OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import gzip | 7 import gzip |
8 import logging | 8 import logging |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 | 177 |
178 def _CompressFile(host_file, output): | 178 def _CompressFile(host_file, output): |
179 with gzip.open(output, 'wb') as out: | 179 with gzip.open(output, 'wb') as out: |
180 with open(host_file, 'rb') as input_file: | 180 with open(host_file, 'rb') as input_file: |
181 out.write(input_file.read()) | 181 out.write(input_file.read()) |
182 os.unlink(host_file) | 182 os.unlink(host_file) |
183 | 183 |
184 | 184 |
185 def _ArchiveFiles(host_files, output): | 185 def _ArchiveFiles(host_files, output): |
186 with zipfile.ZipFile(output, 'w') as z: | 186 with zipfile.ZipFile(output, 'w', zipfile.ZIP_DEFLATED) as z: |
187 for host_file in host_files: | 187 for host_file in host_files: |
188 z.write(host_file) | 188 z.write(host_file) |
189 os.unlink(host_file) | 189 os.unlink(host_file) |
190 | 190 |
191 | 191 |
192 def _PrintMessage(heading, eol='\n'): | 192 def _PrintMessage(heading, eol='\n'): |
193 sys.stdout.write('%s%s' % (heading, eol)) | 193 sys.stdout.write('%s%s' % (heading, eol)) |
194 sys.stdout.flush() | 194 sys.stdout.flush() |
195 | 195 |
196 | 196 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 return 1 | 351 return 1 |
352 | 352 |
353 _CaptureAndPullTrace(controllers, | 353 _CaptureAndPullTrace(controllers, |
354 options.time if not options.continuous else 0, | 354 options.time if not options.continuous else 0, |
355 options.output, | 355 options.output, |
356 options.compress) | 356 options.compress) |
357 | 357 |
358 | 358 |
359 if __name__ == '__main__': | 359 if __name__ == '__main__': |
360 sys.exit(main()) | 360 sys.exit(main()) |
OLD | NEW |