Bug 814593

Summary: "TypeError: 'unicode' object does not support item assignment" when pulling translation from server
Product: [Fedora] Fedora Reporter: Ding-Yi Chen <dchen>
Component: zanata-python-clientAssignee: James Ni <jni>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: rawhideCC: dchen, jni, jochang, petersen, sflaniga, zanata-bugs
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python client version: 1.3.7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-18 02:42:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ding-Yi Chen 2012-04-20 07:28:28 UTC
Description of problem:
Python client failed to put some of the translation file.

Version-Release number of selected component (if applicable):
Version 1.3.4-18-gb3e6 from Git

zanata python client version: 1.3.4-18-gb3e6, zanata server API version: 1.6.0-alpha-2-SNAPSHOT

How reproducible:
Always

Steps to Reproduce:
0. Make sure locale "de" is enabled, and user joined language group "de"
1. Download tar-1.26.tar.gz from U tar project (http://www.gnu.org/software/tar/#TOCdownloading)
2. tar zxvf tar-1.26.tar.gz
3. cd tar-1.26/po
4. Create zanata.xml like following:
<config xmlns="http://zanata.org/namespace/config/">
  <url>ZanataServerURL</url>
  <project>Tar</project>
  <project-version>1.26</project-version>
  <project-type>gettext</project-type>
  <locales>
    <locale>de</locale>
  </locales>
</config>
5. zanata project create Tar --project-name "GNU Tar" --project-desc "GNU Tar"
6. zanata version create 1.26 --project-id Tar
7. zanata push --push-trans
8. zanata pull --transdir /tmp/Tar

Actual results:
Fetching the content of tar from Zanata server:
Retrieving de translation from server:
Traceback (most recent call last):
  File "/home/dchen/devel/zanata-python-client/zanata", line 25, in <module>
    zanata.run()
  File "/home/dchen/devel/zanata-python-client/zanataclient/zanata.py", line 1413, in run
    program_name=os.path.split(sys.argv[0])[1],
  File "/home/dchen/devel/zanata-python-client/zanataclient/command.py", line 339, in handle_program
    command(command_options, args)
  File "/home/dchen/devel/zanata-python-client/zanataclient/zanata.py", line 1315, in pull
    zanatacmd.pull_command(zanata, locale_map, project_id, iteration_id, filelist, lang_list, outpath, command_type, skeletons)
  File "/home/dchen/devel/zanata-python-client/zanataclient/zanatacmd.py", line 480, in pull_command
    publicanutil.save_to_pofile(pofile, result, pot, skeletons, item, name)
  File "/home/dchen/devel/zanata-python-client/zanataclient/publicanutil.py", line 451, in save_to_pofile
    message.msgstr[i]=msg
TypeError: 'unicode' object does not support item assignment


Expected results:
Pull successfully without error

Additional info:
zanata-python-client-1.3.4 does not have this error.

Comment 1 James Ni 2012-04-24 04:23:50 UTC
Thanks Ding,

I have made a commit yesterday to fix this issue, this issue is about processing msgstr_plural when pulling from server.
 
https://github.com/zanata/zanata-python-client/commit/1594598e4cc870d74d246198d20195140d13b153

I have test on my local machine, both push and pull is correct (for GNU Tar). I am testing the state machine now and try to address the issue you mentioned. 

Thanks

Comment 2 Joyce Chang 2012-05-02 06:41:33 UTC
Hi james,
It didn't seem to work for me, can you look into it again or let me know where I went wrong?
xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config xmlns="http://zanata.org/namespace/config/">
    <url>http://zanata-empire.lab.eng.bne.redhat.com:8080/</url>
        <project>AboutFedora</project>
            <project-type>podir</project-type>
                <project-version>f13</project-version>
                    <locales>
                   	<locale map-from="zh-CN">zh-Hans</locale>
                        </locales>
                        </config>

zanata.ini

zanata_1_5_auto.url=http://zanata-empire.lab.eng.bne.redhat.com:8080/
zanata_1_5_auto.username=admin
zanata_1_5_auto.key=b6d7044e9ee3b2447c28fb7c50d86d98


setup:
zanata python client version: 1.3.5-1-g0279, zanata server API version: 1.6.0-alpha-2
Project: AboutFedora
Version: f13
Username: admin


step 1:locale "zh-CN" is enabled, and user joined language group "zh-CH"
step 2:zanata push --push-trans

actual results:
error: Error 401 - This operation is not authorized, please check username and apikey


if step 2 replaced with:zanata pull 

actual result:
Fetching the content of About_Fedora from Zanata server: 
Retrieving zh-CN translation from server:
error: Error 400 - Unsupported Extensions within this context: comment?skeletons

Fetching the content of Article_Info from Zanata server: 
Retrieving zh-CN translation from server:
error: Error 400 - Unsupported Extensions within this context: comment?skeletons

Fetching the content of Author_Group from Zanata server: 
Retrieving zh-CN translation from server:
error: Error 400 - Unsupported Extensions within this context: comment?skeletons

Fetching the content of Revision_History from Zanata server: 
Retrieving zh-CN translation from server:
error: Error 400 - Unsupported Extensions within this context: comment?skeletons

Comment 3 James Ni 2012-05-07 13:59:20 UTC
(In reply to comment #2)
> Hi james,
> It didn't seem to work for me, can you look into it again or let me know where
> I went wrong?
> xml:
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <config xmlns="http://zanata.org/namespace/config/">
>     <url>http://zanata-empire.lab.eng.bne.redhat.com:8080/</url>
>         <project>AboutFedora</project>
>             <project-type>podir</project-type>
>                 <project-version>f13</project-version>
>                     <locales>
>                     <locale map-from="zh-CN">zh-Hans</locale>
>                         </locales>
>                         </config>
> 
> zanata.ini
> 
> zanata_1_5_auto.url=http://zanata-empire.lab.eng.bne.redhat.com:8080/
> zanata_1_5_auto.username=admin
> zanata_1_5_auto.key=b6d7044e9ee3b2447c28fb7c50d86d98
> 
> 
> setup:
> zanata python client version: 1.3.5-1-g0279, zanata server API version:
> 1.6.0-alpha-2
> Project: AboutFedora
> Version: f13
> Username: admin
> 
> 
> step 1:locale "zh-CN" is enabled, and user joined language group "zh-CH"
> step 2:zanata push --push-trans
> 
> actual results:
> error: Error 401 - This operation is not authorized, please check username and
> apikey


Hi Joycy,

I test the client, if you joined language group "zh-CN", but mapping to "zh-Hans" in zanata.xml, you will receive this error message. I think this is correct responding from server, so please join the "zh-Hans" group on server side, then it will work correct. 
 
> if step 2 replaced with:zanata pull 
> 
> actual result:
> Fetching the content of About_Fedora from Zanata server: 
> Retrieving zh-CN translation from server:
> error: Error 400 - Unsupported Extensions within this context:
> comment?skeletons
> 
> Fetching the content of Article_Info from Zanata server: 
> Retrieving zh-CN translation from server:
> error: Error 400 - Unsupported Extensions within this context:
> comment?skeletons
> 
> Fetching the content of Author_Group from Zanata server: 
> Retrieving zh-CN translation from server:
> error: Error 400 - Unsupported Extensions within this context:
> comment?skeletons
> 
> Fetching the content of Revision_History from Zanata server: 
> Retrieving zh-CN translation from server:
> error: Error 400 - Unsupported Extensions within this context:
> comment?skeletons

Thanks, I think this is a fault in python client, i make a mistake when processing "query param" of skeletons, i should use "&" to separate "query param", i have fixed and commit the changes, so please download the latest source code to verify this issue. It works as expected when i doing test on my side. 

Best Regards 
james

Comment 4 Joyce Chang 2012-05-08 06:27:42 UTC
verified with zanata python client version: 1.3.5-4-gc828

Comment 5 Fedora Update System 2012-06-13 05:38:23 UTC
zanata-python-client-1.3.7-1.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/zanata-python-client-1.3.7-1.fc16

Comment 6 Fedora Update System 2012-06-13 05:39:05 UTC
zanata-python-client-1.3.7-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/zanata-python-client-1.3.7-1.el5

Comment 7 Fedora Update System 2012-06-13 05:39:36 UTC
zanata-python-client-1.3.7-1.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/zanata-python-client-1.3.7-1.fc17

Comment 8 Fedora Update System 2012-06-13 05:40:09 UTC
zanata-python-client-1.3.7-1.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/zanata-python-client-1.3.7-1.fc15

Comment 9 Fedora Update System 2012-06-13 05:40:45 UTC
zanata-python-client-1.3.7-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/zanata-python-client-1.3.7-1.el6

Comment 10 Fedora Update System 2012-06-15 00:18:55 UTC
Package zanata-python-client-1.3.7-1.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing zanata-python-client-1.3.7-1.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-9357/zanata-python-client-1.3.7-1.fc16
then log in and leave karma (feedback).

Comment 11 Fedora Update System 2012-06-15 02:15:17 UTC
Package zanata-python-client-1.3.7-1.el6:
* should fix your issue,
* was pushed to the Fedora EPEL 6 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=epel-testing zanata-python-client-1.3.7-1.el6'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-EPEL-2012-6156/zanata-python-client-1.3.7-1.el6
then log in and leave karma (feedback).

Comment 12 Fedora Update System 2012-07-17 17:30:24 UTC
zanata-python-client-1.3.7-1.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.