From 63c928575c10741ac6a6c3c3c8be9c238e7b8432 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 17 Aug 2009 00:54:11 -0700 Subject: Removed Source and Sink classes as Port subclasses. A port can be a source or a sink based on the dir parameter. --- grc/python/Platform.py | 5 ++--- grc/python/Port.py | 34 ++++++++++++---------------------- 2 files changed, 14 insertions(+), 25 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Platform.py b/grc/python/Platform.py index d55dbf4ce..cab25d348 100644 --- a/grc/python/Platform.py +++ b/grc/python/Platform.py @@ -23,7 +23,7 @@ from .. base.Platform import Platform as _Platform from FlowGraph import FlowGraph as _FlowGraph from Connection import Connection as _Connection from Block import Block as _Block -from Port import Source,Sink +from Port import Port as _Port from Param import Param as _Param from Generator import Generator from Constants import \ @@ -77,6 +77,5 @@ class Platform(_Platform): FlowGraph = _FlowGraph Connection = _Connection Block = _Block - Source = Source - Sink = Sink + Port = _Port Param = _Param diff --git a/grc/python/Port.py b/grc/python/Port.py index daf8f9ca3..f71c5fa35 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -25,17 +25,27 @@ class Port(_Port): ##possible port types TYPES = ['complex', 'float', 'int', 'short', 'byte', 'msg'] - def __init__(self, block, n): + def __init__(self, block, n, dir): """ Make a new port from nested data. @param block the parent element @param n the nested odict + @param dir the direction """ + self._n = n + if n['type'] == 'msg': n['key'] = 'msg' + if dir == 'source' and not n.find('key'): + n['key'] = str(block._source_count) + block._source_count += 1 + if dir == 'sink' and not n.find('key'): + n['key'] = str(block._sink_count) + block._sink_count += 1 #build the port _Port.__init__( self, block=block, n=n, + dir=dir, ) self._nports = n.find('nports') or '' self._vlen = n.find('vlen') or '' @@ -109,24 +119,4 @@ class Port(_Port): def copy(self, new_key=None): n = self._n.copy() if new_key: n['key'] = new_key - return self.__class__(self.get_parent(), n) - -class Source(Port): - - def __init__(self, block, n): - self._n = n #save n - if n['type'] == 'msg': n['key'] = 'msg' - if not n.find('key'): - n['key'] = str(block._source_count) - block._source_count = block._source_count + 1 - Port.__init__(self, block, n) - -class Sink(Port): - - def __init__(self, block, n): - self._n = n #save n - if n['type'] == 'msg': n['key'] = 'msg' - if not n.find('key'): - n['key'] = str(block._sink_count) - block._sink_count = block._sink_count + 1 - Port.__init__(self, block, n) + return self.__class__(self.get_parent(), n, self._dir) -- cgit From bf232a6e6e73d156c9a46c26842480352c6794c0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 20 Aug 2009 01:30:23 -0700 Subject: added continuation mode for pad source and sinks --- grc/python/flow_graph.tmpl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'grc/python') diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index df346dd16..32139636a 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -161,8 +161,20 @@ class $(class_name)(gr.hier_block2): $DIVIDER #end if #for $con in $connections + #################################################################### + ## Logic to extract source and sink + ## Special resolution logic for pad source in continuation mode + #################################################################### #set $source = $con.get_source() #set $sink = $con.get_sink() + #if $source.get_parent().get_key() == 'pad_source' and $source.get_parent().get_param('mode').get_value() == 'cont' + #set $pad_sink_id = $source.get_parent().get_param('pad_sink_id').get_evaluated() + #set $pad_sink = filter(lambda b: b.get_id() == pad_sink_id, $blocks)[0] + #set $source = $pad_sink.get_sink($source.get_key()).get_connections()[0].get_source() + #end if + #################################################################### + ## Logic to extract source and sink names + #################################################################### #if $source.get_parent().get_key() == 'pad_source' #set $source_name = 'self' #else @@ -173,7 +185,12 @@ class $(class_name)(gr.hier_block2): #else #set $sink_name = 'self.' + $sink.get_parent().get_id() #end if + #################################################################### + ## Dont make a connection for continuation pad sinks!!! + #################################################################### + #if not ($sink.get_parent().get_key() == 'pad_sink' and $sink.get_parent().get_param('mode').get_value() == 'cont') self.connect(($source_name, $source.get_key()), ($sink_name, $sink.get_key())) + #end if #end for ######################################################## -- cgit From af5701409859af4b20a03bfd6b2cebf3559b1b3d Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 25 Aug 2009 14:56:47 -0700 Subject: Work on command line options for generated code. Simplified eng_option eng_float to reuse str_to_num code. --- grc/python/flow_graph.tmpl | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'grc/python') diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index 32139636a..924a280c4 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -211,6 +211,20 @@ class $(class_name)(gr.hier_block2): ## For top block code, generate a main routine. ## Instantiate the top block and run as gui or cli. ######################################################## +#def make_default($type, $param) + #if $type == 'eng_float' +eng_notation.num_to_str($param.get_make())#slurp + #else +$param.get_make()#slurp + #end if +#end def +#def make_short_id($param) + #set $short_id = $param.get_param('short_id').get_evaluated() + #if $short_id + #set $short_id = '-' + $short_id + #end if +$short_id#slurp +#end def #if $generate_options != 'hb' if __name__ == '__main__': parser = OptionParser(option_class=eng_option, usage="%prog: [options]") @@ -219,12 +233,8 @@ if __name__ == '__main__': #set $type = $param.get_param('type').get_value() #if $type #silent $params_eq_list.append('%s=options.%s'%($param.get_id(), $param.get_id())) - #set $short_id = $param.get_param('short_id').get_evaluated() - #if $short_id - #set $short_id = '-' + $short_id - #end if - parser.add_option("$short_id", "--$param.get_id()", dest="$param.get_id()", type="$type", default=$param.get_make(), - help="Set $($param.get_param('label').evaluate() or $param.get_id()) [default=%default]") + parser.add_option("$make_short_id($param)", "--$param.get_id().replace('_', '-')", dest="$param.get_id()", type="$type", default=$make_default($type, $param), + help="Set $($param.get_param('label').get_evaluated() or $param.get_id()) [default=%default]") #end if #end for (options, args) = parser.parse_args() -- cgit From 62abad680b43218bbacf03c19d35c068973de4b9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 25 Aug 2009 23:42:18 -0700 Subject: removed repurposing of pads --- grc/python/flow_graph.tmpl | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) (limited to 'grc/python') diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index 924a280c4..5e5844052 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -154,6 +154,13 @@ class $(class_name)(gr.hier_block2): ## The port name should be the id of the parent block. ## However, port names for IO pads should be self. ######################################################## +#def make_port_name($port) + #if $port.get_parent().get_key().startswith('pad_') +self#slurp + #else +self.$port.get_parent().get_id()#slurp + #end if +#end def #if $connections $DIVIDER @@ -161,36 +168,9 @@ class $(class_name)(gr.hier_block2): $DIVIDER #end if #for $con in $connections - #################################################################### - ## Logic to extract source and sink - ## Special resolution logic for pad source in continuation mode - #################################################################### #set $source = $con.get_source() #set $sink = $con.get_sink() - #if $source.get_parent().get_key() == 'pad_source' and $source.get_parent().get_param('mode').get_value() == 'cont' - #set $pad_sink_id = $source.get_parent().get_param('pad_sink_id').get_evaluated() - #set $pad_sink = filter(lambda b: b.get_id() == pad_sink_id, $blocks)[0] - #set $source = $pad_sink.get_sink($source.get_key()).get_connections()[0].get_source() - #end if - #################################################################### - ## Logic to extract source and sink names - #################################################################### - #if $source.get_parent().get_key() == 'pad_source' - #set $source_name = 'self' - #else - #set $source_name = 'self.' + $source.get_parent().get_id() - #end if - #if $sink.get_parent().get_key() == 'pad_sink' - #set $sink_name = 'self' - #else - #set $sink_name = 'self.' + $sink.get_parent().get_id() - #end if - #################################################################### - ## Dont make a connection for continuation pad sinks!!! - #################################################################### - #if not ($sink.get_parent().get_key() == 'pad_sink' and $sink.get_parent().get_param('mode').get_value() == 'cont') - self.connect(($source_name, $source.get_key()), ($sink_name, $sink.get_key())) - #end if + self.connect(($make_port_name($source), $source.get_key()), ($make_port_name($sink), $sink.get_key())) #end for ######################################################## -- cgit From 854bed10dfb61e9f9feab5259a75e809941089ab Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 26 Aug 2009 11:23:23 -0700 Subject: Added virtual sink and logic to clone port. Tweaks to the base validation routines. Validate twice in the update until rewrite functions are implemented. --- grc/python/Port.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'grc/python') diff --git a/grc/python/Port.py b/grc/python/Port.py index f71c5fa35..bfbac7237 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -57,11 +57,25 @@ class Port(_Port): except AssertionError: self.add_error_message('Port is not connected.') try: assert self.is_source() or len(self.get_enabled_connections()) <= 1 except AssertionError: self.add_error_message('Port has too many connections.') + ################################################################ + # message port logic + ################################################################ if self.get_type() == 'msg': try: assert not self.get_nports() except AssertionError: self.add_error_message('A port of type "msg" cannot have "nports" set.') try: assert self.get_vlen() == 1 except AssertionError: self.add_error_message('A port of type "msg" must have a "vlen" of 1.') + ################################################################ + # virtual sink logic + ################################################################ + if self.get_parent().get_key() == 'virtual_sink': + if self.get_enabled_connections(): #clone type and vlen + source = self.get_enabled_connections()[0].get_source() + self._type = str(source.get_type()) + self._vlen = str(source.get_vlen()) + else: #reset type and vlen + self._type = '' + self._vlen = '' def get_vlen(self): """ -- cgit From dc9e9db16047ec589a7b0488fac04c5bb682903c Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 26 Aug 2009 13:29:28 -0700 Subject: added rewrite methods to element to separate from validation logic --- grc/python/Block.py | 7 ++++++- grc/python/Port.py | 14 ++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Block.py b/grc/python/Block.py index 47fe13a3c..f47f76446 100644 --- a/grc/python/Block.py +++ b/grc/python/Block.py @@ -54,7 +54,6 @@ class Block(_Block): Validate this block. Call the base class validate. Evaluate the checks: each check must evaluate to True. - Adjust the nports. """ _Block.validate(self) #evaluate the checks @@ -65,6 +64,12 @@ class Block(_Block): try: assert check_eval except AssertionError: self.add_error_message('Check "%s" failed.'%check) except: self.add_error_message('Check "%s" did not evaluate.'%check) + + def rewrite(self): + """ + Add and remove ports to adjust for the nports. + """ + _Block.rewrite(self) #adjust nports for get_ports, get_port in ( (self.get_sources, self.get_source), diff --git a/grc/python/Port.py b/grc/python/Port.py index bfbac7237..dde736dba 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -57,17 +57,19 @@ class Port(_Port): except AssertionError: self.add_error_message('Port is not connected.') try: assert self.is_source() or len(self.get_enabled_connections()) <= 1 except AssertionError: self.add_error_message('Port has too many connections.') - ################################################################ - # message port logic - ################################################################ + #message port logic if self.get_type() == 'msg': try: assert not self.get_nports() except AssertionError: self.add_error_message('A port of type "msg" cannot have "nports" set.') try: assert self.get_vlen() == 1 except AssertionError: self.add_error_message('A port of type "msg" must have a "vlen" of 1.') - ################################################################ - # virtual sink logic - ################################################################ + + def rewrite(self): + """ + Handle the port cloning for virtual blocks. + """ + _Port.rewrite(self) + #virtual sink logic if self.get_parent().get_key() == 'virtual_sink': if self.get_enabled_connections(): #clone type and vlen source = self.get_enabled_connections()[0].get_source() -- cgit From 36d1520f0ac73b64bd0541b422552a6d419c7ffd Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 28 Aug 2009 01:09:08 -0700 Subject: added virtual source and added stream ids, logic to clone in port --- grc/python/Port.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Port.py b/grc/python/Port.py index dde736dba..b386e3f89 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -69,13 +69,23 @@ class Port(_Port): Handle the port cloning for virtual blocks. """ _Port.rewrite(self) - #virtual sink logic - if self.get_parent().get_key() == 'virtual_sink': - if self.get_enabled_connections(): #clone type and vlen - source = self.get_enabled_connections()[0].get_source() + if self.get_parent().get_key() in ('virtual_sink', 'virtual_source'): + try: + if self.get_parent().get_key() == 'virtual_sink': + source = self.get_enabled_connections()[0].get_source() + if self.get_parent().get_key() == 'virtual_source': + source = filter( + lambda vs: vs.get_param('stream_id').get_value() == self.get_parent().get_param('stream_id').get_value(), + filter( + lambda b: b.get_key() == 'virtual_sink', + self.get_parent().get_parent().get_enabled_blocks(), + ), + )[0].get_sink('0').get_enabled_connections()[0].get_source() + #clone type and vlen self._type = str(source.get_type()) self._vlen = str(source.get_vlen()) - else: #reset type and vlen + except: + #reset type and vlen self._type = '' self._vlen = '' -- cgit From cadc9548afb7b4a385cea51f48745f0a1c702607 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 28 Aug 2009 18:15:49 -0700 Subject: Recursive resolution of virtual sources. Flow graph generation code working. Also, mod to fft window to use clean/nice Db/div. --- grc/python/Connection.py | 2 +- grc/python/Port.py | 45 ++++++++++++++++++++++++++++++--------------- grc/python/flow_graph.tmpl | 7 +++++++ 3 files changed, 38 insertions(+), 16 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Connection.py b/grc/python/Connection.py index 5eba9f24d..85b5b2c52 100644 --- a/grc/python/Connection.py +++ b/grc/python/Connection.py @@ -1,5 +1,5 @@ """ -Copyright 2008 Free Software Foundation, Inc. +Copyright 2008, 2009 Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or diff --git a/grc/python/Port.py b/grc/python/Port.py index b386e3f89..2f7af855c 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -20,6 +20,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA from .. base.Port import Port as _Port import Constants +def _get_source_from_virtual_sink_port(vsp): + try: return _get_source_from_virtual_source_port( + vsp.get_enabled_connections()[0].get_source()) + except: raise Exception, 'Could not resolve source for virtual sink port', vsp + +def _get_source_from_virtual_source_port(vsp): + if not vsp.is_virtual_source(): return vsp + try: return _get_source_from_virtual_source_port( + _get_source_from_virtual_sink_port( + filter( + lambda vs: vs.get_param('stream_id').get_value() == vsp.get_parent().get_param('stream_id').get_value(), + filter( + lambda b: b.get_key() == 'virtual_sink', + vsp.get_parent().get_parent().get_enabled_blocks(), + ), + )[0].get_sink(vsp.get_key()) + ) + ) + except: raise Exception, 'Could not resolve source for virtual source port', vsp + class Port(_Port): ##possible port types @@ -69,26 +89,21 @@ class Port(_Port): Handle the port cloning for virtual blocks. """ _Port.rewrite(self) - if self.get_parent().get_key() in ('virtual_sink', 'virtual_source'): - try: - if self.get_parent().get_key() == 'virtual_sink': - source = self.get_enabled_connections()[0].get_source() - if self.get_parent().get_key() == 'virtual_source': - source = filter( - lambda vs: vs.get_param('stream_id').get_value() == self.get_parent().get_param('stream_id').get_value(), - filter( - lambda b: b.get_key() == 'virtual_sink', - self.get_parent().get_parent().get_enabled_blocks(), - ), - )[0].get_sink('0').get_enabled_connections()[0].get_source() - #clone type and vlen + if self.is_virtual_sink() or self.is_virtual_source(): + try: #clone type and vlen + source = self.resolve_virtual_source() self._type = str(source.get_type()) self._vlen = str(source.get_vlen()) - except: - #reset type and vlen + except: #reset type and vlen self._type = '' self._vlen = '' + def is_virtual_sink(self): return self.get_parent().get_key() == 'virtual_sink' + def is_virtual_source(self): return self.get_parent().get_key() == 'virtual_source' + def resolve_virtual_source(self): + if self.is_virtual_sink(): return _get_source_from_virtual_sink_port(self) + if self.is_virtual_source(): return _get_source_from_virtual_source_port(self) + def get_vlen(self): """ Get the vector length. diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index 5e5844052..bd12e82e9 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -170,7 +170,14 @@ self.$port.get_parent().get_id()#slurp #for $con in $connections #set $source = $con.get_source() #set $sink = $con.get_sink() + ##resolve virtual sources to the actual sources + #if $source.is_virtual_source() + #set $source = $source.resolve_virtual_source() + #end if + ##do not generate connections with virtual sinks + #if not $sink.is_virtual_sink() self.connect(($make_port_name($source), $source.get_key()), ($make_port_name($sink), $sink.get_key())) + #end if #end for ######################################################## -- cgit From 5f7bd3f80387ea699649f76bd22d0be5ba08732d Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 28 Aug 2009 20:39:35 -0700 Subject: avoid loops --- grc/python/Port.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Port.py b/grc/python/Port.py index 2f7af855c..80d9fcaae 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -21,12 +21,21 @@ from .. base.Port import Port as _Port import Constants def _get_source_from_virtual_sink_port(vsp): + """ + Resolve the source port that is connected to the given virtual sink port. + Use the get source from virtual source to recursively resolve subsequent ports. + """ try: return _get_source_from_virtual_source_port( vsp.get_enabled_connections()[0].get_source()) - except: raise Exception, 'Could not resolve source for virtual sink port', vsp + except: raise Exception, 'Could not resolve source for virtual sink port %s'%vsp -def _get_source_from_virtual_source_port(vsp): +def _get_source_from_virtual_source_port(vsp, traversed=[]): + """ + Recursively resolve source ports over the virtual connections. + Keep track of traversed sources to avoid recursive loops. + """ if not vsp.is_virtual_source(): return vsp + if vsp in traversed: raise Exception, 'Loop found when resolving virtual source %s'%vsp try: return _get_source_from_virtual_source_port( _get_source_from_virtual_sink_port( filter( @@ -36,9 +45,9 @@ def _get_source_from_virtual_source_port(vsp): vsp.get_parent().get_parent().get_enabled_blocks(), ), )[0].get_sink(vsp.get_key()) - ) + ), traversed + [vsp], ) - except: raise Exception, 'Could not resolve source for virtual source port', vsp + except: raise Exception, 'Could not resolve source for virtual source port %s'%vsp class Port(_Port): -- cgit From 9ae19105d745ef2c7be8fbe3c2206a0a6ca6632b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 28 Aug 2009 20:57:40 -0700 Subject: added stream id type and checking in evaluate --- grc/python/Param.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Param.py b/grc/python/Param.py index f971d0c3f..49601f168 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -94,7 +94,7 @@ class Param(_Param): 'complex_vector', 'real_vector', 'int_vector', 'hex', 'string', 'bool', 'file_open', 'file_save', - 'id', + 'id', 'stream_id', 'grid_pos', 'notebook', 'import', ] @@ -310,14 +310,31 @@ class Param(_Param): #can python use this as a variable? try: assert _check_id_matcher.match(v) except AssertionError: raise Exception, 'ID "%s" must begin with a letter and may contain letters, numbers, and underscores.'%v - params = self.get_all_params('id') - keys = [param.get_value() for param in params] - try: assert keys.count(v) <= 1 #id should only appear once, or zero times if block is disabled + ids = [param.get_value() for param in self.get_all_params(t)] + try: assert ids.count(v) <= 1 #id should only appear once, or zero times if block is disabled except: raise Exception, 'ID "%s" is not unique.'%v try: assert v not in ID_BLACKLIST except: raise Exception, 'ID "%s" is blacklisted.'%v return v ######################### + # Stream ID Type + ######################### + elif t == 'stream_id': + #get a list of all stream ids used in the virtual sinks + ids = [param.get_value() for param in filter( + lambda p: p.get_parent().get_key() == 'virtual_sink', + self.get_all_params(t), + )] + #check that the virtual sink's stream id is unique + if self.get_parent().get_key() == 'virtual_sink': + try: assert ids.count(v) <= 1 #id should only appear once, or zero times if block is disabled + except: raise Exception, 'Stream ID "%s" is not unique.'%v + #check that the virtual source's steam id is found + if self.get_parent().get_key() == 'virtual_source': + try: assert v in ids + except: raise Exception, 'Stream ID "%s" is not found.'%v + return v + ######################### # Grid Position Type ######################### elif t == 'grid_pos': -- cgit From cb794a7c8703ea06a9bce110fc1041140f25e8e6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 28 Aug 2009 21:06:19 -0700 Subject: made is_virtual_xxx a block level function, used by port and param classes --- grc/python/Block.py | 3 +++ grc/python/Param.py | 6 +++--- grc/python/Port.py | 16 +++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Block.py b/grc/python/Block.py index f47f76446..2df2049a4 100644 --- a/grc/python/Block.py +++ b/grc/python/Block.py @@ -23,6 +23,9 @@ import extract_category class Block(_Block): + def is_virtual_sink(self): return self.get_key() == 'virtual_sink' + def is_virtual_source(self): return self.get_key() == 'virtual_source' + ##for make source to keep track of indexes _source_count = 0 ##for make sink to keep track of indexes diff --git a/grc/python/Param.py b/grc/python/Param.py index 49601f168..2ca1d0ec0 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -322,15 +322,15 @@ class Param(_Param): elif t == 'stream_id': #get a list of all stream ids used in the virtual sinks ids = [param.get_value() for param in filter( - lambda p: p.get_parent().get_key() == 'virtual_sink', + lambda p: p.get_parent().is_virtual_sink(), self.get_all_params(t), )] #check that the virtual sink's stream id is unique - if self.get_parent().get_key() == 'virtual_sink': + if self.get_parent().is_virtual_sink(): try: assert ids.count(v) <= 1 #id should only appear once, or zero times if block is disabled except: raise Exception, 'Stream ID "%s" is not unique.'%v #check that the virtual source's steam id is found - if self.get_parent().get_key() == 'virtual_source': + if self.get_parent().is_virtual_source(): try: assert v in ids except: raise Exception, 'Stream ID "%s" is not found.'%v return v diff --git a/grc/python/Port.py b/grc/python/Port.py index 80d9fcaae..d6c622c46 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -34,14 +34,14 @@ def _get_source_from_virtual_source_port(vsp, traversed=[]): Recursively resolve source ports over the virtual connections. Keep track of traversed sources to avoid recursive loops. """ - if not vsp.is_virtual_source(): return vsp + if not vsp.get_parent().is_virtual_source(): return vsp if vsp in traversed: raise Exception, 'Loop found when resolving virtual source %s'%vsp try: return _get_source_from_virtual_source_port( _get_source_from_virtual_sink_port( - filter( + filter(#get all virtual sinks with a matching stream id lambda vs: vs.get_param('stream_id').get_value() == vsp.get_parent().get_param('stream_id').get_value(), - filter( - lambda b: b.get_key() == 'virtual_sink', + filter(#get all enabled blocks that are also virtual sinks + lambda b: b.is_virtual_sink(), vsp.get_parent().get_parent().get_enabled_blocks(), ), )[0].get_sink(vsp.get_key()) @@ -98,7 +98,7 @@ class Port(_Port): Handle the port cloning for virtual blocks. """ _Port.rewrite(self) - if self.is_virtual_sink() or self.is_virtual_source(): + if self.get_parent().is_virtual_sink() or self.get_parent().is_virtual_source(): try: #clone type and vlen source = self.resolve_virtual_source() self._type = str(source.get_type()) @@ -107,11 +107,9 @@ class Port(_Port): self._type = '' self._vlen = '' - def is_virtual_sink(self): return self.get_parent().get_key() == 'virtual_sink' - def is_virtual_source(self): return self.get_parent().get_key() == 'virtual_source' def resolve_virtual_source(self): - if self.is_virtual_sink(): return _get_source_from_virtual_sink_port(self) - if self.is_virtual_source(): return _get_source_from_virtual_source_port(self) + if self.get_parent().is_virtual_sink(): return _get_source_from_virtual_sink_port(self) + if self.get_parent().is_virtual_source(): return _get_source_from_virtual_source_port(self) def get_vlen(self): """ -- cgit From 576d3978c7fafe5d6727c77281e3aad6d92074d2 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 29 Aug 2009 01:04:58 -0700 Subject: Replaced TYPES in Port and Param with types parameter. Replaced odict in options for storing options with a list. Fix virtual port check in flow graph template. --- grc/python/Param.py | 29 +++++++++++++++++++---------- grc/python/Port.py | 9 +++++---- grc/python/flow_graph.tmpl | 4 ++-- 3 files changed, 26 insertions(+), 16 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Param.py b/grc/python/Param.py index 2ca1d0ec0..dd18d1c44 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -83,21 +83,30 @@ COMPLEX_TYPES = tuple(COMPLEX_TYPES + REAL_TYPES + INT_TYPES) REAL_TYPES = tuple(REAL_TYPES + INT_TYPES) INT_TYPES = tuple(INT_TYPES) +##possible param types +TYPES = [ + 'raw', 'enum', + 'complex', 'real', 'int', + 'complex_vector', 'real_vector', 'int_vector', + 'hex', 'string', 'bool', + 'file_open', 'file_save', + 'id', 'stream_id', + 'grid_pos', 'notebook', + 'import', +] + class Param(_Param): _init = False _hostage_cells = list() - ##possible param types - TYPES = _Param.TYPES + [ - 'complex', 'real', 'int', - 'complex_vector', 'real_vector', 'int_vector', - 'hex', 'string', 'bool', - 'file_open', 'file_save', - 'id', 'stream_id', - 'grid_pos', 'notebook', - 'import', - ] + def __init__(self, block, n, **kwargs): + _Param.__init__( + self, + block=block, + n=n, + types=TYPES, + ) def __repr__(self): """ diff --git a/grc/python/Port.py b/grc/python/Port.py index d6c622c46..3214d937a 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -49,12 +49,12 @@ def _get_source_from_virtual_source_port(vsp, traversed=[]): ) except: raise Exception, 'Could not resolve source for virtual source port %s'%vsp -class Port(_Port): +##possible port types +TYPES = ['complex', 'float', 'int', 'short', 'byte', 'msg', ''] - ##possible port types - TYPES = ['complex', 'float', 'int', 'short', 'byte', 'msg'] +class Port(_Port): - def __init__(self, block, n, dir): + def __init__(self, block, n, dir, **kwargs): """ Make a new port from nested data. @param block the parent element @@ -75,6 +75,7 @@ class Port(_Port): block=block, n=n, dir=dir, + types=TYPES, ) self._nports = n.find('nports') or '' self._vlen = n.find('vlen') or '' diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index bd12e82e9..dce4037d5 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -171,11 +171,11 @@ self.$port.get_parent().get_id()#slurp #set $source = $con.get_source() #set $sink = $con.get_sink() ##resolve virtual sources to the actual sources - #if $source.is_virtual_source() + #if $source.get_parent().is_virtual_source() #set $source = $source.resolve_virtual_source() #end if ##do not generate connections with virtual sinks - #if not $sink.is_virtual_sink() + #if not $sink.get_parent().is_virtual_sink() self.connect(($make_port_name($source), $source.get_key()), ($make_port_name($sink), $sink.get_key())) #end if #end for -- cgit From cc13a27310e4ab91ebf90ee2d9cd6e3c659e1bc0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 30 Aug 2009 09:35:55 -0700 Subject: port and param types from an overloaded method --- grc/python/Param.py | 31 ++++++++++++++----------------- grc/python/Port.py | 8 +++----- 2 files changed, 17 insertions(+), 22 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Param.py b/grc/python/Param.py index dd18d1c44..d574b513e 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -83,30 +83,27 @@ COMPLEX_TYPES = tuple(COMPLEX_TYPES + REAL_TYPES + INT_TYPES) REAL_TYPES = tuple(REAL_TYPES + INT_TYPES) INT_TYPES = tuple(INT_TYPES) -##possible param types -TYPES = [ - 'raw', 'enum', - 'complex', 'real', 'int', - 'complex_vector', 'real_vector', 'int_vector', - 'hex', 'string', 'bool', - 'file_open', 'file_save', - 'id', 'stream_id', - 'grid_pos', 'notebook', - 'import', -] - class Param(_Param): - _init = False - _hostage_cells = list() - - def __init__(self, block, n, **kwargs): + def __init__(self, block, n): _Param.__init__( self, block=block, n=n, - types=TYPES, ) + self._init = False + self._hostage_cells = list() + + def get_types(self): return ( + 'raw', 'enum', + 'complex', 'real', 'int', + 'complex_vector', 'real_vector', 'int_vector', + 'hex', 'string', 'bool', + 'file_open', 'file_save', + 'id', 'stream_id', + 'grid_pos', 'notebook', + 'import', + ) def __repr__(self): """ diff --git a/grc/python/Port.py b/grc/python/Port.py index 3214d937a..a714844ef 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -49,12 +49,9 @@ def _get_source_from_virtual_source_port(vsp, traversed=[]): ) except: raise Exception, 'Could not resolve source for virtual source port %s'%vsp -##possible port types -TYPES = ['complex', 'float', 'int', 'short', 'byte', 'msg', ''] - class Port(_Port): - def __init__(self, block, n, dir, **kwargs): + def __init__(self, block, n, dir): """ Make a new port from nested data. @param block the parent element @@ -75,12 +72,13 @@ class Port(_Port): block=block, n=n, dir=dir, - types=TYPES, ) self._nports = n.find('nports') or '' self._vlen = n.find('vlen') or '' self._optional = bool(n.find('optional')) + def get_types(self): return ('complex', 'float', 'int', 'short', 'byte', 'msg', '') + def validate(self): _Port.validate(self) try: assert self.get_enabled_connections() or self.get_optional() -- cgit From 152fcbc219cd2e4f6df7b38843844bc85fdf2bc2 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 30 Aug 2009 10:34:10 -0700 Subject: Switched the python classes to inherit from the base and gui classes. Use only **kwargs so all contructor parameters must be passed with keys. Moved gui input forms classes from base to gui param module. --- grc/python/Block.py | 4 +++- grc/python/Connection.py | 7 ++++++- grc/python/FlowGraph.py | 7 ++++++- grc/python/Param.py | 18 +++++++++--------- grc/python/Platform.py | 4 +++- grc/python/Port.py | 4 +++- 6 files changed, 30 insertions(+), 14 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Block.py b/grc/python/Block.py index 2df2049a4..dd39b095d 100644 --- a/grc/python/Block.py +++ b/grc/python/Block.py @@ -18,10 +18,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ from .. base.Block import Block as _Block +from .. gui.Block import Block as _GUIBlock import extract_docs import extract_category -class Block(_Block): +class Block(_Block, _GUIBlock): def is_virtual_sink(self): return self.get_key() == 'virtual_sink' def is_virtual_source(self): return self.get_key() == 'virtual_source' @@ -51,6 +52,7 @@ class Block(_Block): flow_graph=flow_graph, n=n, ) + _GUIBlock.__init__(self) def validate(self): """ diff --git a/grc/python/Connection.py b/grc/python/Connection.py index 85b5b2c52..edc18841a 100644 --- a/grc/python/Connection.py +++ b/grc/python/Connection.py @@ -18,8 +18,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ from .. base.Connection import Connection as _Connection +from .. gui.Connection import Connection as _GUIConnection -class Connection(_Connection): +class Connection(_Connection, _GUIConnection): + + def __init__(self, **kwargs): + _Connection.__init__(self, **kwargs) + _GUIConnection.__init__(self) def is_msg(self): return self.get_source().get_type() == self.get_sink().get_type() == 'msg' diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py index 8cad8be49..96188b816 100644 --- a/grc/python/FlowGraph.py +++ b/grc/python/FlowGraph.py @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import expr_utils from .. base.FlowGraph import FlowGraph as _FlowGraph +from .. gui.FlowGraph import FlowGraph as _GUIFlowGraph from Block import Block from Connection import Connection import re @@ -26,7 +27,11 @@ import re _variable_matcher = re.compile('^(variable\w*)$') _parameter_matcher = re.compile('^(parameter)$') -class FlowGraph(_FlowGraph): +class FlowGraph(_FlowGraph, _GUIFlowGraph): + + def __init__(self, **kwargs): + _FlowGraph.__init__(self, **kwargs) + _GUIFlowGraph.__init__(self) _eval_cache = dict() def _eval(self, code, namespace, namespace_hash): diff --git a/grc/python/Param.py b/grc/python/Param.py index d574b513e..17cfad051 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -18,7 +18,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ import expr_utils -from .. base.Param import Param as _Param, EntryParam +from .. base.Param import Param as _Param +from .. gui.Param import Param as _GUIParam +from .. gui.Param import EntryParam import Constants import numpy import os @@ -83,14 +85,11 @@ COMPLEX_TYPES = tuple(COMPLEX_TYPES + REAL_TYPES + INT_TYPES) REAL_TYPES = tuple(REAL_TYPES + INT_TYPES) INT_TYPES = tuple(INT_TYPES) -class Param(_Param): +class Param(_Param, _GUIParam): - def __init__(self, block, n): - _Param.__init__( - self, - block=block, - n=n, - ) + def __init__(self, **kwargs): + _Param.__init__(self, **kwargs) + _GUIParam.__init__(self) self._init = False self._hostage_cells = list() @@ -156,7 +155,7 @@ class Param(_Param): def get_input_class(self): if self.get_type() in ('file_open', 'file_save'): return FileParam - return _Param.get_input_class(self) + return _GUIParam.get_input_class(self) def get_color(self): """ @@ -178,6 +177,7 @@ class Param(_Param): 'hex': Constants.INT_COLOR_SPEC, 'string': Constants.BYTE_VECTOR_COLOR_SPEC, 'id': Constants.ID_COLOR_SPEC, + 'stream_id': Constants.ID_COLOR_SPEC, 'grid_pos': Constants.INT_VECTOR_COLOR_SPEC, 'notebook': Constants.INT_VECTOR_COLOR_SPEC, 'raw': Constants.WILDCARD_COLOR_SPEC, diff --git a/grc/python/Platform.py b/grc/python/Platform.py index cab25d348..bb56d361b 100644 --- a/grc/python/Platform.py +++ b/grc/python/Platform.py @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import os from gnuradio import gr from .. base.Platform import Platform as _Platform +from .. gui.Platform import Platform as _GUIPlatform from FlowGraph import FlowGraph as _FlowGraph from Connection import Connection as _Connection from Block import Block as _Block @@ -46,7 +47,7 @@ COLORS = (#title, #color spec ('Message', Constants.MSG_COLOR_SPEC), ) -class Platform(_Platform): +class Platform(_Platform, _GUIPlatform): def __init__(self): """ @@ -70,6 +71,7 @@ class Platform(_Platform): generator=Generator, colors=COLORS, ) + _GUIPlatform.__init__(self) ############################################## # Constructors diff --git a/grc/python/Port.py b/grc/python/Port.py index a714844ef..33426d905 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ from .. base.Port import Port as _Port +from .. gui.Port import Port as _GUIPort import Constants def _get_source_from_virtual_sink_port(vsp): @@ -49,7 +50,7 @@ def _get_source_from_virtual_source_port(vsp, traversed=[]): ) except: raise Exception, 'Could not resolve source for virtual source port %s'%vsp -class Port(_Port): +class Port(_Port, _GUIPort): def __init__(self, block, n, dir): """ @@ -73,6 +74,7 @@ class Port(_Port): n=n, dir=dir, ) + _GUIPort.__init__(self) self._nports = n.find('nports') or '' self._vlen = n.find('vlen') or '' self._optional = bool(n.find('optional')) -- cgit From 30513fdc9afa3d8e9d4dce4214299d89aed3c409 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 2 Sep 2009 13:16:47 -0700 Subject: Removed the flagging api and usage from the base classes. Far better to flag the namespace for renewing once in the flowgraph.py --- grc/python/FlowGraph.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'grc/python') diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py index 96188b816..6b2936c75 100644 --- a/grc/python/FlowGraph.py +++ b/grc/python/FlowGraph.py @@ -32,8 +32,8 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): def __init__(self, **kwargs): _FlowGraph.__init__(self, **kwargs) _GUIFlowGraph.__init__(self) + self._eval_cache = dict() - _eval_cache = dict() def _eval(self, code, namespace, namespace_hash): """ Evaluate the code with the given namespace. @@ -114,6 +114,13 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): parameters = filter(lambda b: _parameter_matcher.match(b.get_key()), self.get_enabled_blocks()) return parameters + def rewrite(self): + """ + Flag the namespace to be renewed. + """ + self._renew_eval_ns = True + _FlowGraph.rewrite(self) + def evaluate(self, expr): """ Evaluate the expression. @@ -121,8 +128,8 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): @throw Exception bad expression @return the evaluated data """ - if self.is_flagged(): - self.deflag() + if self._renew_eval_ns: + self._renew_eval_ns = False #reload namespace n = dict() #load imports -- cgit From 56a58932701c981e55972ad994d397733edb8c75 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 2 Sep 2009 16:58:15 -0700 Subject: Evaluation fix in param.to_code(). Dont force an evaluation in to code unless the type is string or list. Not doing so forces the variables to call evaluate before the namespace was bootstrapped. This fixes a bug that came up when the validate was replaced with rewrite in flowgraph.import_data(). By replacing the validate, evaluate was only called once, and the namespace was not bootstrapped. --- grc/python/Param.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Param.py b/grc/python/Param.py index 17cfad051..e61779136 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -403,17 +403,18 @@ class Param(_Param, _GUIParam): def to_code(self): """ Convert the value to code. + For string and list types, check the init flag, call evaluate(). + This ensures that evaluate() was called to set the xxxify_flags. @return a string representing the code """ - #run init tasks in evaluate - #such as setting flags - if not self._init: self.evaluate() v = self.get_value() t = self.get_type() if t in ('string', 'file_open', 'file_save'): #string types + if not self._init: self.evaluate() if self._stringify_flag: return '"%s"'%v.replace('"', '\"') else: return v elif t in ('complex_vector', 'real_vector', 'int_vector'): #vector types + if not self._init: self.evaluate() if self._lisitify_flag: return '(%s, )'%v else: return '(%s)'%v else: return v -- cgit From 4cc3667b348d58ef4fb30f0ecbe494cdb109fc83 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 5 Sep 2009 00:54:56 -0700 Subject: better error msg for empty statements --- grc/python/FlowGraph.py | 1 + 1 file changed, 1 insertion(+) (limited to 'grc/python') diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py index 6b2936c75..4dd18a81f 100644 --- a/grc/python/FlowGraph.py +++ b/grc/python/FlowGraph.py @@ -42,6 +42,7 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): @param namespace_hash a unique hash for the namespace @return the resultant object """ + if not code: raise Exception, 'Cannot evaluate empty statement.' my_hash = hash(code) ^ namespace_hash #cache if does not exist if not self._eval_cache.has_key(my_hash): -- cgit From e39507bf32666f9b17d2249106aac0d6cbcacc58 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 6 Sep 2009 01:17:35 -0700 Subject: propsdialog tweaks --- grc/python/Param.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'grc/python') diff --git a/grc/python/Param.py b/grc/python/Param.py index e61779136..c64659a08 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -153,9 +153,9 @@ class Param(_Param, _GUIParam): dt_str = dt_str[:max_len-3] + '...' return dt_str - def get_input_class(self): - if self.get_type() in ('file_open', 'file_save'): return FileParam - return _GUIParam.get_input_class(self) + def get_input(self, *args, **kwargs): + if self.get_type() in ('file_open', 'file_save'): return FileParam(*args, **kwargs) + return _GUIParam.get_input(self, *args, **kwargs) def get_color(self): """ -- cgit From 6b1d8817a7fc6dd99a770cb11fac7ca48a3c81b0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 6 Sep 2009 01:58:25 -0700 Subject: Fixed the usrp and usrp2 probe scripts to work with the new gui param api. Also fixed the scripts to work since they were broken by previous changes. Get input in param class now pases a param instance (self) into the object. --- grc/python/Param.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grc/python') diff --git a/grc/python/Param.py b/grc/python/Param.py index c64659a08..387fab548 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -154,7 +154,7 @@ class Param(_Param, _GUIParam): return dt_str def get_input(self, *args, **kwargs): - if self.get_type() in ('file_open', 'file_save'): return FileParam(*args, **kwargs) + if self.get_type() in ('file_open', 'file_save'): return FileParam(self, *args, **kwargs) return _GUIParam.get_input(self, *args, **kwargs) def get_color(self): -- cgit From b8f69ad7ba49aa85239f6de611ddfd040344f66b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 8 Sep 2009 23:04:38 -0700 Subject: use show signal to perform initial gui update --- grc/python/Port.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grc/python') diff --git a/grc/python/Port.py b/grc/python/Port.py index 33426d905..6965371df 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -45,7 +45,7 @@ def _get_source_from_virtual_source_port(vsp, traversed=[]): lambda b: b.is_virtual_sink(), vsp.get_parent().get_parent().get_enabled_blocks(), ), - )[0].get_sink(vsp.get_key()) + )[0].get_sinks()[0] ), traversed + [vsp], ) except: raise Exception, 'Could not resolve source for virtual source port %s'%vsp -- cgit From 14895064d7345c2223ff2b8ff3b9cbcdf69dd8c9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 18 Sep 2009 02:10:13 -0700 Subject: added errors dialog to show all error messages in flow graph --- grc/python/Param.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grc/python') diff --git a/grc/python/Param.py b/grc/python/Param.py index 387fab548..1c1511315 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -254,7 +254,7 @@ class Param(_Param, _GUIParam): elif t in ('raw', 'complex', 'real', 'int', 'complex_vector', 'real_vector', 'int_vector', 'hex', 'bool'): #raise exception if python cannot evaluate this value try: e = self.get_parent().get_parent().evaluate(v) - except Exception, e: raise Exception, 'Value "%s" cannot be evaluated: %s'%(v, e) + except Exception, e: raise Exception, 'Value "%s" cannot be evaluated:\n%s'%(v, e) #raise an exception if the data is invalid if t == 'raw': return e elif t == 'complex': -- cgit From 54f913876e5d92fa66f4bcf3a1c773a503e907f8 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 18 Sep 2009 09:51:33 -0700 Subject: Re/evaluate the notebook blocks label because we dont garuntee the evaluation priority. Meaning, we cant garuntee that the notebook block will be evaluated before this param, without explicitly calling evaluate on it when the value is needed. --- grc/python/Param.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grc/python') diff --git a/grc/python/Param.py b/grc/python/Param.py index 1c1511315..34d5ab116 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -385,7 +385,7 @@ class Param(_Param, _GUIParam): try: notebook_block = filter(lambda b: b.get_id() == notebook_id, notebook_blocks)[0] except: raise Exception, 'Notebook id "%s" is not an existing notebook id.'%notebook_id #check that page index exists - try: assert int(page_index) in range(len(notebook_block.get_param('labels').get_evaluated())) + try: assert int(page_index) in range(len(notebook_block.get_param('labels').evaluate())) except: raise Exception, 'Page index "%s" is not a valid index number.'%page_index return notebook_id, page_index ######################### -- cgit