Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Side by Side Diff: client/run_isolated.py

Issue 2060983006: luci-py/isolateserver.py: Add archive support when downloading. (Closed) Base URL: https://github.com/luci/luci-py.git@master
Patch Set: Adding a test. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2012 The LUCI Authors. All rights reserved. 2 # Copyright 2012 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 """Runs a command with optional isolated input/output. 6 """Runs a command with optional isolated input/output.
7 7
8 Despite name "run_isolated", can run a generic non-isolated command specified as 8 Despite name "run_isolated", can run a generic non-isolated command specified as
9 args. 9 args.
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 # unsupported and probably unneeded. 84 # unsupported and probably unneeded.
85 assert not zip_package.is_zipped_module(sys.modules[__name__]) 85 assert not zip_package.is_zipped_module(sys.modules[__name__])
86 assert THIS_FILE_PATH 86 assert THIS_FILE_PATH
87 assert BASE_DIR 87 assert BASE_DIR
88 package = zip_package.ZipPackage(root=BASE_DIR) 88 package = zip_package.ZipPackage(root=BASE_DIR)
89 package.add_python_file(THIS_FILE_PATH, '__main__.py' if executable else None) 89 package.add_python_file(THIS_FILE_PATH, '__main__.py' if executable else None)
90 package.add_python_file(os.path.join(BASE_DIR, 'isolated_format.py')) 90 package.add_python_file(os.path.join(BASE_DIR, 'isolated_format.py'))
91 package.add_python_file(os.path.join(BASE_DIR, 'isolateserver.py')) 91 package.add_python_file(os.path.join(BASE_DIR, 'isolateserver.py'))
92 package.add_python_file(os.path.join(BASE_DIR, 'auth.py')) 92 package.add_python_file(os.path.join(BASE_DIR, 'auth.py'))
93 package.add_python_file(os.path.join(BASE_DIR, 'cipd.py')) 93 package.add_python_file(os.path.join(BASE_DIR, 'cipd.py'))
94 package.add_directory(os.path.join(BASE_DIR, 'libs'))
nodir 2016/06/20 15:54:35 why do we need this?
mithro 2016/06/21 06:42:33 The ar files are under libs/
94 package.add_directory(os.path.join(BASE_DIR, 'third_party')) 95 package.add_directory(os.path.join(BASE_DIR, 'third_party'))
95 package.add_directory(os.path.join(BASE_DIR, 'utils')) 96 package.add_directory(os.path.join(BASE_DIR, 'utils'))
96 return package 97 return package
97 98
98 99
99 def make_temp_dir(prefix, root_dir=None): 100 def make_temp_dir(prefix, root_dir=None):
100 """Returns a temporary directory. 101 """Returns a temporary directory.
101 102
102 If root_dir is given and /tmp is on same file system as root_dir, uses /tmp. 103 If root_dir is given and /tmp is on same file system as root_dir, uses /tmp.
103 Otherwise makes a new temp directory under root_dir. 104 Otherwise makes a new temp directory under root_dir.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 isolated_hash=isolated_hash, 264 isolated_hash=isolated_hash,
264 storage=storage, 265 storage=storage,
265 cache=cache, 266 cache=cache,
266 outdir=outdir) 267 outdir=outdir)
267 return bundle, { 268 return bundle, {
268 'duration': time.time() - start, 269 'duration': time.time() - start,
269 'initial_number_items': cache.initial_number_items, 270 'initial_number_items': cache.initial_number_items,
270 'initial_size': cache.initial_size, 271 'initial_size': cache.initial_size,
271 'items_cold': base64.b64encode(large.pack(sorted(cache.added))), 272 'items_cold': base64.b64encode(large.pack(sorted(cache.added))),
272 'items_hot': base64.b64encode( 273 'items_hot': base64.b64encode(
273 large.pack(sorted(set(cache.linked) - set(cache.added)))), 274 large.pack(sorted(set(cache.used) - set(cache.added)))),
274 } 275 }
275 276
276 277
277 def delete_and_upload(storage, out_dir, leak_temp_dir): 278 def delete_and_upload(storage, out_dir, leak_temp_dir):
278 """Deletes the temporary run directory and uploads results back. 279 """Deletes the temporary run directory and uploads results back.
279 280
280 Returns: 281 Returns:
281 tuple(outputs_ref, success, stats) 282 tuple(outputs_ref, success, stats)
282 - outputs_ref: a dict referring to the results archived back to the isolated 283 - outputs_ref: a dict referring to the results archived back to the isolated
283 server, if applicable. 284 server, if applicable.
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 except cipd.Error as ex: 741 except cipd.Error as ex:
741 print >> sys.stderr, ex.message 742 print >> sys.stderr, ex.message
742 return 1 743 return 1
743 744
744 745
745 if __name__ == '__main__': 746 if __name__ == '__main__':
746 subprocess42.inhibit_os_error_reporting() 747 subprocess42.inhibit_os_error_reporting()
747 # Ensure that we are always running with the correct encoding. 748 # Ensure that we are always running with the correct encoding.
748 fix_encoding.fix_encoding() 749 fix_encoding.fix_encoding()
749 sys.exit(main(sys.argv[1:])) 750 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698