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

Unified Diff: build/android/pylib/device/adb_wrapper.py

Issue 783543003: Update from https://crrev.com/306901 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/findbugs_filter/findbugs_exclude.xml ('k') | build/android/pylib/device/adb_wrapper_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/device/adb_wrapper.py
diff --git a/build/android/pylib/device/adb_wrapper.py b/build/android/pylib/device/adb_wrapper.py
index 4981f28df033f82966c76ea6ceb8679bcb05430b..e73d66c9a7c8efe0dbe0c445e7cf61b893ae1591 100644
--- a/build/android/pylib/device/adb_wrapper.py
+++ b/build/android/pylib/device/adb_wrapper.py
@@ -8,6 +8,7 @@ This is a thin wrapper around the adb interface. Any additional complexity
should be delegated to a higher level (ex. DeviceUtils).
"""
+import collections
import errno
import logging
import os
@@ -36,6 +37,10 @@ def _VerifyLocalFileExists(path):
raise IOError(errno.ENOENT, os.strerror(errno.ENOENT), path)
+DeviceStat = collections.namedtuple('DeviceStat',
+ ['st_mode', 'st_size', 'st_time'])
+
+
class AdbWrapper(object):
"""A wrapper around a local Android Debug Bridge executable."""
@@ -200,6 +205,38 @@ class AdbWrapper(object):
args, output, status, self._device_serial)
return output
+ def Ls(self, path, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES):
+ """List the contents of a directory on the device.
+
+ Args:
+ path: Path on the device filesystem.
+ timeout: (optional) Timeout per try in seconds.
+ retries: (optional) Number of retries to attempt.
+
+ Returns:
+ A list of pairs (filename, stat) for each file found in the directory,
+ where the stat object has the properties: st_mode, st_size, and st_time.
+
+ Raises:
+ AdbCommandFailedError if |path| does not specify a valid and accessible
+ directory in the device.
+ """
+ def ParseLine(line):
+ cols = line.split(None, 3)
+ filename = cols.pop()
+ stat = DeviceStat(*[int(num, base=16) for num in cols])
+ return (filename, stat)
+
+ cmd = ['ls', path]
+ lines = self._RunDeviceAdbCmd(
+ cmd, timeout=timeout, retries=retries).splitlines()
+ if lines:
+ return [ParseLine(line) for line in lines]
+ else:
+ raise device_errors.AdbCommandFailedError(
+ cmd, 'path does not specify an accessible directory in the device',
+ device_serial=self._device_serial)
+
def Logcat(self, filter_spec=None, timeout=_DEFAULT_TIMEOUT,
retries=_DEFAULT_RETRIES):
"""Get the logcat output.
« no previous file with comments | « build/android/findbugs_filter/findbugs_exclude.xml ('k') | build/android/pylib/device/adb_wrapper_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698