FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
simplecpp/testutils.py at 1.9.0 · cppcheck-opensource/simplecpp · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
cppcheck-opensource
/
simplecpp
Public
Notifications
You must be signed in to change notification settings
Fork
104
Star
263
Code
Issues
83
Pull requests
32
Actions
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
simplecpp
/
testutils.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
57 lines (49 loc) · 1.95 KB
Breadcrumbs
simplecpp
/
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
)
Back
|
FazBrowse Home
|
New Git URL