Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

loader.py 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #-*- coding: utf-8 -*-
  2. ##@brief Lodel2 loader script
  3. #
  4. #@note If you want to avoid settings loading you can set the environment
  5. #variable LODEL2_NO_SETTINGS_LOAD (see @ref install.lodel_admin.update_plugin_discover_cache()
  6. #
  7. import sys, os, os.path
  8. #
  9. # Bootstraping
  10. #
  11. LODEL2_LIB_ABS_PATH = None
  12. if LODEL2_LIB_ABS_PATH is not None:
  13. if not os.path.isdir(LODEL2_LIB_ABS_PATH):
  14. print("FATAL ERROR : the LODEL2_LIB_ABS_PATH variable in loader.py is \
  15. not correct : '%s'" % LODEL2_LIB_ABS_PATH, file=sys.stderr)
  16. sys.path.append(os.path.dirname(LODEL2_LIB_ABS_PATH))
  17. try:
  18. import lodel
  19. except ImportError as e:
  20. print("Unable to load lodel module. exiting...")
  21. print(e)
  22. exit(1)
  23. if 'LODEL2_NO_SETTINGS_LOAD' not in os.environ:
  24. #
  25. # Loading settings
  26. #
  27. from lodel.settings.settings import Settings as settings
  28. if not settings.started():
  29. settings('conf.d')
  30. from lodel.settings import Settings
  31. #Starts hooks
  32. from lodel.plugin import LodelHook
  33. from lodel.plugin import core_hooks
  34. def start():
  35. #Load plugins
  36. from lodel import logger
  37. from lodel.plugin import Plugin
  38. logger.debug("Loader.start() called")
  39. Plugin.load_all()
  40. LodelHook.call_hook('lodel2_bootstraped', '__main__', None)
  41. if __name__ == '__main__':
  42. start()
  43. if Settings.runtest:
  44. import unittest
  45. import tests
  46. loader = unittest.TestLoader()
  47. test_dir = os.path.join(LODEL2_LIB_ABS_PATH, 'tests')
  48. suite = loader.discover(test_dir)
  49. print("DEBUG : failfast = ", '-f' in sys.argv, sys.argv)
  50. runner = unittest.TextTestRunner(
  51. failfast = '-f' in sys.argv,
  52. verbosity = 2 if '-v' in sys.argv else 1)
  53. runner.run(suite)
  54. exit()
  55. import lodel
  56. import leapi_dyncode as dyncode
  57. lodel.dyncode = dyncode
  58. LodelHook.call_hook('lodel2_dyncode_bootstraped', '__main__', None)
  59. LodelHook.call_hook('lodel2_loader_main', '__main__', None)
  60. #Run interative python
  61. import code
  62. print("""
  63. Running interactive python in Lodel2 %s instance environment
  64. """%Settings.sitename)
  65. code.interact(local=locals())