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 buildbot_common | 13 import buildbot_common |
14 import csv | 14 import csv |
15 import cStringIO | 15 import cStringIO |
16 import difflib | 16 import difflib |
17 import email | 17 import email |
18 import logging | 18 import logging |
19 import logging.handlers | 19 import logging.handlers |
20 import manifest_util | 20 import manifest_util |
21 import optparse | 21 import argparse |
binji
2014/11/13 23:57:02
sort
Sam Clegg
2014/11/30 17:55:11
Done.
| |
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[1:]) | 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 19 matching lines...) Expand all Loading... | |
929 | 930 |
930 if options.upload_log: | 931 if options.upload_log: |
931 gsutil_logging_handler = GsutilLoggingHandler(delegate) | 932 gsutil_logging_handler = GsutilLoggingHandler(delegate) |
932 logger.addHandler(gsutil_logging_handler) | 933 logger.addHandler(gsutil_logging_handler) |
933 | 934 |
934 # Only look for naclports archives >= 27. The old ports bundles don't | 935 # Only look for naclports archives >= 27. The old ports bundles don't |
935 # include license information. | 936 # include license information. |
936 extra_archives = [('naclports.tar.bz2', '27.0.0.0')] | 937 extra_archives = [('naclports.tar.bz2', '27.0.0.0')] |
937 Run(delegate, ('mac', 'win', 'linux'), extra_archives, | 938 Run(delegate, ('mac', 'win', 'linux'), extra_archives, |
938 fixed_bundle_versions) | 939 fixed_bundle_versions) |
939 return 0 | |
940 except Exception: | 940 except Exception: |
941 if options.mailfrom and options.mailto: | 941 if options.mailfrom and options.mailto: |
942 traceback.print_exc() | 942 traceback.print_exc() |
943 scriptname = os.path.basename(sys.argv[0]) | 943 scriptname = os.path.basename(sys.argv[0]) |
944 subject = '[%s] Failed to update manifest' % (scriptname,) | 944 subject = '[%s] Failed to update manifest' % (scriptname,) |
945 text = '%s failed.\n\nSTDERR:\n%s\n' % (scriptname, | 945 text = '%s failed.\n\nSTDERR:\n%s\n' % (scriptname, |
946 sys.stderr.getvalue()) | 946 sys.stderr.getvalue()) |
947 delegate.SendMail(subject, text) | 947 delegate.SendMail(subject, text) |
948 return 1 | 948 return 1 |
949 else: | 949 else: |
950 raise | 950 raise |
951 finally: | 951 finally: |
952 if options.upload_log: | 952 if options.upload_log: |
953 gsutil_logging_handler.upload() | 953 gsutil_logging_handler.upload() |
954 except manifest_util.Error as e: | 954 except manifest_util.Error as e: |
955 if options.debug: | 955 if options.debug: |
956 raise | 956 raise |
957 sys.stderr.write(str(e) + '\n') | 957 sys.stderr.write(str(e) + '\n') |
958 return 1 | 958 return 1 |
959 | 959 |
960 return 0 | |
960 | 961 |
961 if __name__ == '__main__': | 962 if __name__ == '__main__': |
962 sys.exit(main(sys.argv)) | 963 sys.exit(main(sys.argv[1:])) |
OLD | NEW |