Skip to content

Commit

Permalink
Update run.py from pymodules
Browse files Browse the repository at this point in the history
  • Loading branch information
corpnewt committed Dec 7, 2018
1 parent dfb5964 commit d4a2fe0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Empty file modified ForceRGB.command 100644 → 100755
Empty file.
9 changes: 7 additions & 2 deletions Scripts/run.py 100644 → 100755
Expand Up @@ -78,6 +78,12 @@ def _stream_output(self, comm, shell = False):
return (output, error, p.returncode)
return ("", "Command not found!", 1)

def _decode(self, value):
# Helper method to only decode if bytes type
if sys.version_info >= (3,0) and isinstance(value, bytes):
return value.decode("utf-8","ignore")
return value

def _run_command(self, comm, shell = False):
c = None
try:
Expand All @@ -87,11 +93,10 @@ def _run_command(self, comm, shell = False):
comm = shlex.split(comm)
p = subprocess.Popen(comm, shell=shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
c = p.communicate()
return (c[0].decode("utf-8", "ignore"), c[1].decode("utf-8", "ignore"), p.returncode)
except:
if c == None:
return ("", "Command not found!", 1)
return (c[0].decode("utf-8", "ignore"), c[1].decode("utf-8", "ignore"), p.returncode)
return (self._decode(c[0]), self._decode(c[1]), p.returncode)

def run(self, command_list, leave_on_fail = False):
# Command list should be an array of dicts
Expand Down

0 comments on commit d4a2fe0

Please sign in to comment.