Açıklama Yok
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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 import logger
  27. from lodel.plugin import Plugin
  28. logger.debug("Loader.start() called")
  29. Plugin.load_all()
  30. LodelHook.call_hook('lodel2_bootstraped', '__main__', None)
  31. if __name__ == '__main__':
  32. start()
  33. if Settings.runtest:
  34. import unittest
  35. import tests
  36. loader = unittest.TestLoader()
  37. test_dir = os.path.join(LODEL2_LIB_ABS_PATH, 'tests')
  38. suite = loader.discover(test_dir)
  39. print("DEBUG : failfast = ", '-f' in sys.argv, sys.argv)
  40. runner = unittest.TextTestRunner(
  41. failfast = '-f' in sys.argv,
  42. verbosity = 2 if '-v' in sys.argv else 1)
  43. runner.run(suite)
  44. exit()
  45. import lodel
  46. import leapi_dyncode as dyncode
  47. lodel.dyncode = dyncode
  48. LodelHook.call_hook('lodel2_dyncode_bootstraped', '__main__', None)
  49. LodelHook.call_hook('lodel2_loader_main', '__main__', None)
  50. #Run interative python
  51. import code
  52. print("""
  53. Running interactive python in Lodel2 %s instance environment
  54. """%Settings.sitename)
  55. code.interact(local=locals())