diff --git a/class/core/mw.py b/class/core/mw.py index 6a9d6f392..47a0c9cdb 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -34,7 +34,14 @@ def execShell(cmdstring, cwd=None, timeout=None, shell=True): if end_time <= datetime.datetime.now(): raise Exception("Timeout:%s" % cmdstring) - return sub.communicate() + data = sub.communicate() + # python3 fix 返回byte数据 + if isinstance(data[0], bytes): + t1 = str(data[0], encoding='utf-8') + + if isinstance(data[1], bytes): + t2 = str(data[1], encoding='utf-8') + return (t1, t2) def getRunDir(): diff --git a/task.py b/task.py index 146791f65..e0d296e03 100755 --- a/task.py +++ b/task.py @@ -80,8 +80,15 @@ def execShell(cmdstring, cwd=None, timeout=None, shell=True): while sub.poll() is None: time.sleep(0.1) - return sub.returncode - except: + data = sub.communicate() + # python3 fix 返回byte数据 + if isinstance(data[0], bytes): + t1 = str(data[0], encoding='utf-8') + + if isinstance(data[1], bytes): + t2 = str(data[1], encoding='utf-8') + return (t1, t2) + except Exception as e: return None