Python 3 compatibility.
Test: ndk/run_tests.py Bug: None Change-Id: Id0d2d8024adec880c1a41b524704df1641cda065
This commit is contained in:
@@ -51,7 +51,8 @@ def get_devices(adb_path='adb'):
|
||||
with open(os.devnull, 'wb') as devnull:
|
||||
subprocess.check_call([adb_path, 'start-server'], stdout=devnull,
|
||||
stderr=devnull)
|
||||
out = split_lines(subprocess.check_output([adb_path, 'devices']))
|
||||
out = split_lines(
|
||||
subprocess.check_output([adb_path, 'devices']).decode('utf-8'))
|
||||
|
||||
# The first line of `adb devices` just says "List of attached devices", so
|
||||
# skip that.
|
||||
@@ -118,7 +119,7 @@ def _get_device_by_type(flag, adb_path):
|
||||
stderr=devnull)
|
||||
try:
|
||||
serial = subprocess.check_output(
|
||||
[adb_path, flag, 'get-serialno']).strip()
|
||||
[adb_path, flag, 'get-serialno']).decode('utf-8').strip()
|
||||
except subprocess.CalledProcessError:
|
||||
raise RuntimeError('adb unexpectedly returned nonzero')
|
||||
if serial == 'unknown':
|
||||
@@ -233,6 +234,7 @@ def version(adb_path=None):
|
||||
|
||||
adb_path = adb_path if adb_path is not None else ['adb']
|
||||
version_output = subprocess.check_output(adb_path + ['version'])
|
||||
version_output = version_output.decode('utf-8')
|
||||
pattern = r'^Android Debug Bridge version 1.0.(\d+)$'
|
||||
result = re.match(pattern, version_output.splitlines()[0])
|
||||
if not result:
|
||||
@@ -273,8 +275,8 @@ class AndroidDevice(object):
|
||||
@property
|
||||
def linesep(self):
|
||||
if self._linesep is None:
|
||||
self._linesep = subprocess.check_output(self.adb_cmd +
|
||||
['shell', 'echo'])
|
||||
self._linesep = subprocess.check_output(
|
||||
self.adb_cmd + ['shell', 'echo']).decode('utf-8')
|
||||
return self._linesep
|
||||
|
||||
@property
|
||||
@@ -326,7 +328,7 @@ class AndroidDevice(object):
|
||||
def _simple_call(self, cmd):
|
||||
logging.info(' '.join(self.adb_cmd + cmd))
|
||||
return _subprocess_check_output(
|
||||
self.adb_cmd + cmd, stderr=subprocess.STDOUT)
|
||||
self.adb_cmd + cmd, stderr=subprocess.STDOUT).decode('utf-8')
|
||||
|
||||
def shell(self, cmd):
|
||||
"""Calls `adb shell`
|
||||
@@ -361,6 +363,8 @@ class AndroidDevice(object):
|
||||
p = _subprocess_Popen(
|
||||
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = p.communicate()
|
||||
stdout = stdout.decode('utf-8')
|
||||
stderr = stderr.decode('utf-8')
|
||||
if self.has_shell_protocol():
|
||||
exit_code = p.returncode
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user