| 6 | |
| 7 | # TODO: detect missing file |
| 8 | def run(cppcheck_path, options, elapsed_time=None): |
| 9 | timeout = None |
| 10 | if elapsed_time: |
| 11 | timeout = elapsed_time * 2 |
| 12 | cmd = options.split() |
| 13 | cmd.insert(0, cppcheck_path) |
| 14 | print('running {}'.format(cppcheck_path)) |
| 15 | with subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) as p: |
| 16 | try: |
| 17 | p.communicate(timeout=timeout) |
| 18 | if p.returncode != 0: |
| 19 | print('error') |
| 20 | return None |
| 21 | print('done') |
| 22 | except subprocess.TimeoutExpired: |
| 23 | print('timeout') |
| 24 | p.kill() |
| 25 | p.communicate() |
| 26 | return False |
| 27 | |
| 28 | return True |
| 29 | |
| 30 | |
| 31 | # TODO: check arguments |