Skip to content

Commit ef33ff6

Browse files
committed
cppcheckdata.py: fix cmd_output() function, handle errors better
1 parent dbb12cb commit ef33ff6

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

addons/cppcheckdata.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,10 @@ def get_path_premium_addon():
13911391

13921392

13931393
def cmd_output(cmd):
1394-
try:
1395-
return subprocess.check_output(cmd).strip().decode('ascii')
1396-
except subprocess.CalledProcessError as e:
1397-
return e.output
1394+
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
1395+
comm = p.communicate()
1396+
out = comm[0]
1397+
if p.returncode == 1 and len(comm[1]) > 2:
1398+
out = comm[1]
1399+
return out.decode(encoding='utf-8', errors='ignore')
1400+

0 commit comments

Comments
 (0)