From 212bda92322a7d75028b30851f03f83e0c3b33ea Mon Sep 17 00:00:00 2001 From: chriskiehl Date: Mon, 12 Feb 2018 19:29:29 -0800 Subject: [PATCH] Make shell option in Popen configurable --- gooey/gui/containers/application.py | 3 ++- gooey/gui/processor.py | 7 ++++--- gooey/python_bindings/config_generator.py | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gooey/gui/containers/application.py b/gooey/gui/containers/application.py index 768cf50..8fc2dc7 100644 --- a/gooey/gui/containers/application.py +++ b/gooey/gui/containers/application.py @@ -46,7 +46,8 @@ class GooeyApplication(wx.Frame): self.clientRunner = ProcessController( self.buildSpec.get('progress_regex'), self.buildSpec.get('progress_expr'), - self.buildSpec.get('encoding') + self.buildSpec.get('encoding'), + self.buildSpec.get('requires_shell'), ) pub.subscribe(events.WINDOW_START, self.onStart) diff --git a/gooey/gui/processor.py b/gooey/gui/processor.py index 85ebfdf..4b7ef8a 100644 --- a/gooey/gui/processor.py +++ b/gooey/gui/processor.py @@ -13,12 +13,13 @@ from gooey.util.functional import unit, bind class ProcessController(object): - def __init__(self, progress_regex, progress_expr, encoding): + def __init__(self, progress_regex, progress_expr, encoding, shell=True): self._process = None self.progress_regex = progress_regex self.progress_expr = progress_expr self.encoding = encoding self.wasForcefullyStopped = False + self.shell_execution = shell def was_success(self): self._process.communicate() @@ -46,12 +47,12 @@ class ProcessController(object): self._process = subprocess.Popen( command.encode(sys.getfilesystemencoding()), bufsize=1, stdout=subprocess.PIPE, stdin=subprocess.PIPE, - stderr=subprocess.STDOUT, shell=True, env=env) + stderr=subprocess.STDOUT, shell=self.shell_execution, env=env) except: self._process = subprocess.Popen( command, bufsize=1, stdout=subprocess.PIPE, stdin=subprocess.PIPE, - stderr=subprocess.STDOUT, shell=True, env=env) + stderr=subprocess.STDOUT, shell=self.shell_execution, env=env) Pool(1).apply_async(self._forward_stdout, (self._process,)) def _forward_stdout(self, process): diff --git a/gooey/python_bindings/config_generator.py b/gooey/python_bindings/config_generator.py index d641d2c..b56d4e9 100644 --- a/gooey/python_bindings/config_generator.py +++ b/gooey/python_bindings/config_generator.py @@ -48,6 +48,9 @@ def create_from_parser(parser, source_path, **kwargs): 'poll_external_updates':kwargs.get('poll_external_updates', False), 'return_to_config': kwargs.get('return_to_config', False), + # debug + 'requires_shell': kwargs.get('requires_shell', True), + # Legacy/Backward compatibility interop 'use_legacy_titles': kwargs.get('use_legacy_titles', True), 'num_required_cols': kwargs.get('required_cols', 1),