cppcheckdata.py: better handling when subprocess call fails

This commit is contained in:
Daniel Marjamäki 2022-06-15 17:13:14 +02:00
parent 176eefcbf3
commit 1cc3b46d32
1 changed files with 8 additions and 4 deletions

View File

@ -1391,7 +1391,11 @@ def get_path_premium_addon():
def cmd_output(cmd):
try:
return subprocess.check_output(cmd).strip().decode('ascii')
except subprocess.CalledProcessError as e:
return e.output
if sys.platform == 'win32':
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, preexec_fn=os.setsid)
comm = p.communicate()
if p.returncode == 0:
return comm[0].decode(encoding='utf-8', errors='ignore')
return comm[1].decode(encoding='utf-8', errors='ignore')