OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # pylint: disable=unused-argument | 5 # pylint: disable=unused-argument |
6 | 6 |
7 import errno | 7 import errno |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 self._output_file = output_file | 45 self._output_file = output_file |
46 self._record_file = None | 46 self._record_file = None |
47 self._record_file_lock = threading.Lock() | 47 self._record_file_lock = threading.Lock() |
48 self._record_thread = None | 48 self._record_thread = None |
49 self._stop_recording_event = threading.Event() | 49 self._stop_recording_event = threading.Event() |
50 | 50 |
51 @property | 51 @property |
52 def output_file(self): | 52 def output_file(self): |
53 return self._output_file | 53 return self._output_file |
54 | 54 |
| 55 @property |
| 56 def get_device_serial(self): |
| 57 return self._adb.GetDeviceSerial() |
| 58 |
55 @decorators.WithTimeoutAndRetriesDefaults(10, 0) | 59 @decorators.WithTimeoutAndRetriesDefaults(10, 0) |
56 def WaitFor(self, success_regex, failure_regex=None, timeout=None, | 60 def WaitFor(self, success_regex, failure_regex=None, timeout=None, |
57 retries=None): | 61 retries=None): |
58 """Wait for a matching logcat line or until a timeout occurs. | 62 """Wait for a matching logcat line or until a timeout occurs. |
59 | 63 |
60 This will attempt to match lines in the logcat against both |success_regex| | 64 This will attempt to match lines in the logcat against both |success_regex| |
61 and |failure_regex| (if provided). Note that this calls re.search on each | 65 and |failure_regex| (if provided). Note that this calls re.search on each |
62 logcat line, not re.match, so the provided regular expressions don't have | 66 logcat line, not re.match, so the provided regular expressions don't have |
63 to match an entire line. | 67 to match an entire line. |
64 | 68 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 with self._record_file_lock: | 237 with self._record_file_lock: |
234 if self._record_file: | 238 if self._record_file: |
235 logging.warning( | 239 logging.warning( |
236 'Need to call |Close| on the logcat monitor when done!') | 240 'Need to call |Close| on the logcat monitor when done!') |
237 self._record_file.close() | 241 self._record_file.close() |
238 | 242 |
239 | 243 |
240 class LogcatMonitorCommandError(device_errors.CommandFailedError): | 244 class LogcatMonitorCommandError(device_errors.CommandFailedError): |
241 """Exception for errors with logcat monitor commands.""" | 245 """Exception for errors with logcat monitor commands.""" |
242 pass | 246 pass |
OLD | NEW |