Left: | ||
Right: |
OLD | NEW |
---|---|
1 # coding: utf-8 | 1 # coding: utf-8 |
2 | 2 |
3 # This Source Code is subject to the terms of the Mozilla Public License | 3 # This Source Code is subject to the terms of the Mozilla Public License |
4 # version 2.0 (the "License"). You can obtain a copy of the License at | 4 # version 2.0 (the "License"). You can obtain a copy of the License at |
5 # http://mozilla.org/MPL/2.0/. | 5 # http://mozilla.org/MPL/2.0/. |
6 | 6 |
7 import os, sys, re, subprocess, buildtools | 7 import os, sys, re, subprocess, buildtools |
8 from getopt import getopt, GetoptError | 8 from getopt import getopt, GetoptError |
9 | 9 |
10 class Command(object): | 10 class Command(object): |
(...skipping 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 def __exit__(self, exc_type, exc_value, traceback): | 35 def __exit__(self, exc_type, exc_value, traceback): |
36 pass | 36 pass |
37 | 37 |
38 def __call__(self, baseDir, scriptName, opts, args, type): | 38 def __call__(self, baseDir, scriptName, opts, args, type): |
39 return self._handler(baseDir, scriptName, opts, args, type) | 39 return self._handler(baseDir, scriptName, opts, args, type) |
40 | 40 |
41 def isSupported(self, type): | 41 def isSupported(self, type): |
42 return self._supportedTypes == None or type in self._supportedTypes | 42 return self._supportedTypes == None or type in self._supportedTypes |
43 | 43 |
44 def addOption(self, description, short=None, long=None, value=None): | 44 def addOption(self, description, short=None, long=None, value=None, types=None ): |
45 self._options.append((description, short, long, value)) | 45 self._options.append((description, short, long, value, types)) |
46 | 46 |
47 def parseArgs(self, args): | 47 def parseArgs(self, type, args): |
48 shortOptions = map(lambda o: o[1]+':' if o[3] != None else o[1], filter(lamb da o: o[1] != None, self._options)) | 48 shortOptions = map( |
49 longOptions = map(lambda o: o[2]+'=' if o[3] != None else o[2], filter(lambd a o: o[2] != None, self._options)) | 49 lambda o: o[1]+':' if o[3] != None else o[1], |
50 filter( | |
51 lambda o: o[1] != None and (o[4] == None or type in o[4]), | |
52 self._options | |
53 ) | |
54 ) | |
55 longOptions = map( | |
56 lambda o: o[2]+'=' if o[3] != None else o[2], | |
57 filter( | |
58 lambda o: o[2] != None and (o[4] == None or type in o[4]), | |
59 self._options | |
60 ) | |
61 ) | |
50 return getopt(args, ''.join(shortOptions), longOptions) | 62 return getopt(args, ''.join(shortOptions), longOptions) |
51 | 63 |
52 | 64 |
53 commandsList = [] | 65 commandsList = [] |
54 commands = {} | 66 commands = {} |
55 def addCommand(handler, name): | 67 def addCommand(handler, name): |
56 if isinstance(name, basestring): | 68 if isinstance(name, basestring): |
57 aliases = () | 69 aliases = () |
58 else: | 70 else: |
59 name, aliases = (name[0], name[1:]) | 71 name, aliases = (name[0], name[1:]) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 %(scriptName)s <command> --help | 112 %(scriptName)s <command> --help |
101 ''' % { | 113 ''' % { |
102 'scriptName': scriptName, | 114 'scriptName': scriptName, |
103 'descriptions': '\n'.join(descriptions) | 115 'descriptions': '\n'.join(descriptions) |
104 } | 116 } |
105 else: | 117 else: |
106 global commands | 118 global commands |
107 command = commands[commandName] | 119 command = commands[commandName] |
108 description = '\n'.join(map(lambda s: '\n'.join(splitByLength(s, 80)), comma nd.description.split('\n'))) | 120 description = '\n'.join(map(lambda s: '\n'.join(splitByLength(s, 80)), comma nd.description.split('\n'))) |
109 options = [] | 121 options = [] |
110 for descr, short, long, value in command.options: | 122 for descr, short, long, value, types in command.options: |
123 if types != None and type not in types: | |
124 continue | |
111 if short == None: | 125 if short == None: |
112 shortText = '' | 126 shortText = '' |
113 elif value == None: | 127 elif value == None: |
114 shortText = '-%s' % short | 128 shortText = '-%s' % short |
115 else: | 129 else: |
116 shortText = '-%s %s' % (short, value) | 130 shortText = '-%s %s' % (short, value) |
117 if long == None: | 131 if long == None: |
118 longText = '' | 132 longText = '' |
119 elif value == None: | 133 elif value == None: |
120 longText = '--%s' % long | 134 longText = '--%s' % long |
(...skipping 18 matching lines...) Expand all Loading... | |
139 } | 153 } |
140 | 154 |
141 | 155 |
142 def runBuild(baseDir, scriptName, opts, args, type): | 156 def runBuild(baseDir, scriptName, opts, args, type): |
143 locales = None | 157 locales = None |
144 buildNum = None | 158 buildNum = None |
145 multicompartment = False | 159 multicompartment = False |
146 releaseBuild = False | 160 releaseBuild = False |
147 keyFile = None | 161 keyFile = None |
148 limitMetadata = False | 162 limitMetadata = False |
163 experimentalAPI = False | |
149 for option, value in opts: | 164 for option, value in opts: |
150 if option in ('-l', '--locales'): | 165 if option in ('-l', '--locales'): |
151 locales = value.split(',') | 166 locales = value.split(',') |
152 elif option in ('-b', '--build'): | 167 elif option in ('-b', '--build'): |
153 buildNum = int(value) | 168 buildNum = int(value) |
154 elif option in ('-k', '--key'): | 169 elif option in ('-k', '--key'): |
155 keyFile = value | 170 keyFile = value |
156 elif option in ('-m', '--multi-compartment'): | 171 elif option in ('-m', '--multi-compartment'): |
157 multicompartment = True | 172 multicompartment = True |
158 elif option in ('-r', '--release'): | 173 elif option in ('-r', '--release'): |
159 releaseBuild = True | 174 releaseBuild = True |
175 elif option == '--experimental': | |
176 experimentalAPI = True | |
160 elif option == '--babelzilla': | 177 elif option == '--babelzilla': |
161 locales = 'all' | 178 locales = 'all' |
162 limitMetadata = True | 179 limitMetadata = True |
163 outFile = args[0] if len(args) > 0 else None | 180 outFile = args[0] if len(args) > 0 else None |
164 | 181 |
165 if type == 'gecko': | 182 if type == 'gecko': |
166 import buildtools.packager as packager | 183 import buildtools.packagerGecko as packager |
167 packager.createBuild(baseDir, outFile=outFile, locales=locales, buildNum=bui ldNum, | 184 packager.createBuild(baseDir, outFile=outFile, locales=locales, buildNum=bui ldNum, |
168 releaseBuild=releaseBuild, keyFile=keyFile, | 185 releaseBuild=releaseBuild, keyFile=keyFile, |
169 limitMetadata=limitMetadata, multicompartment=multicomp artment) | 186 limitMetadata=limitMetadata, multicompartment=multicomp artment) |
187 elif type == 'chrome': | |
188 import buildtools.packagerChrome as packager | |
189 packager.createBuild(baseDir, outFile=outFile, buildNum=buildNum, | |
190 releaseBuild=releaseBuild, keyFile=keyFile, | |
191 experimentalAPI=experimentalAPI) | |
170 elif type == 'kmeleon': | 192 elif type == 'kmeleon': |
Felix Dahlke
2013/01/10 16:36:20
Shouldn't we get rid of this while we're at it?
Wladimir Palant
2013/01/16 14:20:15
This was done in a separate batch of changes.
| |
171 import buildtools.packagerKMeleon as packagerKMeleon | 193 import buildtools.packagerKMeleon as packager |
172 packagerKMeleon.createBuild(baseDir, outFile=outFile, locales=locales, | 194 packager.createBuild(baseDir, outFile=outFile, locales=locales, |
173 buildNum=buildNum, releaseBuild=releaseBuild) | 195 buildNum=buildNum, releaseBuild=releaseBuild) |
174 | 196 |
175 def runAutoInstall(baseDir, scriptName, opts, args, type): | 197 def runAutoInstall(baseDir, scriptName, opts, args, type): |
176 if len(args) == 0: | 198 if len(args) == 0: |
177 print 'Port of the Extension Auto-Installer needs to be specified' | 199 print 'Port of the Extension Auto-Installer needs to be specified' |
178 usage(scriptName, type, 'autoinstall') | 200 usage(scriptName, type, 'autoinstall') |
179 return | 201 return |
180 | 202 |
181 multicompartment = False | 203 multicompartment = False |
182 for option, value in opts: | 204 for option, value in opts: |
183 if option in ('-m', '--multi-compartment'): | 205 if option in ('-m', '--multi-compartment'): |
184 multicompartment = True | 206 multicompartment = True |
185 | 207 |
186 if ':' in args[0]: | 208 if ':' in args[0]: |
187 host, port = args[0].rsplit(':', 1) | 209 host, port = args[0].rsplit(':', 1) |
188 else: | 210 else: |
189 host, port = ('localhost', args[0]) | 211 host, port = ('localhost', args[0]) |
190 | 212 |
191 import buildtools.packager as packager | 213 import buildtools.packagerGecko as packager |
192 packager.autoInstall(baseDir, host, port, multicompartment=multicompartment) | 214 packager.autoInstall(baseDir, host, port, multicompartment=multicompartment) |
193 | 215 |
194 | 216 |
195 def setupTranslations(baseDir, scriptName, opts, args, type): | 217 def setupTranslations(baseDir, scriptName, opts, args, type): |
196 if len(args) < 1: | 218 if len(args) < 1: |
197 print 'Project key is required to update translation master files.' | 219 print 'Project key is required to update translation master files.' |
198 usage(scriptName, type, 'setuptrans') | 220 usage(scriptName, type, 'setuptrans') |
199 return | 221 return |
200 | 222 |
201 key = args[0] | 223 key = args[0] |
202 | 224 |
203 import buildtools.packager as packager | 225 if type == 'chrome': |
204 locales = packager.getLocales(baseDir, True) | 226 import buildtools.packagerChrome as packager |
205 basename = packager.readMetadata(baseDir).get('general', 'baseName') | 227 locales = os.listdir(os.path.join(baseDir, '_locales')) |
228 locales = map(lambda locale: locale.replace('_', '-'), locales) | |
229 basename = packager.readMetadata(baseDir).get('general', 'baseName') | |
230 else: | |
Felix Dahlke
2013/01/10 16:36:20
Shouldn't we check for the type here as well and h
Wladimir Palant
2013/01/16 14:20:15
Yes, that command is only available for the chrome
| |
231 import buildtools.packagerGecko as packager | |
232 locales = packager.getLocales(baseDir, True) | |
233 basename = packager.readMetadata(baseDir).get('general', 'baseName') | |
206 | 234 |
207 import buildtools.localeTools as localeTools | 235 import buildtools.localeTools as localeTools |
208 localeTools.setupTranslations(locales, basename, key) | 236 localeTools.setupTranslations(type, locales, basename, key) |
209 | 237 |
210 | 238 |
211 def updateTranslationMaster(baseDir, scriptName, opts, args, type): | 239 def updateTranslationMaster(baseDir, scriptName, opts, args, type): |
212 if len(args) < 1: | 240 if len(args) < 1: |
213 print 'Project key is required to update translation master files.' | 241 print 'Project key is required to update translation master files.' |
214 usage(scriptName, type, 'translate') | 242 usage(scriptName, type, 'translate') |
215 return | 243 return |
216 | 244 |
217 key = args[0] | 245 key = args[0] |
218 | 246 |
219 import buildtools.packager as packager | 247 if type == 'chrome': |
220 defaultLocaleDir = os.path.join(packager.getLocalesDir(baseDir), packager.defa ultLocale) | 248 import buildtools.packagerChrome as packager |
221 basename = packager.readMetadata(baseDir).get('general', 'baseName') | 249 defaultLocaleDir = os.path.join(baseDir, '_locales', packager.defaultLocale) |
250 metadata = packager.readMetadata(baseDir) | |
251 basename = metadata.get('general', 'baseName') | |
252 else: | |
Felix Dahlke
2013/01/10 16:36:20
Same as above.
| |
253 import buildtools.packagerGecko as packager | |
254 defaultLocaleDir = os.path.join(packager.getLocalesDir(baseDir), packager.de faultLocale) | |
255 metadata = packager.readMetadata(baseDir) | |
256 basename = metadata.get('general', 'baseName') | |
222 | 257 |
223 import buildtools.localeTools as localeTools | 258 import buildtools.localeTools as localeTools |
224 localeTools.updateTranslationMaster(defaultLocaleDir, packager.defaultLocale, basename, key) | 259 localeTools.updateTranslationMaster(type, metadata, defaultLocaleDir, basename , key) |
260 | |
261 | |
262 def uploadTranslations(baseDir, scriptName, opts, args, type): | |
263 if len(args) < 1: | |
264 print 'Project key is required to upload existing translations.' | |
265 usage(scriptName, type, 'uploadtrans') | |
266 return | |
267 | |
268 key = args[0] | |
269 | |
270 if type == 'chrome': | |
271 import buildtools.packagerChrome as packager | |
272 localesDir = os.path.join(baseDir, '_locales') | |
273 locales = os.listdir(localesDir) | |
274 locales = map(lambda locale: (locale.replace('_', '-'), os.path.join(locales Dir, locale)), locales) | |
275 metadata = packager.readMetadata(baseDir) | |
276 basename = metadata.get('general', 'baseName') | |
277 else: | |
Felix Dahlke
2013/01/10 16:36:20
Same as above.
| |
278 import buildtools.packagerGecko as packager | |
279 localesDir = packager.getLocalesDir(baseDir) | |
280 locales = packager.getLocales(baseDir, True) | |
281 locales = map(lambda locale: (locale, os.path.join(localesDir, locale)), loc ales) | |
282 metadata = packager.readMetadata(baseDir) | |
283 basename = metadata.get('general', 'baseName') | |
284 | |
285 import buildtools.localeTools as localeTools | |
286 for locale, localeDir in locales: | |
287 if locale != packager.defaultLocale: | |
288 localeTools.uploadTranslations(type, metadata, localeDir, locale, basename , key) | |
225 | 289 |
226 | 290 |
227 def getTranslations(baseDir, scriptName, opts, args, type): | 291 def getTranslations(baseDir, scriptName, opts, args, type): |
228 if len(args) < 1: | 292 if len(args) < 1: |
229 print 'Project key is required to update translation master files.' | 293 print 'Project key is required to update translation master files.' |
230 usage(scriptName, type, 'translate') | 294 usage(scriptName, type, 'translate') |
231 return | 295 return |
232 | 296 |
233 key = args[0] | 297 key = args[0] |
234 import buildtools.packager as packager | 298 if type == 'chrome': |
Felix Dahlke
2013/01/10 16:36:20
Same as above.
| |
235 localesDir = packager.getLocalesDir(baseDir) | 299 import buildtools.packagerChrome as packager |
236 basename = packager.readMetadata(baseDir).get('general', 'baseName') | 300 localesDir = os.path.join(baseDir, '_locales') |
301 else: | |
302 import buildtools.packagerGecko as packager | |
303 localesDir = packager.getLocalesDir(baseDir) | |
237 | 304 |
238 import buildtools.localeTools as localeTools | 305 import buildtools.localeTools as localeTools |
239 localeTools.getTranslations(localesDir, packager.defaultLocale, basename, key) | 306 basename = packager.readMetadata(baseDir).get('general', 'baseName') |
307 localeTools.getTranslations(type, localesDir, packager.defaultLocale.replace(' _', '-'), basename, key) | |
240 | 308 |
241 | 309 |
242 def showDescriptions(baseDir, scriptName, opts, args, type): | 310 def showDescriptions(baseDir, scriptName, opts, args, type): |
243 locales = None | 311 locales = None |
244 for option, value in opts: | 312 for option, value in opts: |
245 if option in ('-l', '--locales'): | 313 if option in ('-l', '--locales'): |
246 locales = value.split(',') | 314 locales = value.split(',') |
247 | 315 |
248 import buildtools.packager as packager | 316 import buildtools.packagerGecko as packager |
249 if locales == None: | 317 if locales == None: |
250 locales = packager.getLocales(baseDir) | 318 locales = packager.getLocales(baseDir) |
251 elif locales == 'all': | 319 elif locales == 'all': |
252 locales = packager.getLocales(baseDir, True) | 320 locales = packager.getLocales(baseDir, True) |
253 | 321 |
254 data = packager.readLocaleMetadata(baseDir, locales) | 322 data = packager.readLocaleMetadata(baseDir, locales) |
255 localeCodes = data.keys() | 323 localeCodes = data.keys() |
256 localeCodes.sort() | 324 localeCodes.sort() |
257 for localeCode in localeCodes: | 325 for localeCode in localeCodes: |
258 locale = data[localeCode] | 326 locale = data[localeCode] |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 return | 383 return |
316 version = args[0] | 384 version = args[0] |
317 if re.search(r'[^\w\.]', version): | 385 if re.search(r'[^\w\.]', version): |
318 print 'Wrong version number format' | 386 print 'Wrong version number format' |
319 usage(scriptName, type, 'release') | 387 usage(scriptName, type, 'release') |
320 return | 388 return |
321 | 389 |
322 if keyFile == None: | 390 if keyFile == None: |
323 print 'Warning: no key file specified, creating an unsigned release build\ n' | 391 print 'Warning: no key file specified, creating an unsigned release build\ n' |
324 | 392 |
325 import buildtools.releaseAutomation as releaseAutomation | 393 import buildtools.releaseAutomationGecko as releaseAutomation |
326 releaseAutomation.run(baseDir, version, keyFile, downloadsRepo, buildtoolsRe po) | 394 releaseAutomation.run(baseDir, version, keyFile, downloadsRepo, buildtoolsRe po) |
327 else: | 395 else: |
328 import buildtools.releaseAutomationKMeleon as releaseAutomationKMeleon | 396 import buildtools.releaseAutomationKMeleon as releaseAutomation |
329 releaseAutomationKMeleon.run(baseDir, downloadsRepo, buildtoolsRepo) | 397 releaseAutomation.run(baseDir, downloadsRepo, buildtoolsRepo) |
398 | |
399 def syncLocales(baseDir, scriptName, opts, args, type): | |
400 if len(args) == 0: | |
401 print 'Please specify the directory of the source Firefox extension as a par ameter' | |
402 usage(scriptName, type, 'synclocales') | |
403 return | |
404 sourceDir = args[0] | |
405 | |
406 import buildtools.localeSyncChrome as localeSync | |
407 localeSync.run(baseDir, sourceDir) | |
408 | |
409 def updatePSL(baseDir, scriptName, opts, args, type): | |
410 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater | |
411 publicSuffixListUpdater.updatePSL(baseDir) | |
330 | 412 |
331 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command: | 413 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command: |
332 command.shortDescription = 'Show this message' | 414 command.shortDescription = 'Show this message' |
333 | 415 |
334 with addCommand(runBuild, 'build') as command: | 416 with addCommand(runBuild, 'build') as command: |
335 command.shortDescription = 'Create a build' | 417 command.shortDescription = 'Create a build' |
336 command.description = 'Creates an extension build with given file name. If out put_file is missing a default name will be chosen.' | 418 command.description = 'Creates an extension build with given file name. If out put_file is missing a default name will be chosen.' |
337 command.params = '[options] [output_file]' | 419 command.params = '[options] [output_file]' |
338 command.addOption('Only include the given locales (if omitted: all locales not marked as incomplete)', short='l', long='locales', value='l1,l2,l3') | 420 command.addOption('Only include the given locales (if omitted: all locales not marked as incomplete)', short='l', long='locales', value='l1,l2,l3', types=('ge cko', 'kmeleon')) |
339 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num') | 421 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num') |
340 command.addOption('File containing private key and certificates required to si gn the package', short='k', long='key', value='file') | 422 command.addOption('File containing private key and certificates required to si gn the package', short='k', long='key', value='file', types=('gecko', 'chrome')) |
341 command.addOption('Create a build for leak testing', short='m', long='multi-co mpartment') | 423 command.addOption('Create a build for leak testing', short='m', long='multi-co mpartment', types=('gecko')) |
342 command.addOption('Create a release build', short='r', long='release') | 424 command.addOption('Create a release build', short='r', long='release') |
343 command.addOption('Create a build for Babelzilla', long='babelzilla') | 425 command.addOption('Enable use of experimental APIs', long='experimental') |
344 command.supportedTypes = ('gecko', 'kmeleon') | 426 command.addOption('Create a build for Babelzilla', long='babelzilla', types=(' gecko')) |
427 command.supportedTypes = ('gecko', 'kmeleon', 'chrome') | |
345 | 428 |
346 with addCommand(runAutoInstall, 'autoinstall') as command: | 429 with addCommand(runAutoInstall, 'autoinstall') as command: |
347 command.shortDescription = 'Install extension automatically' | 430 command.shortDescription = 'Install extension automatically' |
348 command.description = 'Will automatically install the extension in a browser r unning Extension Auto-Installer. If host parameter is omitted assumes that the b rowser runs on localhost.' | 431 command.description = 'Will automatically install the extension in a browser r unning Extension Auto-Installer. If host parameter is omitted assumes that the b rowser runs on localhost.' |
349 command.params = '[<host>:]<port>' | 432 command.params = '[<host>:]<port>' |
350 command.addOption('Create a build for leak testing', short='m', long='multi-co mpartment') | 433 command.addOption('Create a build for leak testing', short='m', long='multi-co mpartment') |
351 command.supportedTypes = ('gecko') | 434 command.supportedTypes = ('gecko') |
352 | 435 |
353 with addCommand(setupTranslations, 'setuptrans') as command: | 436 with addCommand(setupTranslations, 'setuptrans') as command: |
354 command.shortDescription = 'Sets up translation languages' | 437 command.shortDescription = 'Sets up translation languages' |
355 command.description = 'Sets up translation languages for the project on crowdi n.net.' | 438 command.description = 'Sets up translation languages for the project on crowdi n.net.' |
356 command.params = '[options] project-key' | 439 command.params = '[options] project-key' |
357 command.supportedTypes = ('gecko') | 440 command.supportedTypes = ('gecko', 'chrome') |
358 | 441 |
359 with addCommand(updateTranslationMaster, 'translate') as command: | 442 with addCommand(updateTranslationMaster, 'translate') as command: |
360 command.shortDescription = 'Updates translation master files' | 443 command.shortDescription = 'Updates translation master files' |
361 command.description = 'Updates the translation master files in the project on crowdin.net.' | 444 command.description = 'Updates the translation master files in the project on crowdin.net.' |
362 command.params = '[options] project-key' | 445 command.params = '[options] project-key' |
363 command.supportedTypes = ('gecko') | 446 command.supportedTypes = ('gecko', 'chrome') |
447 | |
448 with addCommand(uploadTranslations, 'uploadtrans') as command: | |
449 command.shortDescription = 'Uploads existing translations' | |
450 command.description = 'Uploads already existing translations to the project on crowdin.net.' | |
451 command.params = '[options] project-key' | |
452 command.supportedTypes = ('gecko', 'chrome') | |
364 | 453 |
365 with addCommand(getTranslations, 'gettranslations') as command: | 454 with addCommand(getTranslations, 'gettranslations') as command: |
366 command.shortDescription = 'Downloads translation updates' | 455 command.shortDescription = 'Downloads translation updates' |
367 command.description = 'Downloads updated translations from crowdin.net.' | 456 command.description = 'Downloads updated translations from crowdin.net.' |
368 command.params = '[options] project-key' | 457 command.params = '[options] project-key' |
369 command.supportedTypes = ('gecko') | 458 command.supportedTypes = ('gecko', 'chrome') |
370 | 459 |
371 with addCommand(showDescriptions, 'showdesc') as command: | 460 with addCommand(showDescriptions, 'showdesc') as command: |
372 command.shortDescription = 'Print description strings for all locales' | 461 command.shortDescription = 'Print description strings for all locales' |
373 command.description = 'Display description strings for all locales as specifie d in the corresponding meta.properties files.' | 462 command.description = 'Display description strings for all locales as specifie d in the corresponding meta.properties files.' |
374 command.addOption('Only include the given locales', short='l', long='locales', value='l1,l2,l3') | 463 command.addOption('Only include the given locales', short='l', long='locales', value='l1,l2,l3') |
375 command.params = '[options]' | 464 command.params = '[options]' |
376 command.supportedTypes = ('gecko') | 465 command.supportedTypes = ('gecko') |
377 | 466 |
378 with addCommand(generateDocs, 'docs') as command: | 467 with addCommand(generateDocs, 'docs') as command: |
379 command.shortDescription = 'Generate documentation' | 468 command.shortDescription = 'Generate documentation' |
380 command.description = 'Generate documentation files and write them into the sp ecified directory.' | 469 command.description = 'Generate documentation files and write them into the sp ecified directory.' |
381 command.addOption('JsDoc Toolkit location', short='t', long='toolkit', value=' dir') | 470 command.addOption('JsDoc Toolkit location', short='t', long='toolkit', value=' dir') |
382 command.params = '[options] <directory>' | 471 command.params = '[options] <directory>' |
383 command.supportedTypes = ('gecko') | 472 command.supportedTypes = ('gecko') |
384 | 473 |
385 with addCommand(runReleaseAutomation, 'release') as command: | 474 with addCommand(runReleaseAutomation, 'release') as command: |
386 command.shortDescription = 'Run release automation' | 475 command.shortDescription = 'Run release automation' |
387 command.description = 'Note: If you are not the project owner then you '\ | 476 command.description = 'Note: If you are not the project owner then you '\ |
388 'probably don\'t want to run this!\n\n'\ | 477 'probably don\'t want to run this!\n\n'\ |
389 'Runs release automation: creates downloads for the new version, tags '\ | 478 'Runs release automation: creates downloads for the new version, tags '\ |
390 'source code repository as well as downloads and buildtools repository.' | 479 'source code repository as well as downloads and buildtools repository.' |
391 command.addOption('File containing private key and certificates required to si gn the release', short='k', long='key', value='file') | 480 command.addOption('File containing private key and certificates required to si gn the release', short='k', long='key', value='file', types=('gecko')) |
392 command.addOption('Directory containing downloads repository (if omitted ../do wnloads is assumed)', short='d', long='downloads', value='dir') | 481 command.addOption('Directory containing downloads repository (if omitted ../do wnloads is assumed)', short='d', long='downloads', value='dir') |
393 command.params = '[options] <version>' | 482 command.params = '[options] <version>' |
394 command.supportedTypes = ('gecko', 'kmeleon') | 483 command.supportedTypes = ('gecko', 'kmeleon') |
395 | 484 |
485 with addCommand(syncLocales, 'synclocales') as command: | |
486 command.shortDescription = 'Sync locales with a Firefox extension' | |
487 command.description = 'Updates locale files with strings from a Firefox extens ion corresponding to the entries in [locale_sync] metadata section.' | |
488 command.params = '<firefox_addon_directory>' | |
489 command.supportedTypes = ('chrome') | |
490 | |
491 with addCommand(updatePSL, 'updatepsl') as command: | |
492 command.shortDescription = 'Updates Public Suffix List' | |
493 command.description = 'Downloads Public Suffix List (see http://publicsuffix.o rg/) and generates lib/publicSuffixList.js from it.' | |
494 command.supportedTypes = ('chrome') | |
495 | |
396 def processArgs(baseDir, args, type='gecko'): | 496 def processArgs(baseDir, args, type='gecko'): |
397 global commands | 497 global commands |
398 | 498 |
399 scriptName = os.path.basename(args[0]) | 499 scriptName = os.path.basename(args[0]) |
400 args = args[1:] | 500 args = args[1:] |
401 if len(args) == 0: | 501 if len(args) == 0: |
402 args = ['build'] | 502 args = ['build'] |
403 print ''' | 503 print ''' |
404 No command given, assuming "build". For a list of commands run: | 504 No command given, assuming "build". For a list of commands run: |
405 | 505 |
406 %s help | 506 %s help |
407 ''' % scriptName | 507 ''' % scriptName |
408 | 508 |
409 command = args[0] | 509 command = args[0] |
410 if command in commands: | 510 if command in commands: |
411 if commands[command].isSupported(type): | 511 if commands[command].isSupported(type): |
412 try: | 512 try: |
413 opts, args = commands[command].parseArgs(args[1:]) | 513 opts, args = commands[command].parseArgs(type, args[1:]) |
414 except GetoptError, e: | 514 except GetoptError, e: |
415 print str(e) | 515 print str(e) |
416 usage(scriptName, type, command) | 516 usage(scriptName, type, command) |
417 sys.exit(2) | 517 sys.exit(2) |
418 for option, value in opts: | 518 for option, value in opts: |
419 if option in ('-h', '--help'): | 519 if option in ('-h', '--help'): |
420 usage(scriptName, type, command) | 520 usage(scriptName, type, command) |
421 sys.exit() | 521 sys.exit() |
422 commands[command](baseDir, scriptName, opts, args, type) | 522 commands[command](baseDir, scriptName, opts, args, type) |
423 else: | 523 else: |
424 print 'Command %s is not supported for this application type' % command | 524 print 'Command %s is not supported for this application type' % command |
425 usage(scriptName, type) | 525 usage(scriptName, type) |
426 else: | 526 else: |
427 print 'Command %s is unrecognized' % command | 527 print 'Command %s is unrecognized' % command |
428 usage(scriptName, type) | 528 usage(scriptName, type) |
OLD | NEW |