Merge pull request #7 from makermelissa/master
Suppress errors from utf-8 decoding and add copy
This commit is contained in:
commit
7ea1ad3312
1 changed files with 14 additions and 2 deletions
|
|
@ -72,7 +72,7 @@ class Shell:
|
|||
if len(output) == 0 and proc.poll() is not None:
|
||||
break
|
||||
if output:
|
||||
decoded_output = output.decode("utf-8").strip()
|
||||
decoded_output = output.decode("utf-8", errors="ignore").strip()
|
||||
if not suppress_message:
|
||||
self.info(decoded_output)
|
||||
full_output += decoded_output
|
||||
|
|
@ -84,7 +84,7 @@ class Shell:
|
|||
|
||||
err = proc.stderr.read()
|
||||
if not suppress_message:
|
||||
self.error(err.decode("utf-8"))
|
||||
self.error(err.decode("utf-8", errors="ignore"))
|
||||
if return_output:
|
||||
return full_output
|
||||
return False
|
||||
|
|
@ -341,6 +341,18 @@ class Shell:
|
|||
if os.path.exists(source):
|
||||
shutil.move(source, destination)
|
||||
|
||||
def copy(self, source, destination):
|
||||
"""
|
||||
Move a file or directory from source to destination
|
||||
"""
|
||||
source = self.path(source)
|
||||
destination = self.path(destination)
|
||||
if os.path.exists(source):
|
||||
if os.path.isdir(source):
|
||||
shutil.copytree(source, destination)
|
||||
else:
|
||||
shutil.copyfile(source, destination)
|
||||
|
||||
def remove(self, location):
|
||||
"""
|
||||
Remove a file or directory if it exists
|
||||
|
|
|
|||
Loading…
Reference in a new issue