Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion easybuild/tools/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import re
import signal
import shutil
import string
import subprocess
import sys
import tempfile
Expand Down Expand Up @@ -233,7 +234,6 @@ def to_cmd_str(cmd):
work_dir = os.getcwd()

cmd_str = to_cmd_str(cmd)
cmd_name = os.path.basename(cmd_str.split(' ')[0])

# auto-enable streaming of command output under --logtostdout/-l, unless it was disabled explicitely
if stream_output is None and build_option('logtostdout'):
Expand All @@ -244,6 +244,9 @@ def to_cmd_str(cmd):
if output_file:
toptmpdir = os.path.join(tempfile.gettempdir(), 'run-shell-cmd-output')
os.makedirs(toptmpdir, exist_ok=True)
# restrict the allowed characters in the name of the output_file
allowed_chars = string.ascii_letters + string.digits
cmd_name = ''.join([c for c in os.path.basename(cmd_str.split(' ')[0]) if c in allowed_chars])
tmpdir = tempfile.mkdtemp(dir=toptmpdir, prefix=f'{cmd_name}-')
cmd_out_fp = os.path.join(tmpdir, 'out.txt')
_log.info(f'run_cmd: Output of "{cmd_str}" will be logged to {cmd_out_fp}')
Expand Down