Skip to content

Commit 931b6f1

Browse files
committed
This changes the debugging line that logs the command to be executed
into something that can be copied and pasted into a shell.
1 parent 4b769ba commit 931b6f1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/psij/executors/local.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""This module contains the local :class:`~psij.JobExecutor`."""
22
import logging
33
import os
4+
import shlex
45
import signal
56
import subprocess
67
import threading
@@ -20,6 +21,15 @@
2021
logger = logging.getLogger(__name__)
2122

2223

24+
def _format_shell_cmd(args: List[str]) -> str:
25+
"""Formats an argument list in a way that allows it to be pasted in a shell."""
26+
cmd = ''
27+
for arg in args:
28+
cmd += shlex.quote(arg)
29+
cmd += ' '
30+
return cmd
31+
32+
2333
def _handle_sigchld(signum: int, frame: Optional[FrameType]) -> None:
2434
_ProcessReaper.get_instance()._handle_sigchld()
2535

@@ -279,7 +289,8 @@ def submit(self, job: Job) -> None:
279289
with job._status_cv:
280290
if job.status.state == JobState.CANCELED:
281291
raise SubmitException('Job canceled')
282-
logger.debug('Running %s, out=%s, err=%s', args, spec.stdout_path, spec.stderr_path)
292+
if logger.isEnabledFor(logging.DEBUG):
293+
logger.debug('Running %s', _format_shell_cmd(args))
283294
nodefile = self._generate_nodefile(job, p)
284295
env = _get_env(spec, nodefile)
285296
p.process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,

0 commit comments

Comments
 (0)