TriggerModule.py 1.0 KB

123456789101112131415161718192021222324252627282930
  1. import logging
  2. from kalliope.core.Utils import Utils
  3. logging.basicConfig()
  4. logger = logging.getLogger("kalliope")
  5. class TriggerModule(object):
  6. """
  7. Mother class of a trigger object
  8. """
  9. def __init__(self):
  10. super(TriggerModule, self).__init__()
  11. @staticmethod
  12. def get_file_from_path(file_path):
  13. """
  14. Trigger can be based on a model file, or other file.
  15. If a file is precised in settings, the path can be relative or absolute.
  16. If the path is absolute, there is no problem when can try to load it directly
  17. If the path is relative, we need to test the get the full path of the file in the following order:
  18. - from the current directory where kalliope has been called. Eg: /home/me/Documents/kalliope_config
  19. - from /etc/kalliope
  20. - from the root of the project. Eg: /usr/local/lib/python2.7/dist-packages/kalliope-version/kalliope/<file_path>
  21. :return: absolute path
  22. """
  23. return Utils.get_real_file_path(file_path)