From b587049eb99e964aa9337e307333d5929954a979 Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Fri, 27 Jan 2017 19:33:43 +0000 Subject: [PATCH] LocalConnection: Support glob patterns in pull --- devlib/host.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/devlib/host.py b/devlib/host.py index d830a5e..510de44 100644 --- a/devlib/host.py +++ b/devlib/host.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from glob import iglob import os import shutil import subprocess @@ -41,7 +42,12 @@ class LocalConnection(object): def pull(self, source, dest, timeout=None, as_root=False): # pylint: disable=unused-argument self.logger.debug('cp {} {}'.format(source, dest)) - shutil.copy(source, dest) + if ('*' in source or '?' in source) and os.path.isdir(dest): + # Pull all files matching a wildcard expression + for each_source in iglob(source): + shutil.copy(each_source, dest) + else: + shutil.copy(source, dest) def execute(self, command, timeout=None, check_exit_code=True, as_root=False): self.logger.debug(command)