cppcheckdata.py: fix cmd_output() function, handle errors better

This commit is contained in:
Daniel Marjamäki 2022-06-16 14:07:14 +02:00
parent 61f846073d
commit b44a38bf7f
1 changed files with 7 additions and 4 deletions

View File

@ -1391,7 +1391,10 @@ 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
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
comm = p.communicate()
out = comm[0]
if p.returncode == 1 and len(comm[1]) > 2:
out = comm[1]
return out.decode(encoding='utf-8', errors='ignore')