OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Swarming Authors. All rights reserved. | 2 # Copyright 2013 The Swarming Authors. All rights reserved. |
3 # Use of this source code is governed under the Apache License, Version 2.0 that | 3 # Use of this source code is governed under the Apache License, Version 2.0 that |
4 # can be found in the LICENSE file. | 4 # can be 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.5' | 8 __version__ = '0.4.5' |
9 | 9 |
10 import base64 | 10 import base64 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 # A class to use to communicate with the server by default. Can be changed by | 103 # A class to use to communicate with the server by default. Can be changed by |
104 # 'set_storage_api_class'. Default is IsolateServer. | 104 # 'set_storage_api_class'. Default is IsolateServer. |
105 _storage_api_cls = None | 105 _storage_api_cls = None |
106 | 106 |
107 | 107 |
108 class Error(Exception): | 108 class Error(Exception): |
109 """Generic runtime error.""" | 109 """Generic runtime error.""" |
110 pass | 110 pass |
111 | 111 |
112 | 112 |
| 113 class IsolatedErrorNoCommand(isolated_format.IsolatedError): |
| 114 """Signals an early abort due to lack of command specified.""" |
| 115 pass |
| 116 |
| 117 |
113 class Aborted(Error): | 118 class Aborted(Error): |
114 """Operation aborted.""" | 119 """Operation aborted.""" |
115 pass | 120 pass |
116 | 121 |
117 | 122 |
118 def stream_read(stream, chunk_size): | 123 def stream_read(stream, chunk_size): |
119 """Reads chunks from |stream| and yields them.""" | 124 """Reads chunks from |stream| and yields them.""" |
120 while True: | 125 while True: |
121 data = stream.read(chunk_size) | 126 data = stream.read(chunk_size) |
122 if not data: | 127 if not data: |
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 except IOError: | 1827 except IOError: |
1823 raise isolated_format.MappingError( | 1828 raise isolated_format.MappingError( |
1824 '%s doesn\'t seem to be a valid file. Did you intent to pass a ' | 1829 '%s doesn\'t seem to be a valid file. Did you intent to pass a ' |
1825 'valid hash?' % isolated_hash) | 1830 'valid hash?' % isolated_hash) |
1826 | 1831 |
1827 # Load all *.isolated and start loading rest of the files. | 1832 # Load all *.isolated and start loading rest of the files. |
1828 bundle.fetch(fetch_queue, isolated_hash, algo) | 1833 bundle.fetch(fetch_queue, isolated_hash, algo) |
1829 if require_command and not bundle.command: | 1834 if require_command and not bundle.command: |
1830 # TODO(vadimsh): All fetch operations are already enqueue and there's no | 1835 # TODO(vadimsh): All fetch operations are already enqueue and there's no |
1831 # easy way to cancel them. | 1836 # easy way to cancel them. |
1832 raise isolated_format.IsolatedError('No command to run') | 1837 raise IsolatedErrorNoCommand() |
1833 | 1838 |
1834 with tools.Profiler('GetRest'): | 1839 with tools.Profiler('GetRest'): |
1835 # Create file system hierarchy. | 1840 # Create file system hierarchy. |
1836 if not fs.isdir(outdir): | 1841 if not fs.isdir(outdir): |
1837 fs.makedirs(outdir) | 1842 fs.makedirs(outdir) |
1838 create_directories(outdir, bundle.files) | 1843 create_directories(outdir, bundle.files) |
1839 create_symlinks(outdir, bundle.files.iteritems()) | 1844 create_symlinks(outdir, bundle.files.iteritems()) |
1840 | 1845 |
1841 # Ensure working directory exists. | 1846 # Ensure working directory exists. |
1842 cwd = os.path.normpath(os.path.join(outdir, bundle.relative_cwd)) | 1847 cwd = os.path.normpath(os.path.join(outdir, bundle.relative_cwd)) |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2183 def main(args): | 2188 def main(args): |
2184 dispatcher = subcommand.CommandDispatcher(__name__) | 2189 dispatcher = subcommand.CommandDispatcher(__name__) |
2185 return dispatcher.execute(OptionParserIsolateServer(), args) | 2190 return dispatcher.execute(OptionParserIsolateServer(), args) |
2186 | 2191 |
2187 | 2192 |
2188 if __name__ == '__main__': | 2193 if __name__ == '__main__': |
2189 fix_encoding.fix_encoding() | 2194 fix_encoding.fix_encoding() |
2190 tools.disable_buffering() | 2195 tools.disable_buffering() |
2191 colorama.init() | 2196 colorama.init() |
2192 sys.exit(main(sys.argv[1:])) | 2197 sys.exit(main(sys.argv[1:])) |
OLD | NEW |