瀏覽代碼

update classes to use the new singleton

nico 8 年之前
父節點
當前提交
12d2da223b

+ 1 - 1
kalliope/__init__.py

@@ -61,7 +61,7 @@ def main():
     if args.brain_file:
     if args.brain_file:
         brain_file = args.brain_file
         brain_file = args.brain_file
     # load the brain once
     # load the brain once
-    brain_loader = BrainLoader.Instance(file_path=brain_file)
+    brain_loader = BrainLoader(file_path=brain_file)
     brain = brain_loader.brain
     brain = brain_loader.brain
 
 
     # check the user provide a valid action
     # check the user provide a valid action

+ 1 - 1
kalliope/core/ConfigurationManager/BrainLoader.py

@@ -15,11 +15,11 @@ logging.basicConfig()
 logger = logging.getLogger("kalliope")
 logger = logging.getLogger("kalliope")
 
 
 
 
-@Singleton
 class BrainLoader(object):
 class BrainLoader(object):
     """
     """
     This Class is used to get the brain YAML and the Brain as an object
     This Class is used to get the brain YAML and the Brain as an object
     """
     """
+    __metaclass__ = Singleton
 
 
     def __init__(self, file_path=None):
     def __init__(self, file_path=None):
         logger.debug("Loading brain with file path: %s" % file_path)
         logger.debug("Loading brain with file path: %s" % file_path)

+ 1 - 1
kalliope/core/ConfigurationManager/SettingLoader.py

@@ -42,11 +42,11 @@ class SettingNotFound(Exception):
     pass
     pass
 
 
 
 
-@Singleton
 class SettingLoader(object):
 class SettingLoader(object):
     """
     """
     This Class is used to get the Settings YAML and the Settings as an object
     This Class is used to get the Settings YAML and the Settings as an object
     """
     """
+    __metaclass__ = Singleton
 
 
     def __init__(self, file_path=None):
     def __init__(self, file_path=None):
         logger.debug("Loading settings with file path: %s" % file_path)
         logger.debug("Loading settings with file path: %s" % file_path)

+ 1 - 1
kalliope/core/MainController.py

@@ -24,7 +24,7 @@ class MainController:
     def __init__(self, brain=None):
     def __init__(self, brain=None):
         self.brain = brain
         self.brain = brain
         # get global configuration
         # get global configuration
-        sl = SettingLoader.Instance()
+        sl = SettingLoader()
         self.settings = sl.settings
         self.settings = sl.settings
 
 
         # run the api if the user want it
         # run the api if the user want it

+ 2 - 2
kalliope/core/NeuronModule.py

@@ -66,9 +66,9 @@ class NeuronModule(object):
         self.neuron_name = child_name
         self.neuron_name = child_name
         logger.debug("NeuronModule called from class %s with parameters: %s" % (child_name, str(kwargs)))
         logger.debug("NeuronModule called from class %s with parameters: %s" % (child_name, str(kwargs)))
 
 
-        sl = SettingLoader.Instance()
+        sl = SettingLoader()
         self.settings = sl.settings
         self.settings = sl.settings
-        brain_loader = BrainLoader.Instance()
+        brain_loader = BrainLoader()
         self.brain = brain_loader.brain
         self.brain = brain_loader.brain
 
 
         # check if the user has overrider the TTS
         # check if the user has overrider the TTS

+ 1 - 1
kalliope/core/OrderListener.py

@@ -39,7 +39,7 @@ class OrderListener(Thread):
         self._ignore_stderr()
         self._ignore_stderr()
         self.stt_module_name = stt
         self.stt_module_name = stt
         self.callback = callback
         self.callback = callback
-        sl = SettingLoader.Instance()
+        sl = SettingLoader()
         self.settings = sl.settings
         self.settings = sl.settings
 
 
     def run(self):
     def run(self):

+ 2 - 2
kalliope/core/RestAPI/utils.py

@@ -8,7 +8,7 @@ def check_auth(username, password):
     """This function is called to check if a username /
     """This function is called to check if a username /
     password combination is valid.
     password combination is valid.
     """
     """
-    sl = SettingLoader.Instance()
+    sl = SettingLoader()
     settings = sl.settings
     settings = sl.settings
     return username == settings.rest_api.login and password == settings.rest_api.password
     return username == settings.rest_api.login and password == settings.rest_api.password
 
 
@@ -24,7 +24,7 @@ def authenticate():
 def requires_auth(f):
 def requires_auth(f):
     @wraps(f)
     @wraps(f)
     def decorated(*args, **kwargs):
     def decorated(*args, **kwargs):
-        sl = SettingLoader.Instance()
+        sl = SettingLoader()
         settings = sl.settings
         settings = sl.settings
         if settings.rest_api.password_protected:
         if settings.rest_api.password_protected:
             auth = request.authorization
             auth = request.authorization

+ 1 - 1
kalliope/core/ShellGui.py

@@ -43,7 +43,7 @@ class ShellGui:
         self.brain = brain
         self.brain = brain
 
 
         # get settings
         # get settings
-        sl = SettingLoader.Instance()
+        sl = SettingLoader()
         self.settings = sl.settings
         self.settings = sl.settings
         locale.setlocale(locale.LC_ALL, '')
         locale.setlocale(locale.LC_ALL, '')
 
 

+ 1 - 1
kalliope/core/TTS/TTSModule.py

@@ -56,7 +56,7 @@ class TTSModule(object):
         self.base_cache_path = None
         self.base_cache_path = None
 
 
         # load settings
         # load settings
-        sl = SettingLoader.Instance()
+        sl = SettingLoader()
         self.settings = sl.settings
         self.settings = sl.settings
 
 
         # create the path in the tmp folder
         # create the path in the tmp folder

+ 1 - 1
kalliope/core/__init__.py

@@ -1,7 +1,7 @@
 from kalliope.core.OrderAnalyser import OrderAnalyser
 from kalliope.core.OrderAnalyser import OrderAnalyser
 from kalliope.core.OrderListener import OrderListener
 from kalliope.core.OrderListener import OrderListener
 from kalliope.core.ShellGui import ShellGui
 from kalliope.core.ShellGui import ShellGui
-from kalliope.core.Utils import Utils
+from kalliope.core.Utils.Utils import Utils
 from kalliope.core.Utils import FileManager
 from kalliope.core.Utils import FileManager
 
 
 
 

+ 1 - 1
kalliope/trigger/snowboy/snowboydetect.py

@@ -6,7 +6,7 @@
 from kalliope.core.ConfigurationManager import SettingLoader
 from kalliope.core.ConfigurationManager import SettingLoader
 from sys import version_info
 from sys import version_info
 
 
-sl = SettingLoader.Instance()
+sl = SettingLoader()
 settings = sl.settings
 settings = sl.settings
 module_file_path = "%s/_snowboydetect" % settings.machine
 module_file_path = "%s/_snowboydetect" % settings.machine