OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Provides an interface to communicate with the device via the adb command. | 5 """Provides an interface to communicate with the device via the adb command. |
6 | 6 |
7 Assumes adb binary is currently on system path. | 7 Assumes adb binary is currently on system path. |
8 """ | 8 """ |
9 | 9 |
10 import collections | 10 import collections |
11 import datetime | 11 import datetime |
12 import logging | 12 import logging |
13 import os | 13 import os |
14 import re | 14 import re |
15 import shlex | 15 import shlex |
16 import subprocess | 16 import subprocess |
17 import sys | 17 import sys |
18 import tempfile | 18 import tempfile |
19 import time | 19 import time |
20 | 20 |
21 import cmd_helper | 21 import cmd_helper |
22 import constants | 22 import constants |
23 import io_stats_parser | 23 import io_stats_parser |
24 try: | 24 try: |
25 import pexpect | 25 import pexpect |
26 except: | 26 except: |
27 pexpect = None | 27 pexpect = None |
28 | 28 |
29 sys.path.append(os.path.join( | 29 sys.path.append(os.path.join( |
30 constants.CHROME_DIR, 'third_party', 'android_testrunner')) | 30 constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner')) |
31 import adb_interface | 31 import adb_interface |
32 import am_instrument_parser | 32 import am_instrument_parser |
33 import errors | 33 import errors |
34 | 34 |
35 | 35 |
36 # Pattern to search for the next whole line of pexpect output and capture it | 36 # Pattern to search for the next whole line of pexpect output and capture it |
37 # into a match group. We can't use ^ and $ for line start end with pexpect, | 37 # into a match group. We can't use ^ and $ for line start end with pexpect, |
38 # see http://www.noah.org/python/pexpect/#doc for explanation why. | 38 # see http://www.noah.org/python/pexpect/#doc for explanation why. |
39 PEXPECT_LINE_RE = re.compile('\n([^\r]*)\r') | 39 PEXPECT_LINE_RE = re.compile('\n([^\r]*)\r') |
40 | 40 |
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 """ | 1330 """ |
1331 def __init__(self, output): | 1331 def __init__(self, output): |
1332 self._output = output | 1332 self._output = output |
1333 | 1333 |
1334 def write(self, data): | 1334 def write(self, data): |
1335 data = data.replace('\r\r\n', '\n') | 1335 data = data.replace('\r\r\n', '\n') |
1336 self._output.write(data) | 1336 self._output.write(data) |
1337 | 1337 |
1338 def flush(self): | 1338 def flush(self): |
1339 self._output.flush() | 1339 self._output.flush() |
OLD | NEW |