Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F8396512
utils.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1009 B
Subscribers
None
utils.py
View Options
# Copyright (C) 2022 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
from
pathlib
import
Path
from
typing
import
Dict
def
run_script
(
script
:
str
,
output_path
:
Path
)
->
None
:
import
os
import
subprocess
from
..config
import
check_config
conf
:
Dict
=
{}
# TODO: configurable
conf
=
check_config
(
conf
)
env
=
{
**
os
.
environ
.
copy
(),
"JAVA_TOOL_OPTIONS"
:
conf
[
"java_tool_options"
],
"CLASSPATH"
:
conf
[
"classpath"
],
}
output_path
.
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
tmp_output_path
=
Path
(
f
"{output_path}.tmp"
)
with
tmp_output_path
.
open
(
"wb"
)
as
tmp_output
:
subprocess
.
run
(
[
"bash"
,
"-c"
,
f
"{script.strip()}"
],
stdout
=
tmp_output
,
env
=
env
,
check
=
True
)
# Atomically write the output file
tmp_output_path
.
replace
(
output_path
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Jun 4 2025, 7:54 PM (13 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3293492
Attached To
rDGRPH Compressed graph representation
Event Timeline
Log In to Comment