MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / __run_command

Function __run_command

tools/donate_cpu_lib.py:403–436  ·  view source on GitHub ↗
(cmd, print_cmd=True)

Source from the content-addressed store, hash-verified

401
402
403def __run_command(cmd, print_cmd=True):
404 if print_cmd:
405 print(cmd)
406 time_start = time.time()
407 if sys.platform == 'win32':
408 p = subprocess.Popen(shlex.split(cmd, comments=False, posix=False), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, errors='surrogateescape')
409 else:
410 p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, errors='surrogateescape', preexec_fn=os.setsid)
411 try:
412 stdout, stderr = p.communicate(timeout=CPPCHECK_TIMEOUT)
413 return_code = p.returncode
414 p = None
415 except subprocess.TimeoutExpired:
416 import psutil
417 return_code = RETURN_CODE_TIMEOUT
418 # terminate all the child processes so we get messages about which files were hanging
419 child_procs = psutil.Process(p.pid).children(recursive=True)
420 if len(child_procs) > 0:
421 for child in child_procs:
422 child.terminate()
423 try:
424 # call with timeout since it might get stuck e.g. gcc-arm-none-eabi
425 stdout, stderr = p.communicate(timeout=5)
426 p = None
427 except subprocess.TimeoutExpired:
428 pass
429 finally:
430 if p:
431 os.killpg(os.getpgid(p.pid), signal.SIGTERM) # Send the signal to all the process groups
432 stdout, stderr = p.communicate()
433 p = None
434 time_stop = time.time()
435 elapsed_time = time_stop - time_start
436 return return_code, stdout, stderr, elapsed_time
437
438
439def scan_package(cppcheck_path, source_path, libraries, capture_callstack=True, enable='style,information', debug_warnings=True, check_level=None, extra_args=None):

Callers 2

scan_packageFunction · 0.85
get_compiler_versionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected