Bug 727386

Summary: zanata po push does not assume working directory
Product: [Community] Zanata Reporter: Joshua Wulf <jwulf>
Component: Component-PythonClientAssignee: James Ni <jni>
Status: CLOSED NEXTRELEASE QA Contact: Ding-Yi Chen <dchen>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 1.2CC: fedora, jni, lcarlon, sflaniga, zanata-bugs
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Fixed In Version: 1.3.4 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-04-05 02:40:02 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 786670    

Description Joshua Wulf 2011-08-01 22:24:54 EDT
User-Agent:       Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.124 Safari/534.30

When I run zanata po push in a directory with a .pot file, the python client complains that it can't find the source folder. 

I have to run 

zanata po push --srcdir .

It should assume .

Reproducible: Always

Steps to Reproduce:
1. Run "zanata po push" in a folder containing zanata.xml and "something.pot"
Actual Results:  
get an error "error: Can not find source folder, please specify the source folder with '--srcdir' option"

Expected Results:  
It should assume "--srcdir ." by default
Comment 1 James Ni 2011-08-01 22:50:59 EDT
Thanks, actually i assume that user running command in folder containing zanata.xml and a folder named po which contain "something.pot" and "something.po". I agree with you, it should assume "--srcdir ." by default. I will change source code.
Comment 2 Sean Flanigan 2011-08-03 03:44:35 EDT
Actually, to keeps backwards compatibility, we need to keep --srcdir's default as "./po" in 'zanata po push'.

However, we should change the default for --srcdir in the new generic command 'zanata push' to be ".", ie current directory.  The same goes for --transdir and for the new command 'zanata pull'.
Comment 3 Joshua Wulf 2011-08-03 05:11:15 EDT
Another alternative:

Keep the current behaviour, add searching the current working directory if it is not found in a ./po directory.

So it would behave the as expected for existing users who are used to the previous behaviour, and would also work for people who put the zanata.xml file in the same directory as the .pot file.

That would be forwards-compatible as well, because the new zanata push could replicate that search pattern.
Comment 4 Sean Flanigan 2011-08-04 01:37:41 EDT
I think it would help a lot if the helptext mentioned the default value for each option, especially for --srcdir.  If we do that, describing even a simple search algorithm becomes a pain.  (And even simple search algorithms add a little complexity, and need testing.)

Also it wouldn't really make sense for a generic push/pull to look at a directory named "po", since it's supposed to be generic.  Eventually it will be pushing and pulling other file formats, not just gettext.

We do plan to deprecate the old publican/po push/pull before much longer.
Comment 5 James Ni 2011-08-16 06:06:50 EDT
I have modified source code for srcdir processing in commit 4ea63b:
1)First, checking the '.', if finding pot files, then srcdir point to '.'.
2)Then, if can not find pot files under current path, check the pot/po folder under current path, if finding pot files, then srcdir point to pot/po folder
3)At last, if can not find pot files in both case, give a error to user that can not find the source files. 

For --transdir, the default value is '.' for the command 'zanata pull'. 

For 'zanata po push', i assume transdir default value is equal to srcdir value, because normally they are in the same folder for the software project. For 'zanata publican push', i set transdir default value to '.'

I have test these on my local machine, it seems working fine.
Comment 6 Sean Flanigan 2012-02-17 03:12:44 EST
James, what you've done is fine for "zanata po push", but the generic "zanata push" should look only in $srcdir, NOT in $srcdir/po.
Comment 7 Sean Flanigan 2012-02-17 03:14:19 EST
The reason for this is to be symmetrical with "zanata pull", which defaults to current directory when writing.

Thus, "zanata push" will push from "." by default, and "zanata pull" will pull to "." by default.
Comment 8 Mario Santagiuliana 2012-02-22 07:37:12 EST
I am trying to push po file to publican-ug on zanata web site.
I copy Italian config xml file in my directory. I done:

$ zanata pull --lang it --project-type podir

I copied my translated file and trying to push the translation to zanata website I have got every times:
error: Can not find source folder, please specify the source folder with '--srcdir' or 'dir' option

exactly explained in the first comment.

$ rpm -q zanata-python-client

Could you provides an rpm update? Thank you.
Comment 9 Sean Flanigan 2012-02-22 19:34:39 EST
Hi Mario,

This bug is about the "po push" command, which is deprecated in favour of the generic "push" command.  http://www.redhat.com/mailman/listinfo/zanata-users is probably the best place to discuss this, but...

Unfortunately, the Zanata server currently doesn't allow translators to push PO files from the command line, only project maintainers (and only together with the POT files).  

The current command-line push feature is designed to allow project maintainers to push the source language (English) and import any *pre-existing* translations.  New translation work should be done in Zanata's web editor.
Comment 10 Mario Santagiuliana 2012-02-23 02:24:49 EST
Thanks Sean for your reply. I hope you can upgrade the zanata server. Sometime for translators are easiest to translate locally and then push their po files...

Thank you!
Comment 11 James Ni 2012-02-23 22:36:36 EST

I have modified source code base on Sean's comment, "zanata push" will push from "." by default, and "zanata pull" will pull to "." by default. This change is included in version 1.3.4 of zanata-python-client. 

Please use "yum install zanata-python-client --enablerepo=updates-testing" to install and test the new version
Comment 12 Ding-Yi Chen 2012-02-28 01:28:09 EST
VERIFIED with 1.3.4