| OLD | NEW |
| 1 # Copyright 2012 The LUCI Authors. All rights reserved. | 1 # Copyright 2012 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import datetime | 5 import datetime |
| 6 import getpass | 6 import getpass |
| 7 import hashlib | 7 import hashlib |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import subprocess | 10 import subprocess |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 def parse_args(use_isolate_server, use_swarming): | 29 def parse_args(use_isolate_server, use_swarming): |
| 30 """Process arguments for the example scripts.""" | 30 """Process arguments for the example scripts.""" |
| 31 os.chdir(ROOT_DIR) | 31 os.chdir(ROOT_DIR) |
| 32 colorama.init() | 32 colorama.init() |
| 33 | 33 |
| 34 parser = optparse.OptionParser(description=sys.modules['__main__'].__doc__) | 34 parser = optparse.OptionParser(description=sys.modules['__main__'].__doc__) |
| 35 if use_isolate_server: | 35 if use_isolate_server: |
| 36 parser.add_option( | 36 parser.add_option( |
| 37 '-I', '--isolate-server', | 37 '-I', '--isolate-server', |
| 38 metavar='URL', default=os.environ.get('ISOLATE_SERVER', ''), | 38 metavar='URL', default=os.environ.get('ISOLATE_SERVER', ''), |
| 39 help='Isolate server to use') | 39 help='Isolate server to use (default: ISOLATE_SERVER env var)') |
| 40 if use_swarming: | 40 if use_swarming: |
| 41 task_name = '%s-%s-hello_world' % ( | 41 task_name = '%s-%s-hello_world' % ( |
| 42 getpass.getuser(), | 42 getpass.getuser(), |
| 43 datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')) | 43 datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')) |
| 44 parser.add_option( | 44 parser.add_option( |
| 45 '--idempotent', action='store_true', | 45 '--idempotent', action='store_true', |
| 46 help='Tells Swarming to reused previous task result if possible') | 46 help='Tells Swarming to reused previous task result if possible') |
| 47 parser.add_option( | 47 parser.add_option( |
| 48 '-S', '--swarming', | 48 '-S', '--swarming', |
| 49 metavar='URL', default=os.environ.get('SWARMING_SERVER', ''), | 49 metavar='URL', default=os.environ.get('SWARMING_SERVER', ''), |
| 50 help='Swarming server to use') | 50 help='Swarming server to use (default: SWARMING_SERVER env var)') |
| 51 parser.add_option( | 51 parser.add_option( |
| 52 '-o', '--os', default=sys.platform, | 52 '-o', '--os', default=sys.platform, |
| 53 help='Swarming slave OS to request. Should be one of the valid ' | 53 help='Swarming slave OS to request. Should be one of the valid ' |
| 54 'sys.platform values like darwin, linux2 or win32 default: ' | 54 'sys.platform values like darwin, linux2 or win32 default: ' |
| 55 '%default.') | 55 '%default.') |
| 56 parser.add_option( | 56 parser.add_option( |
| 57 '-t', '--task-name', default=task_name, | 57 '-t', '--task-name', default=task_name, |
| 58 help='Swarming task name, default is based on time: %default') | 58 help='Swarming task name, default is based on time: %default') |
| 59 parser.add_option( | 59 parser.add_option( |
| 60 '--service-account', | 60 '--service-account', |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 'isolate.py', | 123 'isolate.py', |
| 124 'archive', | 124 'archive', |
| 125 '--isolate', os.path.join('payload', 'hello_world.isolate'), | 125 '--isolate', os.path.join('payload', 'hello_world.isolate'), |
| 126 '--isolated', isolated, | 126 '--isolated', isolated, |
| 127 '--isolate-server', isolate_server, | 127 '--isolate-server', isolate_server, |
| 128 '--config-variable', 'OS', swarming_os, | 128 '--config-variable', 'OS', swarming_os, |
| 129 ], verbose) | 129 ], verbose) |
| 130 with open(isolated, 'rb') as f: | 130 with open(isolated, 'rb') as f: |
| 131 hashval = hashlib.sha1(f.read()).hexdigest() | 131 hashval = hashlib.sha1(f.read()).hexdigest() |
| 132 return isolated, hashval | 132 return isolated, hashval |
| OLD | NEW |