From c93e3d6d83e9f050f1032e6c68e8c2a7e2d869c2 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Wed, 25 Nov 2015 11:19:08 +0000 Subject: [PATCH] android: add support to pull multiple files using wildcard expressions The ADB pull command allows only to pull a single file or a whole directory. This patch adds the required support to pull only a selection of files, from a target folder, which match a path specified using '*' and/or '?' wildcards. In this case we first get the list of files on the target, using the wildcard expansion support provided by the "ls" command, and than we pull each and every file returned from the previous command. This operation mode is available only if the 'dest' parameter is a valid host-side folder. Signed-off-by: Patrick Bellasi --- devlib/utils/android.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/devlib/utils/android.py b/devlib/utils/android.py index 17c8f3a..ad637fa 100644 --- a/devlib/utils/android.py +++ b/devlib/utils/android.py @@ -173,6 +173,15 @@ class AdbConnection(object): def pull(self, source, dest, timeout=None): if timeout is None: timeout = self.timeout + # Pull all files matching a wildcard expression + if os.path.isdir(dest) and \ + ('*' in source or '?' in source): + command = 'shell ls {}'.format(source) + output = adb_command(self.device, command, timeout=timeout) + for line in output.splitlines(): + command = 'pull {} {}'.format(line, dest) + adb_command(self.device, command, timeout=timeout) + return command = 'pull {} {}'.format(source, dest) return adb_command(self.device, command, timeout=timeout)