Browse Source

skip failled neuron #357

nico 7 years ago
parent
commit
d0d751bf3e

+ 2 - 0
kalliope/core/NeuronExceptions.py

@@ -0,0 +1,2 @@
+class NeuronExceptions(Exception):
+    pass

+ 8 - 2
kalliope/core/NeuronLauncher.py

@@ -5,6 +5,7 @@ import six
 
 from kalliope.core.ConfigurationManager.SettingLoader import SettingLoader
 from kalliope.core.Cortex import Cortex
+from kalliope.core.NeuronExceptions import NeuronExceptions
 from kalliope.core.Utils.Utils import Utils
 
 logging.basicConfig()
@@ -52,9 +53,14 @@ class NeuronLauncher:
             try:
                 neuron.parameters = cls._replace_brackets_by_loaded_parameter(neuron.parameters, parameters_dict)
             except NeuronParameterNotAvailable:
-                Utils.print_danger("The neuron %s cannot be launched" % neuron.name)
+                Utils.print_danger("Missing parameter in neuron %s. Execution skipped" % neuron.name)
                 return None
-        instantiated_neuron = NeuronLauncher.launch_neuron(neuron)
+        try:
+            instantiated_neuron = NeuronLauncher.launch_neuron(neuron)
+        except NeuronExceptions:
+            Utils.print_danger("ERROR: Fail to execute neuron '%s'. Missing or invalid parameter(s). Execution skipped"
+                               % neuron.name)
+            return None
         return instantiated_neuron
 
     @classmethod

+ 3 - 2
kalliope/core/NeuronModule.py

@@ -11,6 +11,7 @@ from kalliope.core.ConfigurationManager import SettingLoader, BrainLoader
 from kalliope.core.Cortex import Cortex
 from kalliope.core.LIFOBuffer import LIFOBuffer
 from kalliope.core.Models.MatchedSynapse import MatchedSynapse
+from kalliope.core.NeuronExceptions import NeuronExceptions
 from kalliope.core.OrderAnalyser import OrderAnalyser
 from kalliope.core.Utils.RpiUtils import RpiUtils
 from kalliope.core.Utils.Utils import Utils
@@ -19,14 +20,14 @@ logging.basicConfig()
 logger = logging.getLogger("kalliope")
 
 
-class InvalidParameterException(Exception):
+class InvalidParameterException(NeuronExceptions):
     """
     Some Neuron parameters are invalid.
     """
     pass
 
 
-class MissingParameterException(Exception):
+class MissingParameterException(NeuronExceptions):
     """
     Some Neuron parameters are missing.
     """

+ 0 - 3
kalliope/core/ShellGui.py

@@ -2,15 +2,12 @@
 
 import locale
 import logging
-import signal
-import sys
 
 from dialog import Dialog
 
 from kalliope.core import OrderListener
 from kalliope.core.ConfigurationManager import SettingLoader
 from kalliope.core.SynapseLauncher import SynapseLauncher
-from kalliope.core.Utils.Utils import Utils
 from kalliope.neurons.say.say import Say
 
 logging.basicConfig()