commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11247 - gnuradio/branches/developers/jblum/grc/grc/ba


From: jblum
Subject: [Commit-gnuradio] r11247 - gnuradio/branches/developers/jblum/grc/grc/base
Date: Sat, 20 Jun 2009 00:25:20 -0600 (MDT)

Author: jblum
Date: 2009-06-20 00:25:20 -0600 (Sat, 20 Jun 2009)
New Revision: 11247

Modified:
   gnuradio/branches/developers/jblum/grc/grc/base/Block.py
   gnuradio/branches/developers/jblum/grc/grc/base/Element.py
   gnuradio/branches/developers/jblum/grc/grc/base/Param.py
   gnuradio/branches/developers/jblum/grc/grc/base/Platform.py
Log:
replaced exit_with_error with exceptions and warning messages

Modified: gnuradio/branches/developers/jblum/grc/grc/base/Block.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/base/Block.py    2009-06-20 
05:54:59 UTC (rev 11246)
+++ gnuradio/branches/developers/jblum/grc/grc/base/Block.py    2009-06-20 
06:25:20 UTC (rev 11247)
@@ -89,8 +89,8 @@
                for param in map(lambda n: 
self.get_parent().get_parent().Param(self, n), params):
                        key = param.get_key()
                        #test against repeated keys
-                       try: assert(key not in self.get_param_keys())
-                       except AssertionError: self._exit_with_error('Key "%s" 
already exists in params'%key)
+                       try: assert key not in self.get_param_keys()
+                       except AssertionError: raise Exception, 'Key "%s" 
already exists in params'%key
                        #store the param
                        self._params[key] = param
                #create the source objects
@@ -98,8 +98,8 @@
                for source in map(lambda n: 
self.get_parent().get_parent().Source(self, n), sources):
                        key = source.get_key()
                        #test against repeated keys
-                       try: assert(key not in self.get_source_keys())
-                       except AssertionError: self._exit_with_error('Key "%s" 
already exists in sources'%key)
+                       try: assert key not in self.get_source_keys()
+                       except AssertionError: raise Exception, 'Key "%s" 
already exists in sources'%key
                        #store the port
                        self._sources[key] = source
                #create the sink objects
@@ -107,8 +107,8 @@
                for sink in map(lambda n: 
self.get_parent().get_parent().Sink(self, n), sinks):
                        key = sink.get_key()
                        #test against repeated keys
-                       try: assert(key not in self.get_sink_keys())
-                       except AssertionError: self._exit_with_error('Key "%s" 
already exists in sinks'%key)
+                       try: assert key not in self.get_sink_keys()
+                       except AssertionError: raise Exception, 'Key "%s" 
already exists in sinks'%key
                        #store the port
                        self._sinks[key] = sink
                #begin the testing

Modified: gnuradio/branches/developers/jblum/grc/grc/base/Element.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/base/Element.py  2009-06-20 
05:54:59 UTC (rev 11246)
+++ gnuradio/branches/developers/jblum/grc/grc/base/Element.py  2009-06-20 
06:25:20 UTC (rev 11247)
@@ -42,20 +42,6 @@
 
        def get_parent(self): return self._parent
 
-       def _exit_with_error(self, error):
-               parent = self
-               #build hier list of elements
-               elements = list()
-               while(parent):
-                       elements.insert(0, parent)
-                       parent = parent.get_parent()
-               #build error string
-               err_str = ">>> Error:"
-               for i, element in enumerate(elements + [error]):
-                       err_str = err_str + '\n' + ''.join('   '*(i+2)) + 
str(element)
-               err_str = err_str + '\n'
-               exit(err_str)
-
        ##############################################
        ## Update flagging
        ##############################################

Modified: gnuradio/branches/developers/jblum/grc/grc/base/Param.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/base/Param.py    2009-06-20 
05:54:59 UTC (rev 11246)
+++ gnuradio/branches/developers/jblum/grc/grc/base/Param.py    2009-06-20 
06:25:20 UTC (rev 11247)
@@ -98,15 +98,15 @@
                opts = n.findall('opt')
                #test against opts when non enum
                try: assert self.get_parent().is_enum() or not opts
-               except AssertionError: self._exit_with_error('Options for 
non-enum types cannot have sub-options')
+               except AssertionError: raise Exception, 'Options for non-enum 
types cannot have sub-options'
                #extract opts
                for opt in opts:
                        #separate the key:value
                        try: key, value = opt.split(':')
-                       except: self._exit_with_error('Error separating "%s" 
into key:value'%opt)
+                       except: raise Exception, 'Error separating "%s" into 
key:value'%opt
                        #test against repeated keys
                        try: assert not self._opts.has_key(key)
-                       except AssertionError: self._exit_with_error('Key "%s" 
already exists in option'%key)
+                       except AssertionError: raise Exception, 'Key "%s" 
already exists in option'%key
                        #store the option
                        self._opts[key] = value
 
@@ -146,24 +146,24 @@
                for option in map(lambda o: Option(self, o), 
n.findall('option')):
                        key = option.get_key()
                        #test against repeated keys
-                       try: assert(key not in self.get_option_keys())
-                       except AssertionError: self._exit_with_error('Key "%s" 
already exists in options'%key)
+                       try: assert key not in self.get_option_keys()
+                       except AssertionError: raise Exception, 'Key "%s" 
already exists in options'%key
                        #store the option
                        self._options[key] = option
                #test the enum options
                if self.is_enum():
                        #test against options with identical keys
-                       try: assert(len(set(self.get_option_keys())) == 
len(self._options))
-                       except AssertionError: self._exit_with_error('Options 
keys "%s" are not unique.'%self.get_option_keys())
+                       try: assert len(set(self.get_option_keys())) == 
len(self._options)
+                       except AssertionError: raise Exception, 'Options keys 
"%s" are not unique.'%self.get_option_keys()
                        #test against inconsistent keys in options
                        opt_keys = self._options.values()[0].get_opt_keys()
                        for option in self._options.values():
-                               try: assert(set(opt_keys) == 
set(option.get_opt_keys()))
-                               except AssertionError: 
self._exit_with_error('Opt keys "%s" are not identical across all 
options.'%opt_keys)
+                               try: assert set(opt_keys) == 
set(option.get_opt_keys())
+                               except AssertionError: raise Exception, 'Opt 
keys "%s" are not identical across all options.'%opt_keys
                        #if a value is specified, it must be in the options keys
                        self._value = value or self.get_option_keys()[0]
-                       try: assert(self.get_value() in self.get_option_keys())
-                       except AssertionError: self._exit_with_error('The value 
"%s" is not in the possible values of "%s".'%(self.get_value(), 
self.get_option_keys()))
+                       try: assert self.get_value() in self.get_option_keys()
+                       except AssertionError: raise Exception, 'The value "%s" 
is not in the possible values of "%s".'%(self.get_value(), 
self.get_option_keys())
                else: self._value = value or ''
 
        def test(self):

Modified: gnuradio/branches/developers/jblum/grc/grc/base/Platform.py
===================================================================
--- gnuradio/branches/developers/jblum/grc/grc/base/Platform.py 2009-06-20 
05:54:59 UTC (rev 11246)
+++ gnuradio/branches/developers/jblum/grc/grc/base/Platform.py 2009-06-20 
06:25:20 UTC (rev 11247)
@@ -84,6 +84,8 @@
                                        self._block_tree_files.append(xml_file)
                                except ParseXML.XMLSyntaxError, e:
                                        print >> sys.stderr, 'Warning: Block 
validation failed:\n\t%s\n\tIgnoring: %s'%(e, xml_file)
+                       except Exception, e:
+                               print >> sys.stderr, 'Warning: Block loading 
failed:\n\t%s\n\tIgnoring: %s'%(e, xml_file)
 
        def parse_flow_graph(self, flow_graph_file):
                """





reply via email to

[Prev in Thread] Current Thread [Next in Thread]