From 4761d342482feb918735073c8a048e2b61653f8a Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 26 Jan 2021 11:00:35 -0800 Subject: [PATCH 1/2] Fix copy issue when destination is a directory --- adafruit_shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_shell.py b/adafruit_shell.py index 34b6f05..ba85f94 100644 --- a/adafruit_shell.py +++ b/adafruit_shell.py @@ -351,7 +351,7 @@ def copy(self, source, destination): if os.path.isdir(source): shutil.copytree(source, destination) else: - shutil.copyfile(source, destination) + shutil.copy(source, destination) def remove(self, location): """ From a55924139ba29a7f3ecf7807a382ae3ab61325fd Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 26 Jan 2021 11:50:06 -0800 Subject: [PATCH 2/2] Fix issue when files already exist --- adafruit_shell.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/adafruit_shell.py b/adafruit_shell.py index ba85f94..49cadc2 100644 --- a/adafruit_shell.py +++ b/adafruit_shell.py @@ -339,6 +339,8 @@ def move(self, source, destination): source = self.path(source) destination = self.path(destination) if os.path.exists(source): + if not os.path.isdir(source) and os.path.isdir(destination): + destination += os.sep + os.path.basename(source) shutil.move(source, destination) def copy(self, source, destination): @@ -351,6 +353,8 @@ def copy(self, source, destination): if os.path.isdir(source): shutil.copytree(source, destination) else: + if os.path.isdir(destination): + destination += os.sep + os.path.basename(source) shutil.copy(source, destination) def remove(self, location):