Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: build.py

Issue 8627097: Moved Chrome extension scripts to buildtools repository (Closed)
Patch Set: Created Oct. 19, 2012, 10:42 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | localeSyncChrome.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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':
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:
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:
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:
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 import buildtools.packagerGecko as packager
235 localesDir = packager.getLocalesDir(baseDir) 299 localesDir = packager.getLocalesDir(baseDir)
236 basename = packager.readMetadata(baseDir).get('general', 'baseName') 300 basename = packager.readMetadata(baseDir).get('general', 'baseName')
237 301
238 import buildtools.localeTools as localeTools 302 import buildtools.localeTools as localeTools
239 localeTools.getTranslations(localesDir, packager.defaultLocale, basename, key) 303 localeTools.getTranslations(localesDir, packager.defaultLocale, basename, key)
240 304
241 305
242 def showDescriptions(baseDir, scriptName, opts, args, type): 306 def showDescriptions(baseDir, scriptName, opts, args, type):
243 locales = None 307 locales = None
244 for option, value in opts: 308 for option, value in opts:
245 if option in ('-l', '--locales'): 309 if option in ('-l', '--locales'):
246 locales = value.split(',') 310 locales = value.split(',')
247 311
248 import buildtools.packager as packager 312 import buildtools.packagerGecko as packager
249 if locales == None: 313 if locales == None:
250 locales = packager.getLocales(baseDir) 314 locales = packager.getLocales(baseDir)
251 elif locales == 'all': 315 elif locales == 'all':
252 locales = packager.getLocales(baseDir, True) 316 locales = packager.getLocales(baseDir, True)
253 317
254 data = packager.readLocaleMetadata(baseDir, locales) 318 data = packager.readLocaleMetadata(baseDir, locales)
255 localeCodes = data.keys() 319 localeCodes = data.keys()
256 localeCodes.sort() 320 localeCodes.sort()
257 for localeCode in localeCodes: 321 for localeCode in localeCodes:
258 locale = data[localeCode] 322 locale = data[localeCode]
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 return 379 return
316 version = args[0] 380 version = args[0]
317 if re.search(r'[^\w\.]', version): 381 if re.search(r'[^\w\.]', version):
318 print 'Wrong version number format' 382 print 'Wrong version number format'
319 usage(scriptName, type, 'release') 383 usage(scriptName, type, 'release')
320 return 384 return
321 385
322 if keyFile == None: 386 if keyFile == None:
323 print 'Warning: no key file specified, creating an unsigned release build\ n' 387 print 'Warning: no key file specified, creating an unsigned release build\ n'
324 388
325 import buildtools.releaseAutomation as releaseAutomation 389 import buildtools.releaseAutomationGecko as releaseAutomation
326 releaseAutomation.run(baseDir, version, keyFile, downloadsRepo, buildtoolsRe po) 390 releaseAutomation.run(baseDir, version, keyFile, downloadsRepo, buildtoolsRe po)
327 else: 391 else:
328 import buildtools.releaseAutomationKMeleon as releaseAutomationKMeleon 392 import buildtools.releaseAutomationKMeleon as releaseAutomation
329 releaseAutomationKMeleon.run(baseDir, downloadsRepo, buildtoolsRepo) 393 releaseAutomation.run(baseDir, downloadsRepo, buildtoolsRepo)
394
395 def syncLocales(baseDir, scriptName, opts, args, type):
396 if len(args) == 0:
397 print 'Please specify the directory of the source Firefox extension as a par ameter'
398 usage(scriptName, type, 'synclocales')
399 return
400 sourceDir = args[0]
401
402 import buildtools.localeSyncChrome as localeSync
403 localeSync.run(baseDir, sourceDir)
404
405 def updatePSL(baseDir, scriptName, opts, args, type):
406 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater
407 publicSuffixListUpdater.updatePSL(baseDir)
330 408
331 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command: 409 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command:
332 command.shortDescription = 'Show this message' 410 command.shortDescription = 'Show this message'
333 411
334 with addCommand(runBuild, 'build') as command: 412 with addCommand(runBuild, 'build') as command:
335 command.shortDescription = 'Create a build' 413 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.' 414 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]' 415 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') 416 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') 417 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') 418 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') 419 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') 420 command.addOption('Create a release build', short='r', long='release')
343 command.addOption('Create a build for Babelzilla', long='babelzilla') 421 command.addOption('Enable use of experimental APIs', long='experimental')
344 command.supportedTypes = ('gecko', 'kmeleon') 422 command.addOption('Create a build for Babelzilla', long='babelzilla', types=(' gecko'))
423 command.supportedTypes = ('gecko', 'kmeleon', 'chrome')
345 424
346 with addCommand(runAutoInstall, 'autoinstall') as command: 425 with addCommand(runAutoInstall, 'autoinstall') as command:
347 command.shortDescription = 'Install extension automatically' 426 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.' 427 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>' 428 command.params = '[<host>:]<port>'
350 command.addOption('Create a build for leak testing', short='m', long='multi-co mpartment') 429 command.addOption('Create a build for leak testing', short='m', long='multi-co mpartment')
351 command.supportedTypes = ('gecko') 430 command.supportedTypes = ('gecko')
352 431
353 with addCommand(setupTranslations, 'setuptrans') as command: 432 with addCommand(setupTranslations, 'setuptrans') as command:
354 command.shortDescription = 'Sets up translation languages' 433 command.shortDescription = 'Sets up translation languages'
355 command.description = 'Sets up translation languages for the project on crowdi n.net.' 434 command.description = 'Sets up translation languages for the project on crowdi n.net.'
356 command.params = '[options] project-key' 435 command.params = '[options] project-key'
357 command.supportedTypes = ('gecko') 436 command.supportedTypes = ('gecko', 'chrome')
358 437
359 with addCommand(updateTranslationMaster, 'translate') as command: 438 with addCommand(updateTranslationMaster, 'translate') as command:
360 command.shortDescription = 'Updates translation master files' 439 command.shortDescription = 'Updates translation master files'
361 command.description = 'Updates the translation master files in the project on crowdin.net.' 440 command.description = 'Updates the translation master files in the project on crowdin.net.'
362 command.params = '[options] project-key' 441 command.params = '[options] project-key'
363 command.supportedTypes = ('gecko') 442 command.supportedTypes = ('gecko', 'chrome')
443
444 with addCommand(uploadTranslations, 'uploadtrans') as command:
445 command.shortDescription = 'Uploads existing translations'
446 command.description = 'Uploads already existing translations to the project on crowdin.net.'
447 command.params = '[options] project-key'
448 command.supportedTypes = ('gecko', 'chrome')
364 449
365 with addCommand(getTranslations, 'gettranslations') as command: 450 with addCommand(getTranslations, 'gettranslations') as command:
366 command.shortDescription = 'Downloads translation updates' 451 command.shortDescription = 'Downloads translation updates'
367 command.description = 'Downloads updated translations from crowdin.net.' 452 command.description = 'Downloads updated translations from crowdin.net.'
368 command.params = '[options] project-key' 453 command.params = '[options] project-key'
369 command.supportedTypes = ('gecko') 454 command.supportedTypes = ('gecko')
370 455
371 with addCommand(showDescriptions, 'showdesc') as command: 456 with addCommand(showDescriptions, 'showdesc') as command:
372 command.shortDescription = 'Print description strings for all locales' 457 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.' 458 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') 459 command.addOption('Only include the given locales', short='l', long='locales', value='l1,l2,l3')
375 command.params = '[options]' 460 command.params = '[options]'
376 command.supportedTypes = ('gecko') 461 command.supportedTypes = ('gecko')
377 462
378 with addCommand(generateDocs, 'docs') as command: 463 with addCommand(generateDocs, 'docs') as command:
379 command.shortDescription = 'Generate documentation' 464 command.shortDescription = 'Generate documentation'
380 command.description = 'Generate documentation files and write them into the sp ecified directory.' 465 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') 466 command.addOption('JsDoc Toolkit location', short='t', long='toolkit', value=' dir')
382 command.params = '[options] <directory>' 467 command.params = '[options] <directory>'
383 command.supportedTypes = ('gecko') 468 command.supportedTypes = ('gecko')
384 469
385 with addCommand(runReleaseAutomation, 'release') as command: 470 with addCommand(runReleaseAutomation, 'release') as command:
386 command.shortDescription = 'Run release automation' 471 command.shortDescription = 'Run release automation'
387 command.description = 'Note: If you are not the project owner then you '\ 472 command.description = 'Note: If you are not the project owner then you '\
388 'probably don\'t want to run this!\n\n'\ 473 'probably don\'t want to run this!\n\n'\
389 'Runs release automation: creates downloads for the new version, tags '\ 474 'Runs release automation: creates downloads for the new version, tags '\
390 'source code repository as well as downloads and buildtools repository.' 475 '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') 476 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') 477 command.addOption('Directory containing downloads repository (if omitted ../do wnloads is assumed)', short='d', long='downloads', value='dir')
393 command.params = '[options] <version>' 478 command.params = '[options] <version>'
394 command.supportedTypes = ('gecko', 'kmeleon') 479 command.supportedTypes = ('gecko', 'kmeleon')
395 480
481 with addCommand(syncLocales, 'synclocales') as command:
482 command.shortDescription = 'Sync locales with a Firefox extension'
483 command.description = 'Updates locale files with strings from a Firefox extens ion corresponding to the entries in [locale_sync] metadata section.'
484 command.params = '<firefox_addon_directory>'
485 command.supportedTypes = ('chrome')
486
487 with addCommand(updatePSL, 'updatepsl') as command:
488 command.shortDescription = 'Updates Public Suffix List'
489 command.description = 'Downloads Public Suffix List (see http://publicsuffix.o rg/) and generates lib/publicSuffixList.js from it.'
490 command.supportedTypes = ('chrome')
491
396 def processArgs(baseDir, args, type='gecko'): 492 def processArgs(baseDir, args, type='gecko'):
397 global commands 493 global commands
398 494
399 scriptName = os.path.basename(args[0]) 495 scriptName = os.path.basename(args[0])
400 args = args[1:] 496 args = args[1:]
401 if len(args) == 0: 497 if len(args) == 0:
402 args = ['build'] 498 args = ['build']
403 print ''' 499 print '''
404 No command given, assuming "build". For a list of commands run: 500 No command given, assuming "build". For a list of commands run:
405 501
406 %s help 502 %s help
407 ''' % scriptName 503 ''' % scriptName
408 504
409 command = args[0] 505 command = args[0]
410 if command in commands: 506 if command in commands:
411 if commands[command].isSupported(type): 507 if commands[command].isSupported(type):
412 try: 508 try:
413 opts, args = commands[command].parseArgs(args[1:]) 509 opts, args = commands[command].parseArgs(type, args[1:])
414 except GetoptError, e: 510 except GetoptError, e:
415 print str(e) 511 print str(e)
416 usage(scriptName, type, command) 512 usage(scriptName, type, command)
417 sys.exit(2) 513 sys.exit(2)
418 for option, value in opts: 514 for option, value in opts:
419 if option in ('-h', '--help'): 515 if option in ('-h', '--help'):
420 usage(scriptName, type, command) 516 usage(scriptName, type, command)
421 sys.exit() 517 sys.exit()
422 commands[command](baseDir, scriptName, opts, args, type) 518 commands[command](baseDir, scriptName, opts, args, type)
423 else: 519 else:
424 print 'Command %s is not supported for this application type' % command 520 print 'Command %s is not supported for this application type' % command
425 usage(scriptName, type) 521 usage(scriptName, type)
426 else: 522 else:
427 print 'Command %s is unrecognized' % command 523 print 'Command %s is unrecognized' % command
428 usage(scriptName, type) 524 usage(scriptName, type)
OLDNEW
« no previous file with comments | « no previous file | localeSyncChrome.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld