Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # This zips the SDK and uploads it to Google Storage when run on a buildbot. | 7 # This zips the SDK and uploads it to Google Storage when run on a buildbot. |
| 8 # | |
| 9 # Usage: upload_sdk.py path_to_sdk | |
| 8 | 10 |
| 9 import os | 11 import os |
| 10 import subprocess | 12 import subprocess |
| 11 import sys | 13 import sys |
| 12 import utils | 14 import utils |
| 13 | 15 |
| 16 from os.path import basename, dirname, join | |
|
Siggi Cherem (dart-lang)
2011/12/13 19:01:00
I personally like how this looks in the code, but
dgrove
2011/12/13 22:38:41
Done.
| |
| 17 | |
| 14 | 18 |
| 15 GSUTIL = '/b/build/scripts/slave/gsutil' | 19 GSUTIL = '/b/build/scripts/slave/gsutil' |
| 16 GS_SITE = 'gs://' | 20 GS_SITE = 'gs://' |
| 17 GS_DIR = 'dart-dump-render-tree' | 21 GS_DIR = 'dart-dump-render-tree' |
| 18 LATEST = 'latest' | 22 LATEST = 'latest' |
|
Siggi Cherem (dart-lang)
2011/12/13 19:01:00
this var is not used
dgrove
2011/12/13 22:38:41
Done.
| |
| 19 SDK = 'sdk' | 23 SDK = 'sdk' |
|
Siggi Cherem (dart-lang)
2011/12/13 19:01:00
maybe rename to GS_SDK_SUBDIR (for a moment I thou
dgrove
2011/12/13 22:38:41
Done.
| |
| 20 | 24 |
| 21 def ExecuteCommand(cmd): | 25 def ExecuteCommand(cmd): |
| 22 """Execute a command in a subprocess. | 26 """Execute a command in a subprocess. |
| 23 """ | 27 """ |
| 24 print 'Executing: ' + ' '.join(cmd) | 28 print 'Executing: ' + ' '.join(cmd) |
| 25 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 29 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 26 output = pipe.communicate() | 30 output = pipe.communicate() |
| 27 if pipe.returncode != 0: | 31 if pipe.returncode != 0: |
| 28 print 'Execution failed: ' + str(output) | 32 print 'Execution failed: ' + str(output) |
| 29 return (pipe.returncode, output) | 33 return (pipe.returncode, output) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 sys.stderr.write('Path not found: %s\n' % argv[1]) | 72 sys.stderr.write('Path not found: %s\n' % argv[1]) |
| 69 Usage(argv[0]) | 73 Usage(argv[0]) |
| 70 return 1 | 74 return 1 |
| 71 if not os.path.exists(GSUTIL): | 75 if not os.path.exists(GSUTIL): |
| 72 sys.stderr.write('cound not find {0}'.format(GSUTIL)) | 76 sys.stderr.write('cound not find {0}'.format(GSUTIL)) |
| 73 exit(0) | 77 exit(0) |
| 74 revision = GetSVNRevision() | 78 revision = GetSVNRevision() |
| 75 if revision is None: | 79 if revision is None: |
| 76 sys.stderr.write('Unable to find SVN revision.\n') | 80 sys.stderr.write('Unable to find SVN revision.\n') |
| 77 return 1 | 81 return 1 |
| 78 os.chdir(argv[1]) | 82 os.chdir(dirname(argv[1])) |
| 83 revision_file = open(join(basename(argv[1]), 'revision'), 'w') | |
| 84 revision_file.write(revision + '\n') | |
| 85 revision_file.close() | |
|
Siggi Cherem (dart-lang)
2011/12/13 19:01:00
(nit): slightly better style:
with open(join(basen
dgrove
2011/12/13 22:38:41
Done.
| |
| 86 | |
| 79 # TODO(dgrove) - deal with architectures that are not ia32. | 87 # TODO(dgrove) - deal with architectures that are not ia32. |
| 80 sdk_name = 'dart-' + utils.GuessOS() + '-' + revision + '.zip' | 88 sdk_file = 'dart-' + utils.GuessOS() + '-' + revision + '.zip' |
|
Siggi Cherem (dart-lang)
2011/12/13 19:01:00
(style nit):
sdk_file = 'dart-%s-%s.zip' % (utils.
| |
| 81 sdk_file = '../' + sdk_name | 89 ExecuteCommand(['zip', '-yr', sdk_file, basename(argv[1])]) |
| 82 ExecuteCommand(['zip', '-yr', sdk_file, '.']) | 90 UploadArchive(sdk_file, GS_SITE + join(gsdir, SDK, sdk_file)) |
| 83 UploadArchive(sdk_file, GS_SITE + os.path.join(gsdir, SDK, sdk_name)) | |
| 84 latest_name = 'dart-' + utils.GuessOS() + '-latest' + '.zip' | 91 latest_name = 'dart-' + utils.GuessOS() + '-latest' + '.zip' |
| 85 UploadArchive(sdk_file, GS_SITE + os.path.join(gsdir, SDK, latest_name)) | 92 UploadArchive(sdk_file, GS_SITE + join(gsdir, SDK, latest_name)) |
| 86 | 93 |
| 87 | 94 |
| 88 if __name__ == '__main__': | 95 if __name__ == '__main__': |
| 89 sys.exit(main(sys.argv)) | 96 sys.exit(main(sys.argv)) |
| 90 | 97 |
| 91 | 98 |
| OLD | NEW |