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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 interactive = self.options and self.options.interactive | 73 interactive = self.options and self.options.interactive |
74 for action_name in self._action_names: | 74 for action_name in self._action_names: |
75 if not hasattr(page, action_name): | 75 if not hasattr(page, action_name): |
76 continue | 76 continue |
77 if should_reload: | 77 if should_reload: |
78 self.RunNavigateSteps(page, tab) | 78 self.RunNavigateSteps(page, tab) |
79 action_runner = action_runner_module.ActionRunner(page, tab, self) | 79 action_runner = action_runner_module.ActionRunner(page, tab, self) |
80 if interactive: | 80 if interactive: |
81 action_runner.RunAction(interact.InteractAction()) | 81 action_runner.RunAction(interact.InteractAction()) |
82 else: | 82 else: |
83 self._RunMethod(page, self._action_name_to_run, action_runner) | 83 self._RunMethod(page, action_name, action_runner) |
84 should_reload = True | 84 should_reload = True |
85 | 85 |
86 | 86 |
87 def _CreatePageSetForUrl(url): | 87 def _CreatePageSetForUrl(url): |
88 ps_name = urlparse.urlparse(url).hostname + '.json' | 88 ps_name = urlparse.urlparse(url).hostname + '.json' |
89 ps_path = os.path.join(util.GetBaseDir(), 'page_sets', ps_name) | 89 ps_path = os.path.join(util.GetBaseDir(), 'page_sets', ps_name) |
90 ps = {'archive_data_file': '../data/%s' % ps_name, | 90 ps = {'archive_data_file': '../data/%s' % ps_name, |
91 'pages': [ | 91 'pages': [ |
92 { 'url': url } | 92 { 'url': url } |
93 ] | 93 ] |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |