@@ -114,16 +114,33 @@ def extract(ctx, upload):
114114 # Use the zanata-cli to upload the pot file
115115 # It would be better to use the REST API directly here, but the XML
116116 # payload format is not documented.
117+
118+ # First ensure that the requested branch exists in Zanata
119+ zanata_args = ['/usr/bin/zanata-cli' , '-B' , '-e' , 'put-version' ,
120+ '--url' , ctx .parent .obj ['zanata_url' ],
121+ '--version-project' , ctx .parent .obj ['zanata_project' ],
122+ '--version-slug' , ctx .parent .obj ['branch' ]]
123+ result = subprocess .run (zanata_args , capture_output = True )
124+ if result .returncode :
125+ print (result .stderr .decode ('utf-8' ))
126+ print (result .stdout .decode ('utf-8' ))
127+ sys .exit (1 )
128+
129+ # Update the translatable strings for this branch
117130 zanata_args = ['/usr/bin/zanata-cli' , '-B' , '-e' , 'push' ,
118131 '--url' , ctx .parent .obj ['zanata_url' ],
119132 '--project' , ctx .parent .obj ['zanata_project' ],
120133 '--project-type' , 'gettext' ,
121- '--project-version' , ctx .parent .obj ['branch' ]]
134+ '--project-version' , ctx .parent .obj ['branch' ],
135+ '--src-dir' , '.' ]
122136 result = subprocess .run (zanata_args , capture_output = True )
123137 if result .returncode :
124- print (result .stderr )
125- print (result .stdout )
126- sys .exit (1 )
138+ print (result .stderr .decode ('utf-8' ))
139+ print (result .stdout .decode ('utf-8' ))
140+ sys .exit (2 )
141+
142+ print ("Uploaded translatable strings for %s to Zanata" % (
143+ ctx .obj ['branch' ]))
127144
128145
129146##############################################################################
0 commit comments