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

Side by Side Diff: gclient.py

Issue 6691034: First pass to transition away for gclient_utils.Error and gclient_utils.CheckedCallError. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 8 months 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
« no previous file with comments | « gcl.py ('k') | gclient_scm.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Meta checkout manager supporting both Subversion and GIT. 6 """Meta checkout manager supporting both Subversion and GIT.
7 7
8 Files 8 Files
9 .gclient : Current client configuration, written by 'config' command. 9 .gclient : Current client configuration, written by 'config' command.
10 Format is a Python script defining 'solutions', a list whose 10 Format is a Python script defining 'solutions', a list whose
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 import sys 61 import sys
62 import urlparse 62 import urlparse
63 import urllib 63 import urllib
64 64
65 import breakpad # pylint: disable=W0611 65 import breakpad # pylint: disable=W0611
66 66
67 import fix_encoding 67 import fix_encoding
68 import gclient_scm 68 import gclient_scm
69 import gclient_utils 69 import gclient_utils
70 from third_party.repo.progress import Progress 70 from third_party.repo.progress import Progress
71 import subprocess2
71 72
72 73
73 def attr(attribute, data): 74 def attr(attribute, data):
74 """Sets an attribute on a function.""" 75 """Sets an attribute on a function."""
75 def hook(fn): 76 def hook(fn):
76 setattr(fn, attribute, data) 77 setattr(fn, attribute, data)
77 return fn 78 return fn
78 return hook 79 return hook
79 80
80 81
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 # interpreter. 447 # interpreter.
447 command[0] = sys.executable 448 command[0] = sys.executable
448 449
449 if '$matching_files' in command: 450 if '$matching_files' in command:
450 splice_index = command.index('$matching_files') 451 splice_index = command.index('$matching_files')
451 command[splice_index:splice_index + 1] = matching_file_list 452 command[splice_index:splice_index + 1] = matching_file_list
452 453
453 try: 454 try:
454 gclient_utils.CheckCallAndFilterAndHeader( 455 gclient_utils.CheckCallAndFilterAndHeader(
455 command, cwd=self.root_dir(), always=True) 456 command, cwd=self.root_dir(), always=True)
456 except gclient_utils.Error, e: 457 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
457 # Use a discrete exit status code of 2 to indicate that a hook action 458 # Use a discrete exit status code of 2 to indicate that a hook action
458 # failed. Users of this script may wish to treat hook action failures 459 # failed. Users of this script may wish to treat hook action failures
459 # differently from VC failures. 460 # differently from VC failures.
460 print >> sys.stderr, 'Error: %s' % str(e) 461 print >> sys.stderr, 'Error: %s' % str(e)
461 sys.exit(2) 462 sys.exit(2)
462 463
463 def root_dir(self): 464 def root_dir(self):
464 return self.parent.root_dir() 465 return self.parent.root_dir()
465 466
466 def enforced_os(self): 467 def enforced_os(self):
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 parser.format_epilog = lambda _: parser.epilog or '' 1255 parser.format_epilog = lambda _: parser.epilog or ''
1255 if argv: 1256 if argv:
1256 command = Command(argv[0]) 1257 command = Command(argv[0])
1257 if command: 1258 if command:
1258 # 'fix' the usage and the description now that we know the subcommand. 1259 # 'fix' the usage and the description now that we know the subcommand.
1259 GenUsage(parser, argv[0]) 1260 GenUsage(parser, argv[0])
1260 return command(parser, argv[1:]) 1261 return command(parser, argv[1:])
1261 # Not a known command. Default to help. 1262 # Not a known command. Default to help.
1262 GenUsage(parser, 'help') 1263 GenUsage(parser, 'help')
1263 return CMDhelp(parser, argv) 1264 return CMDhelp(parser, argv)
1264 except gclient_utils.Error, e: 1265 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
1265 print >> sys.stderr, 'Error: %s' % str(e) 1266 print >> sys.stderr, 'Error: %s' % str(e)
1266 return 1 1267 return 1
1267 1268
1268 1269
1269 if '__main__' == __name__: 1270 if '__main__' == __name__:
1270 fix_encoding.fix_encoding() 1271 fix_encoding.fix_encoding()
1271 sys.exit(Main(sys.argv[1:])) 1272 sys.exit(Main(sys.argv[1:]))
1272 1273
1273 # vim: ts=2:sw=2:tw=80:et: 1274 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « gcl.py ('k') | gclient_scm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698