| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Script that reads omahaproxy and gsutil to determine version of SDK to put | 6 """Script that reads omahaproxy and gsutil to determine version of SDK to put |
| 7 in manifest. | 7 in manifest. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 # pylint is convinced the email module is missing attributes | 10 # pylint is convinced the email module is missing attributes |
| 11 # pylint: disable=E1101 | 11 # pylint: disable=E1101 |
| 12 | 12 |
| 13 import argparse |
| 13 import buildbot_common | 14 import buildbot_common |
| 14 import csv | 15 import csv |
| 15 import cStringIO | 16 import cStringIO |
| 16 import difflib | 17 import difflib |
| 17 import email | 18 import email |
| 18 import logging | 19 import logging |
| 19 import logging.handlers | 20 import logging.handlers |
| 20 import manifest_util | 21 import manifest_util |
| 21 import optparse | |
| 22 import os | 22 import os |
| 23 import posixpath | 23 import posixpath |
| 24 import re | 24 import re |
| 25 import smtplib | 25 import smtplib |
| 26 import subprocess | 26 import subprocess |
| 27 import sys | 27 import sys |
| 28 import time | 28 import time |
| 29 import traceback | 29 import traceback |
| 30 import urllib2 | 30 import urllib2 |
| 31 | 31 |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 def write(self, s): | 872 def write(self, s): |
| 873 self.written.write(s) | 873 self.written.write(s) |
| 874 if self.passthrough: | 874 if self.passthrough: |
| 875 self.passthrough.write(s) | 875 self.passthrough.write(s) |
| 876 | 876 |
| 877 def getvalue(self): | 877 def getvalue(self): |
| 878 return self.written.getvalue() | 878 return self.written.getvalue() |
| 879 | 879 |
| 880 | 880 |
| 881 def main(args): | 881 def main(args): |
| 882 parser = optparse.OptionParser() | 882 parser = argparse.ArgumentParser() |
| 883 parser.add_option('--gsutil', help='path to gsutil.') | 883 parser.add_argument('--gsutil', help='path to gsutil.') |
| 884 parser.add_option('-d', '--debug', help='run in debug mode.', | 884 parser.add_argument('-d', '--debug', help='run in debug mode.', |
| 885 action='store_true') | 885 action='store_true') |
| 886 parser.add_option('--mailfrom', help='email address of sender.') | 886 parser.add_argument('--mailfrom', help='email address of sender.') |
| 887 parser.add_option('--mailto', help='send error mails to...', action='append') | 887 parser.add_argument('--mailto', help='send error mails to...', |
| 888 parser.add_option('-n', '--dryrun', help="don't upload the manifest.", | 888 action='append') |
| 889 parser.add_argument('-n', '--dryrun', help="don't upload the manifest.", |
| 889 action='store_true') | 890 action='store_true') |
| 890 parser.add_option('-v', '--verbose', help='print more diagnotic messages. ' | 891 parser.add_argument('-v', '--verbose', help='print more diagnotic messages. ' |
| 891 'Use more than once for more info.', | 892 'Use more than once for more info.', |
| 892 action='count') | 893 action='count') |
| 893 parser.add_option('--log-file', metavar='FILE', help='log to FILE') | 894 parser.add_argument('--log-file', metavar='FILE', help='log to FILE') |
| 894 parser.add_option('--upload-log', help='Upload log alongside the manifest.', | 895 parser.add_argument('--upload-log', help='Upload log alongside the manifest.', |
| 895 action='store_true') | 896 action='store_true') |
| 896 parser.add_option('--bundle-version', | 897 parser.add_argument('--bundle-version', |
| 897 help='Manually set a bundle version. This can be passed more than once. ' | 898 help='Manually set a bundle version. This can be passed more than once. ' |
| 898 'format: --bundle-version pepper_24=24.0.1312.25', action='append') | 899 'format: --bundle-version pepper_24=24.0.1312.25', action='append') |
| 899 options, args = parser.parse_args(args) | 900 options = parser.parse_args(args) |
| 900 | 901 |
| 901 if (options.mailfrom is None) != (not options.mailto): | 902 if (options.mailfrom is None) != (not options.mailto): |
| 902 options.mailfrom = None | 903 options.mailfrom = None |
| 903 options.mailto = None | 904 options.mailto = None |
| 904 logger.warning('Disabling email, one of --mailto or --mailfrom ' | 905 logger.warning('Disabling email, one of --mailto or --mailfrom ' |
| 905 'was missing.\n') | 906 'was missing.\n') |
| 906 | 907 |
| 907 if options.verbose >= 2: | 908 if options.verbose >= 2: |
| 908 logging.basicConfig(level=logging.DEBUG, filename=options.log_file) | 909 logging.basicConfig(level=logging.DEBUG, filename=options.log_file) |
| 909 elif options.verbose: | 910 elif options.verbose: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 except manifest_util.Error as e: | 954 except manifest_util.Error as e: |
| 954 if options.debug: | 955 if options.debug: |
| 955 raise | 956 raise |
| 956 sys.stderr.write(str(e) + '\n') | 957 sys.stderr.write(str(e) + '\n') |
| 957 return 1 | 958 return 1 |
| 958 | 959 |
| 959 return 0 | 960 return 0 |
| 960 | 961 |
| 961 if __name__ == '__main__': | 962 if __name__ == '__main__': |
| 962 sys.exit(main(sys.argv[1:])) | 963 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |