GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — simplecpp/testutils.py at master · cppcheck-opensource/simplecpp

Expand file tree

/

testutils.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
57 lines (49 loc) · 1.95 KB
/

testutils.py

Copy path

File metadata and controls

57 lines (49 loc) · 1.95 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import subprocess
import json
def __run_subprocess(args, env=None, cwd=None, timeout=None):
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, cwd=cwd)
try:
stdout, stderr = p.communicate(timeout=timeout)
return_code = p.returncode
p = None
except subprocess.TimeoutExpired:
import psutil
# terminate all the child processes
child_procs = psutil.Process(p.pid).children(recursive=True)
if len(child_procs) > 0:
for child in child_procs:
child.terminate()
try:
# call with timeout since it might be stuck
p.communicate(timeout=5)
p = None
except subprocess.TimeoutExpired:
pass
raise
finally:
if p:
# sending the signal to the process groups causes the parent Python process to terminate as well
#os.killpg(os.getpgid(p.pid), signal.SIGTERM) # Send the signal to all the process groups
p.terminate()
stdout, stderr = p.communicate()
p = None
stdout = stdout.decode(encoding='utf-8', errors='ignore').replace('\r\n', '\n')
stderr = stderr.decode(encoding='utf-8', errors='ignore').replace('\r\n', '\n')
return return_code, stdout, stderr
def simplecpp(args = [], cwd = None):
dir_path = os.path.dirname(os.path.realpath(__file__))
if 'SIMPLECPP_EXE_PATH' in os.environ:
simplecpp_path = os.environ['SIMPLECPP_EXE_PATH']
else:
simplecpp_path = os.path.join(dir_path, "simplecpp")
return __run_subprocess([simplecpp_path] + args, cwd = cwd)
def quoted_string(s):
return json.dumps(str(s))
def format_include_path_arg(include_path):
return f"-I{str(include_path)}"
def format_include(include, is_sys_header=False):
if is_sys_header:
return f"<{quoted_string(include)[1:-1]}>"
else:
return quoted_string(include)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.