Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7451262
D8931.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D8931.id.diff
View Options
diff --git a/swh/graph/luigi/utils.py b/swh/graph/luigi/utils.py
--- a/swh/graph/luigi/utils.py
+++ b/swh/graph/luigi/utils.py
@@ -6,30 +6,60 @@
from pathlib import Path
from typing import Dict
+LOGBACK_CONF = b"""\
+<configuration>
+ <appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
+ <target>System.err</target>
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="debug">
+ <appender-ref ref="STDERR" />
+ </root>
+</configuration>
+"""
+"""Overrides the default config, to log to stderr instead of stdout"""
+
def run_script(script: str, output_path: Path) -> None:
import os
import subprocess
+ import tempfile
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
- )
+ conf = check_config(conf)
+
+ with tempfile.NamedTemporaryFile(prefix="logback_", suffix=".xml") as logback_conf:
+ logback_conf.write(LOGBACK_CONF)
+ logback_conf.flush()
+
+ java_tool_options = [
+ f"-Dlogback.configurationFile={logback_conf.name}",
+ conf["java_tool_options"],
+ ]
+
+ env = {
+ **os.environ.copy(),
+ "JAVA_TOOL_OPTIONS": " ".join(java_tool_options),
+ "CLASSPATH": conf["classpath"],
+ }
+
+ 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/plain
Expires
Wed, Apr 16, 10:18 AM (5 d, 17 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3214926
Attached To
D8931: Prevent incorrect warning from being printed to output files
Event Timeline
Log In to Comment