From e8f5a13f3b4d0f57819db18bb6cde086b92eb6c8 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 1 Mar 2019 11:22:50 +0100 Subject: [PATCH] Fix LocalShellRunner All the `cmd` coming from the plugins are strings, so if cmd is a string we use `shell=True`, brings this on par with the Remote Shell plugins (which consume strings). Should fix https://github.com/galaxyproject/galaxy/issues/7269. --- lib/galaxy/jobs/runners/util/cli/shell/local.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/jobs/runners/util/cli/shell/local.py b/lib/galaxy/jobs/runners/util/cli/shell/local.py index 078ca06afa9..2e2f86c17f5 100644 --- a/lib/galaxy/jobs/runners/util/cli/shell/local.py +++ b/lib/galaxy/jobs/runners/util/cli/shell/local.py @@ -6,6 +6,8 @@ from subprocess import ( from tempfile import TemporaryFile from time import sleep +import six + from ..shell import BaseShellExec from ....util import ( Bunch, @@ -37,14 +39,17 @@ class LocalShell(BaseShellExec): True >>> exec_result.returncode == TIMEOUT_RETURN_CODE True + >>> shell.execute('echo hi').stdout == "hi\\n" + True """ def __init__(self, **kwds): pass def execute(self, cmd, persist=False, timeout=DEFAULT_TIMEOUT, timeout_check_interval=DEFAULT_TIMEOUT_CHECK_INTERVAL, **kwds): + is_cmd_string = isinstance(cmd, six.string_types) outf = TemporaryFile() - p = Popen(cmd, stdin=None, stdout=outf, stderr=PIPE) + p = Popen(cmd, stdin=None, stdout=outf, stderr=PIPE, shell=is_cmd_string) # poll until timeout for i in range(int(timeout / timeout_check_interval)):