summaryrefslogtreecommitdiff
path: root/grc/core/FlowGraph.py
diff options
context:
space:
mode:
Diffstat (limited to 'grc/core/FlowGraph.py')
-rw-r--r--grc/core/FlowGraph.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/grc/core/FlowGraph.py b/grc/core/FlowGraph.py
index 48563eefb1..ecae11cf1a 100644
--- a/grc/core/FlowGraph.py
+++ b/grc/core/FlowGraph.py
@@ -16,16 +16,16 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import imp
-import time
from itertools import ifilter, chain
from operator import methodcaller, attrgetter
-
import re
+import sys
+import time
from . import Messages
from .Constants import FLOW_GRAPH_FILE_FORMAT_VERSION
from .Element import Element
-from .utils import odict, expr_utils
+from .utils import odict, expr_utils, shlex
_parameter_matcher = re.compile('^(parameter)$')
_monitors_searcher = re.compile('(ctrlport_monitor)')
@@ -64,7 +64,7 @@ class FlowGraph(Element):
self._options_block = self.new_block('options')
def __str__(self):
- return 'FlowGraph - {0}({1})'.format(self.get_option('title'), self.get_option('id'))
+ return 'FlowGraph - {}({})'.format(self.get_option('title'), self.get_option('id'))
##############################################
# TODO: Move these to new generator package
@@ -186,6 +186,16 @@ class FlowGraph(Element):
"""
return self._options_block.get_param(key).get_evaluated()
+ def get_run_command(self, file_path, split=False):
+ run_command = self.get_option('run_command')
+ try:
+ run_command = run_command.format(
+ python=shlex.quote(sys.executable),
+ filename=shlex.quote(file_path))
+ return shlex.split(run_command) if split else run_command
+ except Exception as e:
+ raise ValueError("Can't parse run command {!r}: {}".format(run_command, e))
+
##############################################
# Access Elements
##############################################
@@ -410,7 +420,7 @@ class FlowGraph(Element):
cwd=self.grc_file_path
)
if file_path: # grc file found. load and get block
- self.platform.load_and_generate_flow_graph(file_path)
+ self.platform.load_and_generate_flow_graph(file_path, hier_only=True)
block = self.new_block(key) # can be None
if not block: # looks like this block key cannot be found
@@ -461,7 +471,7 @@ class FlowGraph(Element):
self.connect(source_port, sink_port)
except LookupError as e:
Messages.send_error_load(
- 'Connection between {0}({1}) and {2}({3}) could not be made.\n\t{4}'.format(
+ 'Connection between {}({}) and {}({}) could not be made.\n\t{}'.format(
source_block_id, source_key, sink_block_id, sink_key, e))
errors = True