Skip to content

Commit 7ea1ad3

Browse files
authored
Merge pull request #7 from makermelissa/master
Suppress errors from utf-8 decoding and add copy
2 parents 70224b6 + 281674d commit 7ea1ad3

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

adafruit_shell.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def run_command(self, cmd, suppress_message=False, return_output=False):
7272
if len(output) == 0 and proc.poll() is not None:
7373
break
7474
if output:
75-
decoded_output = output.decode("utf-8").strip()
75+
decoded_output = output.decode("utf-8", errors="ignore").strip()
7676
if not suppress_message:
7777
self.info(decoded_output)
7878
full_output += decoded_output
@@ -84,7 +84,7 @@ def run_command(self, cmd, suppress_message=False, return_output=False):
8484

8585
err = proc.stderr.read()
8686
if not suppress_message:
87-
self.error(err.decode("utf-8"))
87+
self.error(err.decode("utf-8", errors="ignore"))
8888
if return_output:
8989
return full_output
9090
return False
@@ -341,6 +341,18 @@ def move(self, source, destination):
341341
if os.path.exists(source):
342342
shutil.move(source, destination)
343343

344+
def copy(self, source, destination):
345+
"""
346+
Move a file or directory from source to destination
347+
"""
348+
source = self.path(source)
349+
destination = self.path(destination)
350+
if os.path.exists(source):
351+
if os.path.isdir(source):
352+
shutil.copytree(source, destination)
353+
else:
354+
shutil.copyfile(source, destination)
355+
344356
def remove(self, location):
345357
"""
346358
Remove a file or directory if it exists

0 commit comments

Comments
 (0)