summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHåkon Vågsether <haakonsv@gmail.com>2019-01-06 15:17:07 +0100
committerMartin Braun <martin.braun@ettus.com>2019-01-07 09:36:13 -0800
commit81169174000ab29bcd651464e830389c62463d5d (patch)
treee0f6b1880ee4eaaf4e9fcb8055bca8c24a90cef0
parent41b4b6a2b835917c7616fe700a632eca8e4c8199 (diff)
grc: Fix Python Module block
Before this fix, it was not possible to add a 'Python Module' to a GRC flow graph, it would just throw exceptions when you tried.
-rw-r--r--grc/core/FlowGraph.py2
-rw-r--r--grc/core/blocks/embedded_python.py7
-rw-r--r--grc/core/generator/top_block.py6
3 files changed, 10 insertions, 5 deletions
diff --git a/grc/core/FlowGraph.py b/grc/core/FlowGraph.py
index bf26225e48..58e10f08b5 100644
--- a/grc/core/FlowGraph.py
+++ b/grc/core/FlowGraph.py
@@ -103,7 +103,7 @@ class FlowGraph(Element):
"""Iterate over custom code block ID and Source"""
for block in self.iter_enabled_blocks():
if block.key == 'epy_module':
- yield block.name, block.params[1].get_value()
+ yield block.name, block.params['source_code'].get_value()
def iter_enabled_blocks(self):
"""
diff --git a/grc/core/blocks/embedded_python.py b/grc/core/blocks/embedded_python.py
index 0b5a7a21c5..29791e1a52 100644
--- a/grc/core/blocks/embedded_python.py
+++ b/grc/core/blocks/embedded_python.py
@@ -26,6 +26,7 @@ from ._templates import MakoTemplates
from .. import utils
from ..base import Element
+from ._build import _build_params as build_core_params
DEFAULT_CODE = '''\
"""
@@ -229,7 +230,7 @@ class EPyModule(Block):
to set parameters of other blocks in your flowgraph.
""")}
- parameters_data = [dict(
+ parameters = [dict(
label='Code',
id='source_code',
dtype='_multiline_python_external',
@@ -240,3 +241,7 @@ class EPyModule(Block):
templates = MakoTemplates(
imports='import ${ id } # embedded python module',
)
+
+ def __init__(self, flow_graph, **kwargs):
+ self.parameters_data = build_core_params(self.parameters, False, False, self.flags, self.key)
+ super(EPyModule, self).__init__(flow_graph, **kwargs)
diff --git a/grc/core/generator/top_block.py b/grc/core/generator/top_block.py
index fad541ea34..cac7537b99 100644
--- a/grc/core/generator/top_block.py
+++ b/grc/core/generator/top_block.py
@@ -201,9 +201,9 @@ class TopBlockGenerator(object):
for block in blocks:
make = block.templates.render('make')
if not (block.is_variable or block.is_virtual_or_pad):
- make = 'self.' + block.name + ' = ' + make
- if make:
- blocks_make.append((block, make))
+ if make:
+ make = 'self.' + block.name + ' = ' + make
+ blocks_make.append((block, make))
return blocks_make
def _callbacks(self):