diff options
Diffstat (limited to 'grc/gui/Executor.py')
-rw-r--r-- | grc/gui/Executor.py | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/grc/gui/Executor.py b/grc/gui/Executor.py index f91a341541..f5a75ab55b 100644 --- a/grc/gui/Executor.py +++ b/grc/gui/Executor.py @@ -15,15 +15,14 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -import gobject -import os -import threading -import shlex import subprocess -import sys -import re +import threading from distutils.spawn import find_executable +import gobject +import os + +from ..core.utils import shlex from ..core import Messages @@ -40,6 +39,7 @@ class ExecFlowGraphThread(threading.Thread): threading.Thread.__init__(self) self.page = flow_graph_page # store page and dont use main window calls in run + self.flow_graph = self.page.get_flow_graph() self.xterm_executable = xterm_executable self.update_callback = callback @@ -56,16 +56,9 @@ class ExecFlowGraphThread(threading.Thread): """ Execute this python flow graph. """ - run_command = self.page.get_flow_graph().get_option('run_command') generator = self.page.get_generator() - - try: - run_command = run_command.format( - python=shlex_quote(sys.executable), - filename=shlex_quote(generator.file_path)) - run_command_args = shlex.split(run_command) - except Exception as e: - raise ValueError("Can't parse run command {!r}: {0}".format(run_command, e)) + run_command = self.flow_graph.get_run_command(generator.file_path) + run_command_args = shlex.split(run_command) # When in no gui mode on linux, use a graphical terminal (looks nice) xterm_executable = find_executable(self.xterm_executable) @@ -101,21 +94,3 @@ class ExecFlowGraphThread(threading.Thread): Messages.send_end_exec(self.process.returncode) self.page.set_proc(None) self.update_callback() - - -########################################################### -# back-port from python3 -########################################################### -_find_unsafe = re.compile(r'[^\w@%+=:,./-]').search - - -def shlex_quote(s): - """Return a shell-escaped version of the string *s*.""" - if not s: - return "''" - if _find_unsafe(s) is None: - return s - - # use single quotes, and put single quotes into double quotes - # the string $'b is then quoted as '$'"'"'b' - return "'" + s.replace("'", "'\"'\"'") + "'" |