Chromium Code Reviews| 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 by the Apache v2.0 license that can be | 3 # Use of this source code is governed by the Apache v2.0 license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Archives a set of files or directories to an Isolate Server.""" | 6 """Archives a set of files or directories to an Isolate Server.""" |
| 7 | 7 |
| 8 __version__ = '0.4.7' | 8 __version__ = '0.4.7' |
| 9 | 9 |
| 10 import base64 | 10 import base64 |
| (...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2173 '-I', '--isolate-server', | 2173 '-I', '--isolate-server', |
| 2174 metavar='URL', default=os.environ.get('ISOLATE_SERVER', ''), | 2174 metavar='URL', default=os.environ.get('ISOLATE_SERVER', ''), |
| 2175 help='URL of the Isolate Server to use. Defaults to the environment ' | 2175 help='URL of the Isolate Server to use. Defaults to the environment ' |
| 2176 'variable ISOLATE_SERVER if set. No need to specify https://, this ' | 2176 'variable ISOLATE_SERVER if set. No need to specify https://, this ' |
| 2177 'is assumed.') | 2177 'is assumed.') |
| 2178 parser.add_option( | 2178 parser.add_option( |
| 2179 '--namespace', default='default-gzip', | 2179 '--namespace', default='default-gzip', |
| 2180 help='The namespace to use on the Isolate Server, default: %default') | 2180 help='The namespace to use on the Isolate Server, default: %default') |
| 2181 | 2181 |
| 2182 | 2182 |
| 2183 def process_isolate_server_options(parser, options, set_exception_handler): | 2183 def process_isolate_server_options( |
| 2184 """Processes the --isolate-server option and aborts if not specified. | 2184 parser, options, set_exception_handler, required=True): |
|
M-A Ruel
2016/05/02 14:18:14
Can you not make it a default arg and update all c
nodir
2016/05/02 17:43:22
Done in a separate patchset
| |
| 2185 """Processes the --isolate-server option. | |
| 2185 | 2186 |
| 2186 Returns the identity as determined by the server. | 2187 Returns the identity as determined by the server. |
| 2187 """ | 2188 """ |
| 2188 if not options.isolate_server: | 2189 if not options.isolate_server: |
| 2189 parser.error('--isolate-server is required.') | 2190 if required: |
| 2191 parser.error('--isolate-server is required.') | |
| 2192 return | |
| 2193 | |
| 2190 try: | 2194 try: |
| 2191 options.isolate_server = net.fix_url(options.isolate_server) | 2195 options.isolate_server = net.fix_url(options.isolate_server) |
| 2192 except ValueError as e: | 2196 except ValueError as e: |
| 2193 parser.error('--isolate-server %s' % e) | 2197 parser.error('--isolate-server %s' % e) |
| 2194 if set_exception_handler: | 2198 if set_exception_handler: |
| 2195 on_error.report_on_exception_exit(options.isolate_server) | 2199 on_error.report_on_exception_exit(options.isolate_server) |
| 2196 try: | 2200 try: |
| 2197 return auth.ensure_logged_in(options.isolate_server) | 2201 return auth.ensure_logged_in(options.isolate_server) |
| 2198 except ValueError as e: | 2202 except ValueError as e: |
| 2199 parser.error(str(e)) | 2203 parser.error(str(e)) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2261 def main(args): | 2265 def main(args): |
| 2262 dispatcher = subcommand.CommandDispatcher(__name__) | 2266 dispatcher = subcommand.CommandDispatcher(__name__) |
| 2263 return dispatcher.execute(OptionParserIsolateServer(), args) | 2267 return dispatcher.execute(OptionParserIsolateServer(), args) |
| 2264 | 2268 |
| 2265 | 2269 |
| 2266 if __name__ == '__main__': | 2270 if __name__ == '__main__': |
| 2267 fix_encoding.fix_encoding() | 2271 fix_encoding.fix_encoding() |
| 2268 tools.disable_buffering() | 2272 tools.disable_buffering() |
| 2269 colorama.init() | 2273 colorama.init() |
| 2270 sys.exit(main(sys.argv[1:])) | 2274 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |