diff options
Diffstat (limited to 'grc/python/Generator.py')
-rw-r--r-- | grc/python/Generator.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/grc/python/Generator.py b/grc/python/Generator.py index f807b59ad1..d60befe3fa 100644 --- a/grc/python/Generator.py +++ b/grc/python/Generator.py @@ -21,6 +21,8 @@ import os import sys import subprocess import tempfile +import shlex +import codecs from distutils.spawn import find_executable from Cheetah.Template import Template @@ -106,7 +108,7 @@ class TopBlockGenerator(object): "This is usually undesired. Consider " "removing the throttle block.") # generate - with open(self.get_file_path(), 'w') as fp: + with codecs.open(self.get_file_path(), 'w', encoding = 'utf-8') as fp: fp.write(self._build_python_code_from_template()) try: os.chmod(self.get_file_path(), self._mode) @@ -120,26 +122,20 @@ class TopBlockGenerator(object): Returns: a popen object """ - # extract the path to the python executable - python_exe = sys.executable - - # when using wx gui on mac os, execute with pythonw - # using pythonw is not necessary anymore, disabled below - # if self._generate_options == 'wx_gui' and 'darwin' in sys.platform.lower(): - # python_exe = 'pythonw' - def args_to_string(args): """Accounts for spaces in args""" return ' '.join(repr(arg) if ' ' in arg else arg for arg in args) - # setup the command args to run - cmds = [python_exe, '-u', self.get_file_path()] # -u is unbuffered stdio + run_command = self._flow_graph.get_option('run_command') + cmds = shlex.split(run_command.format(python=sys.executable, + filename=self.get_file_path())) # when in no gui mode on linux, use a graphical terminal (looks nice) xterm_executable = find_executable(XTERM_EXECUTABLE) if self._generate_options == 'no_gui' and xterm_executable: cmds = [xterm_executable, '-e', args_to_string(cmds)] + Messages.send_start_exec(args_to_string(cmds)) p = subprocess.Popen( args=cmds, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False, universal_newlines=True) @@ -172,7 +168,7 @@ class TopBlockGenerator(object): return code blocks = expr_utils.sort_objects( - filter(lambda b: b.get_enabled() and not b.get_bypassed(), self._flow_graph.get_blocks()), + filter(lambda b: b.get_enabled() and not b.get_bypassed(), self._flow_graph.iter_blocks()), lambda b: b.get_id(), _get_block_sort_text ) # List of regular blocks (all blocks minus the special ones) |