Browse Source

Make shell option in Popen configurable

pull/473/head
chriskiehl 6 years ago
committed by Chris
parent
commit
7843cbcd9c
3 changed files with 7 additions and 5 deletions
  1. 3
      gooey/gui/containers/application.py
  2. 8
      gooey/gui/processor.py
  3. 1
      gooey/python_bindings/config_generator.py

3
gooey/gui/containers/application.py

@ -47,7 +47,8 @@ class GooeyApplication(wx.Frame):
self.clientRunner = ProcessController( self.clientRunner = ProcessController(
self.buildSpec.get('progress_regex'), self.buildSpec.get('progress_regex'),
self.buildSpec.get('progress_expr'), 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) pub.subscribe(events.WINDOW_START, self.onStart)

8
gooey/gui/processor.py

@ -13,12 +13,13 @@ from gooey.util.functional import unit, bind
class ProcessController(object): 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._process = None
self.progress_regex = progress_regex self.progress_regex = progress_regex
self.progress_expr = progress_expr self.progress_expr = progress_expr
self.encoding = encoding self.encoding = encoding
self.wasForcefullyStopped = False self.wasForcefullyStopped = False
self.shell_execution = shell
def was_success(self): def was_success(self):
self._process.communicate() self._process.communicate()
@ -46,16 +47,15 @@ class ProcessController(object):
self._process = subprocess.Popen( self._process = subprocess.Popen(
command.encode(sys.getfilesystemencoding()), command.encode(sys.getfilesystemencoding()),
bufsize=1, stdout=subprocess.PIPE, stdin=subprocess.PIPE, 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: except:
self._process = subprocess.Popen( self._process = subprocess.Popen(
command, command,
bufsize=1, stdout=subprocess.PIPE, stdin=subprocess.PIPE, bufsize=1, stdout=subprocess.PIPE, stdin=subprocess.PIPE,
stderr=subprocess.STDOUT, shell=True, env=env)
stderr = subprocess.STDOUT, shell = self.shell_execution, env=env)
t = Thread(target=self._forward_stdout, args=(self._process,)) t = Thread(target=self._forward_stdout, args=(self._process,))
t.start() t.start()
def _forward_stdout(self, process): def _forward_stdout(self, process):
''' '''

1
gooey/python_bindings/config_generator.py

@ -48,6 +48,7 @@ def create_from_parser(parser, source_path, **kwargs):
'poll_external_updates':kwargs.get('poll_external_updates', False), 'poll_external_updates':kwargs.get('poll_external_updates', False),
'return_to_config': kwargs.get('return_to_config', False), 'return_to_config': kwargs.get('return_to_config', False),
'show_restart_button': kwargs.get('show_restart_button', True), 'show_restart_button': kwargs.get('show_restart_button', True),
'requires_shell': kwargs.get('requires_shell', True),
# Legacy/Backward compatibility interop # Legacy/Backward compatibility interop
'use_legacy_titles': kwargs.get('use_legacy_titles', True), 'use_legacy_titles': kwargs.get('use_legacy_titles', True),

Loading…
Cancel
Save