OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Uploads files to Google Storage content addressed.""" | 6 """Uploads files to Google Storage content addressed.""" |
7 | 7 |
8 import hashlib | 8 import hashlib |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 (code, | 116 (code, |
117 'Encountered error on setting metadata on %s\n%s' % | 117 'Encountered error on setting metadata on %s\n%s' % |
118 (file_url, err))) | 118 (file_url, err))) |
119 | 119 |
120 | 120 |
121 def get_targets(args, parser, use_null_terminator): | 121 def get_targets(args, parser, use_null_terminator): |
122 if not args: | 122 if not args: |
123 parser.error('Missing target.') | 123 parser.error('Missing target.') |
124 | 124 |
125 if len(args) == 1 and args[0] == '-': | 125 if len(args) == 1 and args[0] == '-': |
126 # Take stdin as a newline or null seperated list of files. | 126 # Take stdin as a newline or null separated list of files. |
127 if use_null_terminator: | 127 if use_null_terminator: |
128 return sys.stdin.read().split('\0') | 128 return sys.stdin.read().split('\0') |
129 else: | 129 else: |
130 return sys.stdin.read().splitlines() | 130 return sys.stdin.read().splitlines() |
131 else: | 131 else: |
132 return args | 132 return args |
133 | 133 |
134 | 134 |
135 def upload_to_google_storage( | 135 def upload_to_google_storage( |
136 input_filenames, base_url, gsutil, force, | 136 input_filenames, base_url, gsutil, force, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 input_filenames, base_url, gsutil, options.force, options.use_md5, | 290 input_filenames, base_url, gsutil, options.force, options.use_md5, |
291 options.num_threads, options.skip_hashing, options.gzip) | 291 options.num_threads, options.skip_hashing, options.gzip) |
292 | 292 |
293 | 293 |
294 if __name__ == '__main__': | 294 if __name__ == '__main__': |
295 try: | 295 try: |
296 sys.exit(main()) | 296 sys.exit(main()) |
297 except KeyboardInterrupt: | 297 except KeyboardInterrupt: |
298 sys.stderr.write('interrupted\n') | 298 sys.stderr.write('interrupted\n') |
299 sys.exit(1) | 299 sys.exit(1) |
OLD | NEW |