Skip to content

Commit 1cc3b46

Browse files
committed
cppcheckdata.py: better handling when subprocess call fails
1 parent 176eefc commit 1cc3b46

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

addons/cppcheckdata.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,11 @@ 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+
if sys.platform == 'win32':
1395+
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
1396+
else:
1397+
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, preexec_fn=os.setsid)
1398+
comm = p.communicate()
1399+
if p.returncode == 0:
1400+
return comm[0].decode(encoding='utf-8', errors='ignore')
1401+
return comm[1].decode(encoding='utf-8', errors='ignore')

0 commit comments

Comments
 (0)