Răsfoiți Sursa

fix unicode str in debug

nico 8 ani în urmă
părinte
comite
780024d946
2 a modificat fișierele cu 22 adăugiri și 19 ștergeri
  1. 21 18
      kalliope/core/LIFOBuffer.py
  2. 1 1
      kalliope/core/NeuronLauncher.py

+ 21 - 18
kalliope/core/LIFOBuffer.py

@@ -172,22 +172,25 @@ class LIFOBuffer(object):
 
 
             # the status of an execution is "complete" if no neuron are waiting for an answer
             # the status of an execution is "complete" if no neuron are waiting for an answer
             cls.api_response.status = "complete"
             cls.api_response.status = "complete"
-            if instantiated_neuron.is_waiting_for_answer:  # the neuron is waiting for an answer
-                logger.debug("[LIFOBuffer] Wait for answer mode")
-                cls.api_response.status = "waiting_for_answer"
-                raise Serialize
+            if instantiated_neuron is not None:
+                if instantiated_neuron.is_waiting_for_answer:  # the neuron is waiting for an answer
+                    logger.debug("[LIFOBuffer] Wait for answer mode")
+                    cls.api_response.status = "waiting_for_answer"
+                    raise Serialize
+                else:
+                    logger.debug("[LIFOBuffer] complete mode")
+                    # we add the instantiated neuron to the neuron_module_list.
+                    # This one contains info about generated text
+                    matched_synapse.neuron_module_list.append(instantiated_neuron)
+                    # the neuron is fully processed we can remove it from the list
+                    matched_synapse.neuron_fifo_list.remove(neuron)
+
+                if instantiated_neuron.pending_synapse:  # the last executed neuron want to run a synapse
+                    logger.debug("[LIFOBuffer] Last executed neuron want to run a synapse. Restart the LIFO")
+                    # add the synapse to the lifo (inside a list as expected by the lifo)
+                    cls.add_synapse_list_to_lifo([instantiated_neuron.pending_synapse])
+                    # we have added a list of synapse to the LIFO ! this one must start over.
+                    # break all while loop until the execution is back to the LIFO loop
+                    raise SynapseListAddedToLIFO
             else:
             else:
-                logger.debug("[LIFOBuffer] complete mode")
-                # we add the instantiated neuron to the neuron_module_list.
-                # This one contains info about generated text
-                matched_synapse.neuron_module_list.append(instantiated_neuron)
-                # the neuron is fully processed we can remove it from the list
-                matched_synapse.neuron_fifo_list.remove(neuron)
-
-            if instantiated_neuron.pending_synapse:  # the last executed neuron want to run a synapse
-                logger.debug("[LIFOBuffer] Last executed neuron want to run a synapse. Restart the LIFO")
-                # add the synapse to the lifo (inside a list as expected by the lifo)
-                cls.add_synapse_list_to_lifo([instantiated_neuron.pending_synapse])
-                # we have added a list of synapse to the LIFO ! this one must start over.
-                # break all while loop until the execution is back to the LIFO loop
-                raise SynapseListAddedToLIFO
+                raise Serialize

+ 1 - 1
kalliope/core/NeuronLauncher.py

@@ -65,7 +65,7 @@ class NeuronLauncher:
         :param neuron_parameters: value to instantiate. Str or dict or list
         :param neuron_parameters: value to instantiate. Str or dict or list
         :param loaded_parameters: dict of parameters
         :param loaded_parameters: dict of parameters
         """
         """
-        logger.debug("[NeuronLauncher] replacing brackets from %s, using %s" % (str(neuron_parameters),str(loaded_parameters)))
+        logger.debug("[NeuronLauncher] replacing brackets from %s, using %s" % (neuron_parameters, loaded_parameters))
         if isinstance(neuron_parameters, str) or isinstance(neuron_parameters, unicode):
         if isinstance(neuron_parameters, str) or isinstance(neuron_parameters, unicode):
             # replace bracket parameter only if the str contains brackets
             # replace bracket parameter only if the str contains brackets
             if Utils.is_containing_bracket(neuron_parameters):
             if Utils.is_containing_bracket(neuron_parameters):