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 """Start and stop Web Page Replay. | 6 """Start and stop Web Page Replay. |
7 | 7 |
8 Of the public module names, the following one is key: | 8 Of the public module names, the following one is key: |
9 ReplayServer: a class to start/stop Web Page Replay. | 9 ReplayServer: a class to start/stop Web Page Replay. |
10 """ | 10 """ |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 self._CheckPath('archive directory', os.path.dirname(self.archive_path)) | 113 self._CheckPath('archive directory', os.path.dirname(self.archive_path)) |
114 elif not os.path.exists(self.archive_path): | 114 elif not os.path.exists(self.archive_path): |
115 self._CheckPath('archive file', self.archive_path) | 115 self._CheckPath('archive file', self.archive_path) |
116 self._CheckPath('replay script', self.replay_py) | 116 self._CheckPath('replay script', self.replay_py) |
117 | 117 |
118 self.log_fh = None | 118 self.log_fh = None |
119 self.replay_process = None | 119 self.replay_process = None |
120 | 120 |
121 def _AddDefaultReplayOptions(self): | 121 def _AddDefaultReplayOptions(self): |
122 """Set WPR command-line options. Can be overridden if needed.""" | 122 """Set WPR command-line options. Can be overridden if needed.""" |
123 self.replay_options += [ | 123 self.replay_options = [ |
124 '--host', str(self._replay_host), | 124 '--host', str(self._replay_host), |
125 '--port', str(self._http_port), | 125 '--port', str(self._http_port), |
126 '--ssl_port', str(self._https_port), | 126 '--ssl_port', str(self._https_port), |
127 '--use_closest_match', | 127 '--use_closest_match', |
128 '--no-dns_forwarding', | 128 '--no-dns_forwarding', |
129 '--log_level', 'warning' | 129 '--log_level', 'warning' |
130 ] | 130 ] + self.replay_options |
131 | 131 |
132 def _CheckPath(self, label, path): | 132 def _CheckPath(self, label, path): |
133 if not os.path.exists(path): | 133 if not os.path.exists(path): |
134 raise ReplayNotFoundError(label, path) | 134 raise ReplayNotFoundError(label, path) |
135 | 135 |
136 def _OpenLogFile(self): | 136 def _OpenLogFile(self): |
137 log_dir = os.path.dirname(self.log_path) | 137 log_dir = os.path.dirname(self.log_path) |
138 if not os.path.exists(log_dir): | 138 if not os.path.exists(log_dir): |
139 os.makedirs(log_dir) | 139 os.makedirs(log_dir) |
140 return open(self.log_path, 'w') | 140 return open(self.log_path, 'w') |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 self.log_fh.close() | 209 self.log_fh.close() |
210 | 210 |
211 def __enter__(self): | 211 def __enter__(self): |
212 """Add support for with-statement.""" | 212 """Add support for with-statement.""" |
213 self.StartServer() | 213 self.StartServer() |
214 return self | 214 return self |
215 | 215 |
216 def __exit__(self, unused_exc_type, unused_exc_val, unused_exc_tb): | 216 def __exit__(self, unused_exc_type, unused_exc_val, unused_exc_tb): |
217 """Add support for with-statement.""" | 217 """Add support for with-statement.""" |
218 self.StopServer() | 218 self.StopServer() |
OLD | NEW |