FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql-action/python-setup/extractor_version.py at main · DevOpsKev/codeql-action · GitHub
DevOpsKev
/
codeql-action
Public
forked from
github/codeql-action
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql-action
/
python-setup
/
extractor_version.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
52 lines (39 loc) · 1.46 KB
Breadcrumbs
codeql-action
/
python-setup
/
extractor_version.py
Copy path
File metadata and controls
executable file
·
52 lines (39 loc) · 1.46 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
#!/usr/bin/env python
# A quick hack to get package installation for Code Scanning to work,
# since it needs to know which version we're going to analyze the project as.
# This file needs to be placed next to `python_tracer.py`, so in
# `<codeql-path>/python/tools/`
from
__future__
import
print_function
,
division
import
os
import
sys
from
contextlib
import
contextmanager
@
contextmanager
def
suppress_stdout_stderr
():
# taken from
# https://thesmithfam.org/blog/2012/10/25/temporarily-suppress-console-output-in-python/
with
open
(
os
.
devnull
,
"w"
)
as
devnull
:
old_stdout
=
sys
.
stdout
old_stderr
=
sys
.
stderr
sys
.
stdout
=
devnull
sys
.
stderr
=
devnull
try
:
yield
finally
:
sys
.
stdout
=
old_stdout
sys
.
stderr
=
old_stderr
def
get_extractor_version
(
codeql_base_dir
:
str
,
quiet
:
bool
=
True
)
->
int
:
extractor_dir
=
os
.
path
.
join
(
codeql_base_dir
,
'python'
,
'tools'
)
sys
.
path
=
[
extractor_dir
]
+
sys
.
path
from
python_tracer
import
getzipfilename
zippath
=
os
.
path
.
join
(
extractor_dir
,
getzipfilename
())
sys
.
path
=
[
zippath
]
+
sys
.
path
import
buildtools
.
discover
if
quiet
:
with
suppress_stdout_stderr
():
return
buildtools
.
discover
.
get_version
()
else
:
return
buildtools
.
discover
.
get_version
()
if
__name__
==
"__main__"
:
codeql_base_dir
=
sys
.
argv
[
1
]
version
=
get_extractor_version
(
codeql_base_dir
)
print
(
'{!r}'
.
format
(
version
))
Back
|
FazBrowse Home
|
New Git URL