From f2a88fd1dca6c2f0f021e40ff7ab468ebc81434e Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Thu, 20 Sep 2018 14:49:00 +0100 Subject: [PATCH] host: Allow `pull` method to deal with directories Check to see if the the source path is a directory before attempting to pull from the host. Use the copy_tree implementation from `distutils` instead of `shutil` to allow copying into an existing directory. --- devlib/host.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/devlib/host.py b/devlib/host.py index f68173c..70461fa 100644 --- a/devlib/host.py +++ b/devlib/host.py @@ -18,6 +18,7 @@ import signal import shutil import subprocess import logging +from distutils.dir_util import copy_tree from getpass import getpass from devlib.exception import TargetTransientError, TargetStableError @@ -55,7 +56,11 @@ class LocalConnection(object): for each_source in iglob(source): shutil.copy(each_source, dest) else: - shutil.copy(source, dest) + if os.path.isdir(source): + # Use distutils to allow copying into an existing directory structure. + copy_tree(source, dest) + else: + shutil.copy(source, dest) # pylint: disable=unused-argument def execute(self, command, timeout=None, check_exit_code=True,