Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: build/android/pylib/android_commands.py

Issue 19284009: Add option to output device status data in format for dashboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed frankf's reviews. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 re_device = re.compile('^([a-zA-Z0-9_:.-]+)\tdevice$', re.MULTILINE) 107 re_device = re.compile('^([a-zA-Z0-9_:.-]+)\tdevice$', re.MULTILINE)
108 devices = re_device.findall(cmd_helper.GetCmdOutput([constants.ADB_PATH, 108 devices = re_device.findall(cmd_helper.GetCmdOutput([constants.ADB_PATH,
109 'devices'])) 109 'devices']))
110 preferred_device = os.environ.get('ANDROID_SERIAL') 110 preferred_device = os.environ.get('ANDROID_SERIAL')
111 if preferred_device in devices: 111 if preferred_device in devices:
112 devices.remove(preferred_device) 112 devices.remove(preferred_device)
113 devices.insert(0, preferred_device) 113 devices.insert(0, preferred_device)
114 return devices 114 return devices
115 115
116 116
117 def GetAttachedOfflineDevices():
118 """Returns a list of attached, offline android devices.
119
120 Returns: List of devices with status 'offline'.
121 """
122 re_device = re.compile('^([a-zA-Z0-9_:.-]+)\toffline$', re.MULTILINE)
123 return re_device.findall(cmd_helper.GetCmdOutput([constants.ADB_PATH,
124 'devices']))
125
126
117 def IsDeviceAttached(device): 127 def IsDeviceAttached(device):
128 """Return true if the device is attached and online."""
118 return device in GetAttachedDevices() 129 return device in GetAttachedDevices()
119 130
120 131
121 def _GetFilesFromRecursiveLsOutput(path, ls_output, re_file, utc_offset=None): 132 def _GetFilesFromRecursiveLsOutput(path, ls_output, re_file, utc_offset=None):
122 """Gets a list of files from `ls` command output. 133 """Gets a list of files from `ls` command output.
123 134
124 Python's os.walk isn't used because it doesn't work over adb shell. 135 Python's os.walk isn't used because it doesn't work over adb shell.
125 136
126 Args: 137 Args:
127 path: The path to list. 138 path: The path to list.
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 """ 1379 """
1369 def __init__(self, output): 1380 def __init__(self, output):
1370 self._output = output 1381 self._output = output
1371 1382
1372 def write(self, data): 1383 def write(self, data):
1373 data = data.replace('\r\r\n', '\n') 1384 data = data.replace('\r\r\n', '\n')
1374 self._output.write(data) 1385 self._output.write(data)
1375 1386
1376 def flush(self): 1387 def flush(self):
1377 self._output.flush() 1388 self._output.flush()
OLDNEW
« build/android/device_status_check.py ('K') | « build/android/device_status_check.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698