12345678910111213141516171819202122 |
- import subprocess
- from V1.PrintLog import printlog
- def exeCommonCmd(cmd, cd=None):
- try:
- s = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=cd,encoding='utf-8')
- std_output, error_output = s.communicate()
- ret = s.returncode
- if ret:
- printlog("cmd: %s \nexec Fail!" % cmd)
- else:
- printlog("cmd: %s \nexec Success!" % cmd)
- printlog(std_output)
- printlog(error_output)
- except Exception as e:
- print(e)
- return 1, e
- return ret, std_output
|