No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

loader.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #-*- coding: utf-8 -*-
  2. import sys, os, os.path
  3. #
  4. # Bootstraping
  5. #
  6. LODEL2_LIB_ABS_PATH = None
  7. if LODEL2_LIB_ABS_PATH is not None:
  8. sys.path.append(os.path.dirname(LODEL2_LIB_ABS_PATH))
  9. try:
  10. import lodel
  11. except ImportError:
  12. print("Unable to load lodel module. exiting...")
  13. exit(1)
  14. #
  15. # Loading settings
  16. #
  17. from lodel.settings.settings import Settings as settings
  18. if not settings.started():
  19. settings('conf.d')
  20. from lodel.settings import Settings
  21. #Starts hooks
  22. from lodel.plugin import LodelHook
  23. from lodel.plugin import core_hooks
  24. def start():
  25. #Load plugins
  26. from lodel.plugin import Plugin
  27. Plugin.load_all()
  28. LodelHook.call_hook('lodel2_bootstraped', '__main__', None)
  29. if __name__ == '__main__':
  30. start()
  31. if Settings.runtest:
  32. import unittest
  33. import tests
  34. loader = unittest.TestLoader()
  35. test_dir = os.path.join(LODEL2_LIB_ABS_PATH, 'tests')
  36. suite = loader.discover(test_dir)
  37. print("DEBUG : failfast = ", '-f' in sys.argv, sys.argv)
  38. runner = unittest.TextTestRunner(
  39. failfast = '-f' in sys.argv,
  40. verbosity = 2 if '-v' in sys.argv else 1)
  41. runner.run(suite)
  42. exit()
  43. LodelHook.call_hook('lodel2_loader_main', '__main__', None)
  44. #Run interative python
  45. import code
  46. print("""
  47. Running interactive python in Lodel2 %s instance environment
  48. """%Settings.sitename)
  49. code.interact(local=locals())