OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The LUCI Authors. All rights reserved. | 2 # Copyright 2013 The LUCI Authors. All rights reserved. |
3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
5 | 5 |
6 """Client tool to trigger tasks or retrieve results from a Swarming server.""" | 6 """Client tool to trigger tasks or retrieve results from a Swarming server.""" |
7 | 7 |
8 __version__ = '0.8.7' | 8 __version__ = '0.8.7' |
M-A Ruel
2016/10/26 18:47:32
bump
| |
9 | 9 |
10 import collections | 10 import collections |
11 import datetime | 11 import datetime |
12 import json | 12 import json |
13 import logging | 13 import logging |
14 import optparse | 14 import optparse |
15 import os | 15 import os |
16 import subprocess | 16 import subprocess |
17 import sys | 17 import sys |
18 import threading | 18 import threading |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 'cipd_input', | 168 'cipd_input', |
169 'command', | 169 'command', |
170 'dimensions', | 170 'dimensions', |
171 'env', | 171 'env', |
172 'execution_timeout_secs', | 172 'execution_timeout_secs', |
173 'extra_args', | 173 'extra_args', |
174 'grace_period_secs', | 174 'grace_period_secs', |
175 'idempotent', | 175 'idempotent', |
176 'inputs_ref', | 176 'inputs_ref', |
177 'io_timeout_secs', | 177 'io_timeout_secs', |
178 'outputs', | |
178 ]) | 179 ]) |
179 | 180 |
180 | 181 |
181 # See ../appengine/swarming/swarming_rpcs.py. | 182 # See ../appengine/swarming/swarming_rpcs.py. |
182 NewTaskRequest = collections.namedtuple( | 183 NewTaskRequest = collections.namedtuple( |
183 'NewTaskRequest', | 184 'NewTaskRequest', |
184 [ | 185 [ |
185 'expiration_secs', | 186 'expiration_secs', |
186 'name', | 187 'name', |
187 'parent_task_id', | 188 'parent_task_id', |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
953 parser.task_group.add_option( | 954 parser.task_group.add_option( |
954 '--cipd-package', action='append', default=[], | 955 '--cipd-package', action='append', default=[], |
955 help='CIPD packages to install on the Swarming bot. Uses the format: ' | 956 help='CIPD packages to install on the Swarming bot. Uses the format: ' |
956 'path:package_name:version') | 957 'path:package_name:version') |
957 parser.task_group.add_option( | 958 parser.task_group.add_option( |
958 '--service-account', | 959 '--service-account', |
959 help='Name of a service account to run the task as. Only literal "bot" ' | 960 help='Name of a service account to run the task as. Only literal "bot" ' |
960 'string can be specified currently (to run the task under bot\'s ' | 961 'string can be specified currently (to run the task under bot\'s ' |
961 'account). Don\'t use task service accounts if not given ' | 962 'account). Don\'t use task service accounts if not given ' |
962 '(default).') | 963 '(default).') |
964 parser.task_group.add_option( | |
965 '-o', '--output', action='append', default=[], | |
966 help='A list of files to return in addition to those written to' | |
967 '$(ISOLATED_OUTDIR). An error will occur if a file specified by' | |
968 'this option is also written directly to $(ISOLATED_OUTDIR).') | |
963 parser.add_option_group(parser.task_group) | 969 parser.add_option_group(parser.task_group) |
964 | 970 |
965 | 971 |
966 def process_trigger_options(parser, options, args): | 972 def process_trigger_options(parser, options, args): |
967 """Processes trigger options and does preparatory steps. | 973 """Processes trigger options and does preparatory steps. |
968 | 974 |
969 Uploads files to isolate server and generates service account tokens if | 975 Uploads files to isolate server and generates service account tokens if |
970 necessary. | 976 necessary. |
971 """ | 977 """ |
972 options.dimensions = dict(options.dimensions) | 978 options.dimensions = dict(options.dimensions) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1019 properties = TaskProperties( | 1025 properties = TaskProperties( |
1020 cipd_input=cipd_input, | 1026 cipd_input=cipd_input, |
1021 command=None if isolated_input else command, | 1027 command=None if isolated_input else command, |
1022 dimensions=options.dimensions, | 1028 dimensions=options.dimensions, |
1023 env=options.env, | 1029 env=options.env, |
1024 execution_timeout_secs=options.hard_timeout, | 1030 execution_timeout_secs=options.hard_timeout, |
1025 extra_args=command if isolated_input else None, | 1031 extra_args=command if isolated_input else None, |
1026 grace_period_secs=30, | 1032 grace_period_secs=30, |
1027 idempotent=options.idempotent, | 1033 idempotent=options.idempotent, |
1028 inputs_ref=inputs_ref, | 1034 inputs_ref=inputs_ref, |
1029 io_timeout_secs=options.io_timeout) | 1035 io_timeout_secs=options.io_timeout, |
1036 outputs=options.output) | |
1030 if not all(len(t.split(':', 1)) == 2 for t in options.tags): | 1037 if not all(len(t.split(':', 1)) == 2 for t in options.tags): |
1031 parser.error('--tags must be in the format key:value') | 1038 parser.error('--tags must be in the format key:value') |
1032 | 1039 |
1033 # Convert a service account email to a signed service account token to pass | 1040 # Convert a service account email to a signed service account token to pass |
1034 # to Swarming. | 1041 # to Swarming. |
1035 service_account_token = None | 1042 service_account_token = None |
1036 if options.service_account in ('bot', 'none'): | 1043 if options.service_account in ('bot', 'none'): |
1037 service_account_token = options.service_account | 1044 service_account_token = options.service_account |
1038 elif options.service_account: | 1045 elif options.service_account: |
1039 # pylint: disable=assignment-from-no-return | 1046 # pylint: disable=assignment-from-no-return |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1637 dispatcher = subcommand.CommandDispatcher(__name__) | 1644 dispatcher = subcommand.CommandDispatcher(__name__) |
1638 return dispatcher.execute(OptionParserSwarming(version=__version__), args) | 1645 return dispatcher.execute(OptionParserSwarming(version=__version__), args) |
1639 | 1646 |
1640 | 1647 |
1641 if __name__ == '__main__': | 1648 if __name__ == '__main__': |
1642 subprocess42.inhibit_os_error_reporting() | 1649 subprocess42.inhibit_os_error_reporting() |
1643 fix_encoding.fix_encoding() | 1650 fix_encoding.fix_encoding() |
1644 tools.disable_buffering() | 1651 tools.disable_buffering() |
1645 colorama.init() | 1652 colorama.init() |
1646 sys.exit(main(sys.argv[1:])) | 1653 sys.exit(main(sys.argv[1:])) |
OLD | NEW |