Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: cros_mark_as_stable.py

Issue 4442001: Add more error checking to preflight queue. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git
Patch Set: Typo fix Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« bin/cbuildbot_unittest.py ('K') | « bin/cbuildbot_unittest.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """This module uprevs a given package's ebuild to the next revision.""" 7 """This module uprevs a given package's ebuild to the next revision."""
8 8
9 9
10 import fileinput 10 import fileinput
11 import gflags 11 import gflags
12 import os 12 import os
13 import re 13 import re
14 import shutil 14 import shutil
15 import subprocess 15 import subprocess
16 import sys 16 import sys
17 17
18 sys.path.append(os.path.join(os.path.dirname(__file__), 'lib')) 18 sys.path.append(os.path.join(os.path.dirname(__file__), 'lib'))
19 from cros_build_lib import Info, RunCommand, Warning, Die 19 from cros_build_lib import Info, RunCommand, Warning, Die
20 20
21 21
22 gflags.DEFINE_string('board', '', 22 gflags.DEFINE_string('board', '',
23 'Board for which the package belongs.', short_name='b') 23 'Board for which the package belongs.', short_name='b')
24 gflags.DEFINE_string('overlays', '', 24 gflags.DEFINE_string('overlays', '',
sosa 2010/11/03 23:49:06 colon separated
25 'Space separated list of overlays to modify.', 25 'Space separated list of overlays to modify.',
26 short_name='o') 26 short_name='o')
27 gflags.DEFINE_string('packages', '', 27 gflags.DEFINE_string('packages', '',
28 'Space separated list of packages to mark as stable.', 28 'Space separated list of packages to mark as stable.',
sosa 2010/11/03 23:49:06 colon-separated
29 short_name='p') 29 short_name='p')
30 gflags.DEFINE_string('push_options', '', 30 gflags.DEFINE_string('push_options', '',
31 'Options to use with git-cl push using push command.') 31 'Options to use with git-cl push using push command.')
32 gflags.DEFINE_string('srcroot', '%s/trunk/src' % os.environ['HOME'], 32 gflags.DEFINE_string('srcroot', '%s/trunk/src' % os.environ['HOME'],
33 'Path to root src directory.', 33 'Path to root src directory.',
34 short_name='r') 34 short_name='r')
35 gflags.DEFINE_string('tracking_branch', 'cros/master', 35 gflags.DEFINE_string('tracking_branch', 'cros/master',
36 'Used with commit to specify branch to track against.', 36 'Used with commit to specify branch to track against.',
37 short_name='t') 37 short_name='t')
38 gflags.DEFINE_boolean('all', False, 38 gflags.DEFINE_boolean('all', False,
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 _SimpleRunCommand('git commit -m "%s"' % description) 233 _SimpleRunCommand('git commit -m "%s"' % description)
234 # Ugh. There has got to be an easier way to push to a tracking branch 234 # Ugh. There has got to be an easier way to push to a tracking branch
235 _SimpleRunCommand('git config push.default tracking') 235 _SimpleRunCommand('git config push.default tracking')
236 _SimpleRunCommand('git push') 236 _SimpleRunCommand('git push')
237 237
238 238
239 def _SimpleRunCommand(command): 239 def _SimpleRunCommand(command):
240 """Runs a shell command and returns stdout back to caller.""" 240 """Runs a shell command and returns stdout back to caller."""
241 _Print(' + %s' % command) 241 _Print(' + %s' % command)
242 proc_handle = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) 242 proc_handle = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
243 return proc_handle.communicate()[0] 243 stdout = proc_handle.communicate()[0]
244 retcode = proc_handle.wait()
245 if retcode != 0:
246 Die("Non-zero return code (%s) for command: %s" % (retcode, command))
sosa 2010/11/03 23:49:06 Can you throw an exception instead.
247 return stdout
244 248
245 249
246 # ======================= End Global Helper Functions ======================== 250 # ======================= End Global Helper Functions ========================
247 251
248 252
249 class _GitBranch(object): 253 class _GitBranch(object):
250 """Wrapper class for a git branch.""" 254 """Wrapper class for a git branch."""
251 255
252 def __init__(self, branch_name): 256 def __init__(self, branch_name):
253 """Sets up variables but does not create the branch.""" 257 """Sets up variables but does not create the branch."""
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 def main(argv): 477 def main(argv):
474 try: 478 try:
475 argv = gflags.FLAGS(argv) 479 argv = gflags.FLAGS(argv)
476 if len(argv) != 2: 480 if len(argv) != 2:
477 _PrintUsageAndDie('Must specify a valid command') 481 _PrintUsageAndDie('Must specify a valid command')
478 else: 482 else:
479 command = argv[1] 483 command = argv[1]
480 except gflags.FlagsError, e : 484 except gflags.FlagsError, e :
481 _PrintUsageAndDie(str(e)) 485 _PrintUsageAndDie(str(e))
482 486
483 package_list = gflags.FLAGS.packages.split() 487 package_list = gflags.FLAGS.packages.split(':')
484 _CheckSaneArguments(package_list, command) 488 _CheckSaneArguments(package_list, command)
485 if gflags.FLAGS.overlays: 489 if gflags.FLAGS.overlays:
486 overlays = dict((path, []) for path in gflags.FLAGS.overlays.split()) 490 overlays = {}
491 for path in gflags.FLAGS.overlays.split(':'):
492 if not os.path.exists(path):
493 Die('Cannot find overlay: %s' % path)
494 overlays[path] = []
487 else: 495 else:
496 Warning('Missing --overlays argument')
488 overlays = { 497 overlays = {
489 '%s/private-overlays/chromeos-overlay' % gflags.FLAGS.srcroot: [], 498 '%s/private-overlays/chromeos-overlay' % gflags.FLAGS.srcroot: [],
490 '%s/third_party/chromiumos-overlay' % gflags.FLAGS.srcroot: [] 499 '%s/third_party/chromiumos-overlay' % gflags.FLAGS.srcroot: []
491 } 500 }
492 501
493 if command == 'commit': 502 if command == 'commit':
494 _BuildEBuildDictionary(overlays, gflags.FLAGS.all, package_list) 503 _BuildEBuildDictionary(overlays, gflags.FLAGS.all, package_list)
495 504
496 for overlay, ebuilds in overlays.items(): 505 for overlay, ebuilds in overlays.items():
497 if not os.path.exists(overlay): 506 if not os.path.exists(overlay):
(...skipping 30 matching lines...) Expand all
528 raise 537 raise
529 538
530 if revved_packages: 539 if revved_packages:
531 _CleanStalePackages(gflags.FLAGS.board, revved_packages) 540 _CleanStalePackages(gflags.FLAGS.board, revved_packages)
532 else: 541 else:
533 work_branch.Delete() 542 work_branch.Delete()
534 543
535 544
536 if __name__ == '__main__': 545 if __name__ == '__main__':
537 main(sys.argv) 546 main(sys.argv)
OLDNEW
« bin/cbuildbot_unittest.py ('K') | « bin/cbuildbot_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698