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 import json | 5 import json |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 import tempfile | 9 import tempfile |
10 import time | 10 import time |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 parser.print_usage() | 120 parser.print_usage() |
121 sys.exit(1) | 121 sys.exit(1) |
122 target = quick_args[0] | 122 target = quick_args[0] |
123 if target in tests: | 123 if target in tests: |
124 recorder.test = tests[target]().test() | 124 recorder.test = tests[target]().test() |
125 recorder.test.AddCommandLineArgs(parser) | 125 recorder.test.AddCommandLineArgs(parser) |
126 recorder.test.SetArgumentDefaults(parser) | 126 recorder.test.SetArgumentDefaults(parser) |
127 parser.parse_args() | 127 parser.parse_args() |
128 recorder.test.ProcessCommandLineArgs(parser, options) | 128 recorder.test.ProcessCommandLineArgs(parser, options) |
129 ps = tests[target]().CreatePageSet(options) | 129 ps = tests[target]().CreatePageSet(options) |
130 elif target.endswith('.json') or target.endswith('.py'): | 130 elif discover.IsPageSetFile(target): |
131 parser.parse_args() | 131 parser.parse_args() |
132 ps = page_set.PageSet.FromFile(target) | 132 ps = page_set.PageSet.FromFile(target) |
133 elif target.startswith('http'): | 133 elif target.startswith('http'): |
134 parser.parse_args() | 134 parser.parse_args() |
135 ps = _CreatePageSetForUrl(target) | 135 ps = _CreatePageSetForUrl(target) |
136 else: | 136 else: |
137 parser.print_usage() | 137 parser.print_usage() |
138 sys.exit(1) | 138 sys.exit(1) |
139 | 139 |
140 page_runner.ProcessCommandLineArgs(parser, options) | 140 page_runner.ProcessCommandLineArgs(parser, options) |
(...skipping 22 matching lines...) Expand all Loading... |
163 'updated for these pages.') | 163 'updated for these pages.') |
164 logging.warning('Skipped pages:\n%s', '\n'.join(zip(*results.skipped)[0])) | 164 logging.warning('Skipped pages:\n%s', '\n'.join(zip(*results.skipped)[0])) |
165 | 165 |
166 if results.successes: | 166 if results.successes: |
167 # Update the metadata for the pages which were recorded. | 167 # Update the metadata for the pages which were recorded. |
168 ps.wpr_archive_info.AddRecordedPages(results.successes) | 168 ps.wpr_archive_info.AddRecordedPages(results.successes) |
169 else: | 169 else: |
170 os.remove(temp_target_wpr_file_path) | 170 os.remove(temp_target_wpr_file_path) |
171 | 171 |
172 return min(255, len(results.failures)) | 172 return min(255, len(results.failures)) |
OLD | NEW |