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

Side by Side Diff: sitescripts/extensions/bin/createNightlies.py

Issue 10942098: Make sure subprocess calls don`t ignore result codes indicating errors. Fix JS docs generation whil… (Closed)
Patch Set: Fixed wrong argument format Created July 4, 2013, 1:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2013 Eyeo GmbH 4 # Copyright (C) 2006-2013 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 self.changelogFilename = None 57 self.changelogFilename = None
58 58
59 def hasChanges(self): 59 def hasChanges(self):
60 return self.revision != self.previousRevision 60 return self.revision != self.previousRevision
61 61
62 def getCurrentRevision(self): 62 def getCurrentRevision(self):
63 """ 63 """
64 retrieves the current revision number from the repository 64 retrieves the current revision number from the repository
65 """ 65 """
66 command = ['hg', 'log', '-R', self.config.repository, '-r', 'default', '--te mplate', '{rev}'] 66 command = ['hg', 'log', '-R', self.config.repository, '-r', 'default', '--te mplate', '{rev}']
67 (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE).communic ate() 67 return subprocess.check_output(command)
68 return result
69 68
70 def getChanges(self): 69 def getChanges(self):
71 """ 70 """
72 retrieve changes between the current and previous ("first") revision 71 retrieve changes between the current and previous ("first") revision
73 """ 72 """
74 73
75 command = ['hg', 'log', '-R', self.config.repository, '-r', 'tip:0', 74 command = ['hg', 'log', '-R', self.config.repository, '-r', 'tip:0',
76 '-b', 'default', '-l', '50', 75 '-b', 'default', '-l', '50',
77 '--template', '{date|isodate}\\0{author|person}\\0{rev}\\0{desc}\\0\\0'] 76 '--template', '{date|isodate}\\0{author|person}\\0{rev}\\0{desc}\\0\\0']
78 (result, dummy) = subprocess.Popen(command, stdout=subprocess.PIPE).communic ate() 77 result = subprocess.check_output(command)
79 78
80 for change in result.split('\0\0'): 79 for change in result.split('\0\0'):
81 if change: 80 if change:
82 date, author, revision, description = change.split('\0') 81 date, author, revision, description = change.split('\0')
83 yield {'date': date, 'author': author, 'revision': revision, 'descriptio n': description} 82 yield {'date': date, 'author': author, 'revision': revision, 'descriptio n': description}
84 83
85 def copyRepository(self): 84 def copyRepository(self):
86 ''' 85 '''
87 Create a repository copy in a temporary directory 86 Create a repository copy in a temporary directory
88 ''' 87 '''
89 # We cannot use hg archive here due to 88 # We cannot use hg archive here due to
90 # http://bz.selenic.com/show_bug.cgi?id=3747, have to clone properly :-( 89 # http://bz.selenic.com/show_bug.cgi?id=3747, have to clone properly :-(
91 self.tempdir = tempfile.mkdtemp(prefix=self.config.repositoryName) 90 self.tempdir = tempfile.mkdtemp(prefix=self.config.repositoryName)
92 command = ['hg', 'clone', '-q', self.config.repository, '-u', 'default', sel f.tempdir] 91 command = ['hg', 'clone', '-q', self.config.repository, '-u', 'default', sel f.tempdir]
93 subprocess.Popen(command).communicate() 92 subprocess.check_call(command)
94 93
95 def writeChangelog(self, changes): 94 def writeChangelog(self, changes):
96 """ 95 """
97 write the changelog file into the cloned repository 96 write the changelog file into the cloned repository
98 """ 97 """
99 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) 98 baseDir = os.path.join(self.config.nightliesDirectory, self.basename)
100 if not os.path.exists(baseDir): 99 if not os.path.exists(baseDir):
101 os.makedirs(baseDir) 100 os.makedirs(baseDir)
102 changelogFile = "%s-%s.changelog.xhtml" % (self.basename, self.version) 101 changelogFile = "%s-%s.changelog.xhtml" % (self.basename, self.version)
103 changelogPath = os.path.join(baseDir, changelogFile) 102 changelogPath = os.path.join(baseDir, changelogFile)
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 """ 254 """
256 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) 255 baseDir = os.path.join(self.config.nightliesDirectory, self.basename)
257 if not os.path.exists(baseDir): 256 if not os.path.exists(baseDir):
258 os.makedirs(baseDir) 257 os.makedirs(baseDir)
259 outputFile = "%s-%s%s" % (self.basename, self.version, self.config.packageSu ffix) 258 outputFile = "%s-%s%s" % (self.basename, self.version, self.config.packageSu ffix)
260 outputPath = os.path.join(baseDir, outputFile) 259 outputPath = os.path.join(baseDir, outputFile)
261 self.updateURL = urlparse.urljoin(self.config.nightliesURL, self.basename + '/' + outputFile + '?update') 260 self.updateURL = urlparse.urljoin(self.config.nightliesURL, self.basename + '/' + outputFile + '?update')
262 261
263 if self.config.type == 'android': 262 if self.config.type == 'android':
264 apkFile = open(outputPath, 'wb') 263 apkFile = open(outputPath, 'wb')
264
265 try: 265 try:
266 port = get_config().get('extensions', 'androidBuildPort') 266 try:
267 except ConfigParser.NoOptionError: 267 port = get_config().get('extensions', 'androidBuildPort')
268 port = '22' 268 except ConfigParser.NoOptionError:
Sebastian Noack 2013/07/04 13:57:51 Will still with NoSectionError, when the section '
Wladimir Palant 2013/07/05 11:24:33 Given that androidBuildHost is mandatory in the ex
269 buildCommand = ['ssh', '-p', port, get_config().get('extensions', 'android BuildHost')] 269 port = '22'
270 buildCommand += map(pipes.quote, ['/home/android/bin/makedebugbuild.py', ' --revision', self.revision, '--version', self.version, '--stdout']) 270 buildCommand = ['ssh', '-p', port, get_config().get('extensions', 'andro idBuildHost')]
271 process = subprocess.Popen(buildCommand, stdout=apkFile, stderr=None) 271 buildCommand += map(pipes.quote, ['/home/android/bin/makedebugbuild.py', '--revision', self.revision, '--version', self.version, '--stdout'])
Sebastian Noack 2013/07/04 13:57:51 It would be better to use, .extend() instead of +=
Wladimir Palant 2013/07/05 11:24:33 Good point about list.extend(), changed that. os.
272 status = process.wait() 272 subprocess.check_call(buildCommand, stdout=apkFile, close_fds=True)
273 apkFile.close() 273 except:
274 if status:
275 # clear broken output if any 274 # clear broken output if any
276 # exception will be raised later
277 if os.path.exists(outputPath): 275 if os.path.exists(outputPath):
278 os.remove(outputPath) 276 os.remove(outputPath)
277 raise
279 elif self.config.type == 'chrome' or self.config.type == 'opera': 278 elif self.config.type == 'chrome' or self.config.type == 'opera':
280 import buildtools.packagerChrome as packager 279 import buildtools.packagerChrome as packager
281 packager.createBuild(self.tempdir, type=self.config.type, outFile=outputPa th, buildNum=self.revision, keyFile=self.config.keyFile, experimentalAPI=self.co nfig.experimental) 280 packager.createBuild(self.tempdir, type=self.config.type, outFile=outputPa th, buildNum=self.revision, keyFile=self.config.keyFile, experimentalAPI=self.co nfig.experimental)
282 else: 281 else:
283 import buildtools.packagerGecko as packager 282 import buildtools.packagerGecko as packager
284 packager.createBuild(self.tempdir, outFile=outputPath, buildNum=self.revis ion, keyFile=self.config.keyFile) 283 packager.createBuild(self.tempdir, outFile=outputPath, buildNum=self.revis ion, keyFile=self.config.keyFile)
285 284
286 if not os.path.exists(outputPath): 285 if not os.path.exists(outputPath):
287 raise Exception("Build failed, output file hasn't been created") 286 raise Exception("Build failed, output file hasn't been created")
288 287
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 links.append(link) 343 links.append(link)
345 template = get_template(get_config().get('extensions', 'nightlyIndexPage')) 344 template = get_template(get_config().get('extensions', 'nightlyIndexPage'))
346 template.stream({'config': self.config, 'links': links}).dump(outputPath) 345 template.stream({'config': self.config, 'links': links}).dump(outputPath)
347 346
348 def updateDocs(self): 347 def updateDocs(self):
349 if not self.config.type == 'gecko': 348 if not self.config.type == 'gecko':
350 return 349 return
351 350
352 docsdir = tempfile.mkdtemp(prefix='jsdoc') 351 docsdir = tempfile.mkdtemp(prefix='jsdoc')
353 command = ['hg', 'archive', '-R', get_config().get('extensions', 'jsdocRepos itory'), '-r', 'default', docsdir] 352 command = ['hg', 'archive', '-R', get_config().get('extensions', 'jsdocRepos itory'), '-r', 'default', docsdir]
354 subprocess.Popen(command).communicate() 353 subprocess.check_call(command)
355 354
356 try: 355 try:
356 import buildtools.build as build
357 outputPath = os.path.join(self.config.docsDirectory, self.basename) 357 outputPath = os.path.join(self.config.docsDirectory, self.basename)
358 command = ['perl', os.path.join(docsdir, 'jsrun.pl'), 358 build.generateDocs(self.tempdir, None, [("-t", docsdir), ("-q", "")], [out putPath], self.config.type)
359 '-t=' + os.path.join(docsdir, 'templates', 'jsdoc'),
360 '-d=' + outputPath,
361 '-a',
362 '-p',
363 '-x=js',
364 os.path.join(self.tempdir, 'lib')]
365 subprocess.Popen(command, stdout=subprocess.PIPE).communicate()
366 finally: 359 finally:
367 shutil.rmtree(docsdir, ignore_errors=True) 360 shutil.rmtree(docsdir, ignore_errors=True)
368 361
369 def run(self): 362 def run(self):
370 """ 363 """
371 Run the nightly build process for one extension 364 Run the nightly build process for one extension
372 """ 365 """
373 try: 366 try:
374 if self.config.type == 'ie': 367 if self.config.type == 'ie':
375 # We cannot build IE builds, simply list the builds already in 368 # We cannot build IE builds, simply list the builds already in
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 except Exception, ex: 432 except Exception, ex:
440 print >>sys.stderr, "The build for %s failed:" % repo 433 print >>sys.stderr, "The build for %s failed:" % repo
441 traceback.print_exc() 434 traceback.print_exc()
442 435
443 file = open(nightlyConfigFile, 'wb') 436 file = open(nightlyConfigFile, 'wb')
444 nightlyConfig.write(file) 437 nightlyConfig.write(file)
445 438
446 439
447 if __name__ == '__main__': 440 if __name__ == '__main__':
448 main() 441 main()
OLDNEW

Powered by Google App Engine
This is Rietveld