| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 """\ | 6 """\ |
| 7 Wrapper script around Rietveld's upload.py that simplifies working with groups | 7 Wrapper script around Rietveld's upload.py that simplifies working with groups |
| 8 of files. | 8 of files. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import getpass | 11 import getpass |
| 12 import optparse |
| 12 import os | 13 import os |
| 13 import random | 14 import random |
| 14 import re | 15 import re |
| 15 import string | 16 import string |
| 16 import subprocess | 17 import subprocess |
| 17 import sys | 18 import sys |
| 18 import tempfile | 19 import tempfile |
| 19 import time | 20 import time |
| 20 from third_party import upload | 21 from third_party import upload |
| 21 import urllib2 | 22 import urllib2 |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 change_info.Save() | 859 change_info.Save() |
| 859 | 860 |
| 860 if desc_file: | 861 if desc_file: |
| 861 os.remove(desc_file) | 862 os.remove(desc_file) |
| 862 change_info.PrimeLint() | 863 change_info.PrimeLint() |
| 863 os.chdir(previous_cwd) | 864 os.chdir(previous_cwd) |
| 864 print "*** Upload does not submit a try; use gcl try to submit a try. ***" | 865 print "*** Upload does not submit a try; use gcl try to submit a try. ***" |
| 865 return 0 | 866 return 0 |
| 866 | 867 |
| 867 | 868 |
| 868 @need_change | 869 @need_change_and_args |
| 869 def CMDpresubmit(change_info): | 870 @attrs(usage='[--upload]') |
| 871 def CMDpresubmit(change_info, args): |
| 870 """Runs presubmit checks on the change. | 872 """Runs presubmit checks on the change. |
| 871 | 873 |
| 872 The actual presubmit code is implemented in presubmit_support.py and looks | 874 The actual presubmit code is implemented in presubmit_support.py and looks |
| 873 for PRESUBMIT.py files.""" | 875 for PRESUBMIT.py files.""" |
| 874 if not change_info.GetFiles(): | 876 if not change_info.GetFiles(): |
| 875 print "Nothing to presubmit check, changelist is empty." | 877 print('Nothing to presubmit check, changelist is empty.') |
| 876 return 0 | 878 return 0 |
| 877 | 879 parser = optparse.OptionParser() |
| 878 print "*** Presubmit checks for UPLOAD would report: ***" | 880 parser.add_option('--upload', action='store_true') |
| 879 result = DoPresubmitChecks(change_info, False, False) | 881 options, args = parser.parse_args(args) |
| 880 | 882 if args: |
| 881 print "\n*** Presubmit checks for COMMIT would report: ***" | 883 parser.error('Unrecognized args: %s' % args) |
| 882 result &= DoPresubmitChecks(change_info, True, False) | 884 if options.upload: |
| 883 return not result | 885 print('*** Presubmit checks for UPLOAD would report: ***') |
| 886 return not DoPresubmitChecks(change_info, False, False) |
| 887 else: |
| 888 print('*** Presubmit checks for COMMIT would report: ***') |
| 889 return not DoPresubmitChecks(change_info, True, False) |
| 884 | 890 |
| 885 | 891 |
| 886 def TryChange(change_info, args, swallow_exception): | 892 def TryChange(change_info, args, swallow_exception): |
| 887 """Create a diff file of change_info and send it to the try server.""" | 893 """Create a diff file of change_info and send it to the try server.""" |
| 888 try: | 894 try: |
| 889 import trychange | 895 import trychange |
| 890 except ImportError: | 896 except ImportError: |
| 891 if swallow_exception: | 897 if swallow_exception: |
| 892 return 1 | 898 return 1 |
| 893 ErrorExit("You need to install trychange.py to use the try server.") | 899 ErrorExit("You need to install trychange.py to use the try server.") |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 if e.code != 500: | 1377 if e.code != 500: |
| 1372 raise | 1378 raise |
| 1373 print >> sys.stderr, ( | 1379 print >> sys.stderr, ( |
| 1374 'AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 1380 'AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 1375 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)) | 1381 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)) |
| 1376 return 1 | 1382 return 1 |
| 1377 | 1383 |
| 1378 | 1384 |
| 1379 if __name__ == "__main__": | 1385 if __name__ == "__main__": |
| 1380 sys.exit(main(sys.argv[1:])) | 1386 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |