Browse Source

Fixing Unicode error during PHP repo adding

bugfixes
gau1991 10 years ago
parent
commit
3fa09f24ce
  1. 17
      ee/core/shellexec.py

17
ee/core/shellexec.py

@ -1,9 +1,9 @@
"""EasyEngine shell executaion functions.""" """EasyEngine shell executaion functions."""
from subprocess import Popen
from ee.core.logging import Log from ee.core.logging import Log
import os import os
import sys import sys
import subprocess import subprocess
import shlex
class EEShellExec(): class EEShellExec():
@ -16,11 +16,20 @@ class EEShellExec():
try: try:
if log: if log:
Log.debug(self, "Running command: {0}".format(command)) Log.debug(self, "Running command: {0}".format(command))
retcode = subprocess.getstatusoutput(command) args = shlex.split(command)
if retcode[0] == 0: with subprocess.Popen(args, stdout=subprocess.PIPE,
stderr=subprocess.PIPE) as proc:
(cmd_stdout_bytes, cmd_stderr_bytes) = proc.communicate()
(cmd_stdout, cmd_stderr) = (cmd_stdout_bytes.decode('utf-8',
"replace"),
cmd_stderr_bytes.decode('utf-8',
"replace"))
if proc.returncode == 0:
return True return True
else: else:
Log.debug(self, retcode[1]) Log.debug(self, "Command Output: {0}, Command Error: {1}"
.format(cmd_stdout, cmd_stderr))
return False return False
except OSError as e: except OSError as e:
if errormsg: if errormsg:

Loading…
Cancel
Save