Ejemplo n.º 1
0
        def check_signal_exist(signal_name):
            """
            Return True if the signal_name python Class exist in signals package
            :param signal_name: Name of the neuron module to check
            :type signal_name: str
            :return:
            """
            sl = SettingLoader()
            settings = sl.settings
            package_name = "kalliope.signals" + "." + signal_name.lower(
            ) + "." + signal_name.lower()
            if settings.resources.signal_folder is not None:
                neuron_resource_path = settings.resources.neuron_folder + \
                                       os.sep + signal_name.lower() + os.sep + \
                                       signal_name.lower() + ".py"
                if os.path.exists(neuron_resource_path):
                    imp.load_source(signal_name.capitalize(),
                                    neuron_resource_path)
                    package_name = signal_name.capitalize()

            try:
                mod = __import__(package_name,
                                 fromlist=[signal_name.capitalize()])
                getattr(mod, signal_name.capitalize())
            except AttributeError:
                raise ModuleNotFoundError(
                    "[AttributeError] The module %s does not exist in the package %s "
                    % (signal_name.capitalize(), package_name))
            except ImportError:
                raise ModuleNotFoundError(
                    "[ImportError] The module %s does not exist in the package %s "
                    % (signal_name.capitalize(), package_name))
            return True
Ejemplo n.º 2
0
 def load_settings():
     """
     Return loaded kalliope settings
     :return: setting object
     """
     sl = SettingLoader()
     return sl.settings
Ejemplo n.º 3
0
 def start_neuron(cls, neuron):
     """
     Start a neuron plugin
     :param neuron: neuron object
     :type neuron: Neuron
     :return:
     """
     logger.debug("Run plugin \"%s\" with parameters %s" %
                  (neuron.name, neuron.parameters))
     sl = SettingLoader()
     settings = sl.settings
     neuron_folder = None
     if settings.resources:
         neuron_folder = settings.resources.neuron_folder
     return Utils.get_dynamic_class_instantiation(
         package_name="neurons",
         module_name=neuron.name,
         parameters=neuron.parameters,
         resources_dir=neuron_folder)
Ejemplo n.º 4
0
# coding: utf8
import logging

from kalliope.core.ConfigurationManager.BrainLoader import BrainLoader
from kalliope.core.ConfigurationManager.SettingLoader import SettingLoader

logging.basicConfig()
logger = logging.getLogger("kalliope")
logger.setLevel(logging.DEBUG)

# file_path = "core/Tests/brains/brain_test.yml"
#
# brainloader1 = BrainLoader.Instance(file_path=file_path)
#
# brainloader2 = BrainLoader.Instance(file_path=file_path)

sl = SettingLoader.Instance(file_path="core/Tests/settings/settings_test.yml")
print sl.yaml_config