| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 # Dart Editor promote and google storage cleanup tools. | 7 # Dart Editor promote and google storage cleanup tools. |
| 8 | 8 |
| 9 import gsutil | 9 import gsutil |
| 10 import optparse | 10 import optparse |
| 11 import os | 11 import os |
| 12 import subprocess | 12 import subprocess |
| 13 import sys | 13 import sys |
| 14 | 14 |
| 15 from os.path import join | 15 from os.path import join |
| 16 | 16 |
| 17 CONTINUOUS = 'gs://dart-editor-archive-continuous' | 17 CONTINUOUS = 'gs://dart-editor-archive-continuous' |
| 18 TRUNK = 'gs://dart-editor-archive-trunk' |
| 18 TESTING = 'gs://dart-editor-archive-testing' | 19 TESTING = 'gs://dart-editor-archive-testing' |
| 19 INTEGRATION = 'gs://dart-editor-archive-integration' | 20 INTEGRATION = 'gs://dart-editor-archive-integration' |
| 20 RELEASE = 'gs://dart-editor-archive-release' | 21 RELEASE = 'gs://dart-editor-archive-release' |
| 21 | 22 |
| 22 DART_PATH = os.path.join('..', '..', '..', 'dart') | 23 DART_PATH = os.path.join('..', '..', '..', 'dart') |
| 23 | 24 |
| 24 def _BuildOptions(): | 25 def _BuildOptions(): |
| 25 """Setup the argument processing for this program. | 26 """Setup the argument processing for this program. |
| 26 | 27 |
| 27 Returns: | 28 Returns: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 47 | 48 |
| 48 promote revision 567 from integration to release | 49 promote revision 567 from integration to release |
| 49 python gsTool.py promote --integration --revision=567""" | 50 python gsTool.py promote --integration --revision=567""" |
| 50 | 51 |
| 51 | 52 |
| 52 result = optparse.OptionParser(usage=usage) | 53 result = optparse.OptionParser(usage=usage) |
| 53 result.set_default('gsbucketuri', 'gs://dart-editor-archive-continuous') | 54 result.set_default('gsbucketuri', 'gs://dart-editor-archive-continuous') |
| 54 result.set_default('keepcount', 1000) | 55 result.set_default('keepcount', 1000) |
| 55 result.set_default('dryrun', False) | 56 result.set_default('dryrun', False) |
| 56 result.set_default('continuous', False) | 57 result.set_default('continuous', False) |
| 58 result.set_default('trunk', False) |
| 57 result.set_default('integration', False) | 59 result.set_default('integration', False) |
| 58 result.set_default('testing', False) | 60 result.set_default('testing', False) |
| 59 group = optparse.OptionGroup(result, 'Cleanup', | 61 group = optparse.OptionGroup(result, 'Cleanup', |
| 60 'options used to cleanup Google Storage') | 62 'options used to cleanup Google Storage') |
| 61 group.add_option('--keepcount', | 63 group.add_option('--keepcount', |
| 62 type='int', | 64 type='int', |
| 63 help='Numer of Builds to keep.', | 65 help='Numer of Builds to keep.', |
| 64 action='store') | 66 action='store') |
| 65 result.add_option_group(group) | 67 result.add_option_group(group) |
| 66 | 68 |
| 67 group = optparse.OptionGroup(result, 'Promote', | 69 group = optparse.OptionGroup(result, 'Promote', |
| 68 'options used to promote code') | 70 'options used to promote code') |
| 69 group.add_option('--revision', | 71 group.add_option('--revision', |
| 70 help='The svn revision to promote', | 72 help='The svn revision to promote', |
| 71 action='store') | 73 action='store') |
| 72 group.add_option('--continuous', | 74 group.add_option('--continuous', |
| 73 help='Promote from continuous', | 75 help='Promote from continuous', |
| 74 action='store_true') | 76 action='store_true') |
| 77 group.add_option('--trunk', |
| 78 help='Promote from trunk', |
| 79 action='store_true') |
| 75 group.add_option('--integration', | 80 group.add_option('--integration', |
| 76 help='Promote from integration', | 81 help='Promote from integration', |
| 77 action='store_true') | 82 action='store_true') |
| 78 result.add_option_group(group) | 83 result.add_option_group(group) |
| 79 | 84 |
| 80 result.add_option('--gsbucketuri', | 85 result.add_option('--gsbucketuri', |
| 81 help='Dart Continuous Google Storage bucket URI.', | 86 help='Dart Continuous Google Storage bucket URI.', |
| 82 action='store') | 87 action='store') |
| 83 result.add_option('--gsutilloc', | 88 result.add_option('--gsutilloc', |
| 84 help='location of gsutil the program', | 89 help='location of gsutil the program', |
| (...skipping 20 matching lines...) Expand all Loading... |
| 105 print 'At least one command must be specified' | 110 print 'At least one command must be specified' |
| 106 parser.print_help() | 111 parser.print_help() |
| 107 sys.exit(1) | 112 sys.exit(1) |
| 108 | 113 |
| 109 if args[0] == 'promote': | 114 if args[0] == 'promote': |
| 110 command = 'promote' | 115 command = 'promote' |
| 111 if options.revision is None: | 116 if options.revision is None: |
| 112 print 'You must specify a --revision to specify which revision to promote' | 117 print 'You must specify a --revision to specify which revision to promote' |
| 113 parser.print_help() | 118 parser.print_help() |
| 114 sys.exit(3) | 119 sys.exit(3) |
| 115 if not (options.continuous or options.integration or options.testing): | 120 if not (options.continuous or options.integration or |
| 116 print 'You must specify one of --continuous or --integration or --testing' | 121 options.testing or options.trunk): |
| 122 print 'You must specify --continuous, --integration, --testing, or --trunk
' |
| 117 parser.print_help() | 123 parser.print_help() |
| 118 sys.exit(4) | 124 sys.exit(4) |
| 119 if options.continuous and options.integration: | 125 if options.continuous and options.integration: |
| 120 print 'continuous and integration can not be specified at the same time' | 126 print 'continuous and integration can not be specified at the same time' |
| 121 parser.print_help() | 127 parser.print_help() |
| 122 sys.exit(5) | 128 sys.exit(5) |
| 123 if (options.continuous or options.integration) and options.testing: | 129 if (options.continuous or options.integration) and options.testing: |
| 124 print """Warning --continuous or --integration and --testing are | 130 print """Warning --continuous or --integration and --testing are |
| 125 specified. The --testing flag will take precedence and all data will | 131 specified. The --testing flag will take precedence and all data will |
| 126 go to the testing bucket {0}""".format(TESTING) | 132 go to the testing bucket {0}""".format(TESTING) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 139 | 145 |
| 140 if options.testing: | 146 if options.testing: |
| 141 bucket_from = CONTINUOUS | 147 bucket_from = CONTINUOUS |
| 142 bucket_to = TESTING | 148 bucket_to = TESTING |
| 143 print """The --testing attribute is specified. All data will go to the | 149 print """The --testing attribute is specified. All data will go to the |
| 144 testing bucket {0}. Press enter to continue""".format(TESTING) | 150 testing bucket {0}. Press enter to continue""".format(TESTING) |
| 145 raw_input('Press Enter to continue') | 151 raw_input('Press Enter to continue') |
| 146 elif options.continuous: | 152 elif options.continuous: |
| 147 bucket_from = CONTINUOUS | 153 bucket_from = CONTINUOUS |
| 148 bucket_to = INTEGRATION | 154 bucket_to = INTEGRATION |
| 155 elif options.trunk: |
| 156 bucket_from = TRUNK |
| 157 bucket_to = INTEGRATION |
| 149 elif options.integration: | 158 elif options.integration: |
| 150 bucket_from = INTEGRATION | 159 bucket_from = INTEGRATION |
| 151 bucket_to = RELEASE | 160 bucket_to = RELEASE |
| 152 | 161 |
| 153 if command == 'cleanup': | 162 if command == 'cleanup': |
| 154 #if the testing flag is set remove the date from the testing bucket | 163 #if the testing flag is set remove the date from the testing bucket |
| 155 if options.testing: | 164 if options.testing: |
| 156 bucket = TESTING | 165 bucket = TESTING |
| 157 #otherwise use the value passed as --gsbucketuri | 166 #otherwise use the value passed as --gsbucketuri |
| 158 else: | 167 else: |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 if directory is not None: | 274 if directory is not None: |
| 266 cwd = os.getcwd() | 275 cwd = os.getcwd() |
| 267 os.chdir(directory) | 276 os.chdir(directory) |
| 268 subprocess.call(cmd, env=os.environ) | 277 subprocess.call(cmd, env=os.environ) |
| 269 if directory is not None: | 278 if directory is not None: |
| 270 os.chdir(cwd) | 279 os.chdir(cwd) |
| 271 | 280 |
| 272 | 281 |
| 273 if __name__ == '__main__': | 282 if __name__ == '__main__': |
| 274 sys.exit(main()) | 283 sys.exit(main()) |
| OLD | NEW |