mirror of
https://github.com/yweber/lodel2.git
synced 2025-10-21 16:49:02 +02:00
Updated instance admin script and Makefile to be able to run plugins discover + webui upgrade
This commit is contained in:
parent
29e825e6ce
commit
3395f76238
5 changed files with 57 additions and 16 deletions
|
@ -10,3 +10,6 @@ init_db: dyncode
|
|||
|
||||
list_hooks: dyncode
|
||||
$(python) -c 'import lodel_admin; lodel_admin.list_registered_hooks()'
|
||||
|
||||
discover_plugins:
|
||||
$(python) -c 'import lodel_admin; lodel_admin.update_plugin_discover_cache()'
|
||||
|
|
|
@ -1,30 +1,41 @@
|
|||
#-*- coding: utf-8 -*-
|
||||
|
||||
##@brief Lodel2 loader script
|
||||
#
|
||||
#@note If you want to avoid settings loading you can set the environment
|
||||
#variable LODEL2_NO_SETTINGS_LOAD (see @ref install.lodel_admin.update_plugin_discover_cache()
|
||||
#
|
||||
|
||||
import sys, os, os.path
|
||||
#
|
||||
# Bootstraping
|
||||
#
|
||||
LODEL2_LIB_ABS_PATH = None
|
||||
if LODEL2_LIB_ABS_PATH is not None:
|
||||
if not os.path.isdir(LODEL2_LIB_ABS_PATH):
|
||||
print("FATAL ERROR : the LODEL2_LIB_ABS_PATH variable in loader.py is \
|
||||
not correct : '%s'" % LODEL2_LIB_ABS_PATH, file=sys.stderr)
|
||||
sys.path.append(os.path.dirname(LODEL2_LIB_ABS_PATH))
|
||||
|
||||
try:
|
||||
import lodel
|
||||
except ImportError:
|
||||
except ImportError as e:
|
||||
print("Unable to load lodel module. exiting...")
|
||||
print(e)
|
||||
exit(1)
|
||||
|
||||
#
|
||||
# Loading settings
|
||||
#
|
||||
from lodel.settings.settings import Settings as settings
|
||||
if not settings.started():
|
||||
settings('conf.d')
|
||||
from lodel.settings import Settings
|
||||
if 'LODEL2_NO_SETTINGS_LOAD' not in os.environ:
|
||||
#
|
||||
# Loading settings
|
||||
#
|
||||
from lodel.settings.settings import Settings as settings
|
||||
if not settings.started():
|
||||
settings('conf.d')
|
||||
from lodel.settings import Settings
|
||||
|
||||
#Starts hooks
|
||||
from lodel.plugin import LodelHook
|
||||
from lodel.plugin import core_hooks
|
||||
#Starts hooks
|
||||
from lodel.plugin import LodelHook
|
||||
from lodel.plugin import core_hooks
|
||||
|
||||
def start():
|
||||
#Load plugins
|
||||
|
|
|
@ -2,10 +2,16 @@
|
|||
|
||||
import sys
|
||||
import os, os.path
|
||||
import loader
|
||||
import argparse
|
||||
|
||||
from lodel.settings import Settings
|
||||
from lodel import logger
|
||||
"""
|
||||
#Dirty hack to solve symlinks problems :
|
||||
# When loader was imported the original one (LODEL_LIBDIR/install/loader)
|
||||
# because lodel_admin.py is a symlink from this folder
|
||||
#Another solution can be delete loader from install folder
|
||||
sys.path[0] = os.getcwd()
|
||||
import loader
|
||||
"""
|
||||
|
||||
## @brief Utility method to generate python code given an emfile and a
|
||||
# translator
|
||||
|
@ -27,6 +33,7 @@ def generate_dyncode(model_file, translator):
|
|||
# @param translator str : a translator name
|
||||
# @param output_filename str : the output file
|
||||
def create_dyncode(model_file, translator, output_filename):
|
||||
from lodel import logger
|
||||
dyncode = generate_dyncode(model_file, translator)
|
||||
with open(output_filename, 'w+') as out_fd:
|
||||
out_fd.write(dyncode)
|
||||
|
@ -36,6 +43,8 @@ def create_dyncode(model_file, translator, output_filename):
|
|||
|
||||
## @brief Refresh dynamic leapi code from settings
|
||||
def refresh_dyncode():
|
||||
import loader
|
||||
from lodel.settings import Settings
|
||||
# EditorialModel update/refresh
|
||||
|
||||
# TODO
|
||||
|
@ -120,3 +129,16 @@ def list_registered_hooks():
|
|||
print(msg)
|
||||
print("\n")
|
||||
|
||||
##@brief update plugin's discover cache
|
||||
#@note impossible to give arguments from a Makefile...
|
||||
#@todo write a __main__ to be able to run ./lodel_admin
|
||||
def update_plugin_discover_cache(path_list = None):
|
||||
os.environ['LODEL2_NO_SETTINGS_LOAD'] = 'True'
|
||||
import loader
|
||||
from lodel.plugin.plugins import Plugin
|
||||
res = Plugin.discover(path_list)
|
||||
print("Plugin discover result in %s :\n" % res['path_list'])
|
||||
for pname, pinfos in res['plugins'].items():
|
||||
print("\t- %s %s -> %s" % (
|
||||
pname, pinfos['version'], pinfos['path']))
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ MANDATORY_VARNAMES = [PLUGIN_NAME_VARNAME, LOADER_FILENAME_VARNAME,
|
|||
PLUGIN_VERSION_VARNAME]
|
||||
|
||||
PLUGIN_DEFAULT_TYPE = 'default'
|
||||
PLUGINS_TYPES = [PLUGIN_DEFAULT_TYPE, 'datasource', 'session_handler']
|
||||
PLUGINS_TYPES = [PLUGIN_DEFAULT_TYPE, 'datasource', 'session_handler', 'ui']
|
||||
|
||||
|
||||
##@brief Describe and handle version numbers
|
||||
|
@ -529,7 +529,9 @@ name differ from the one found in plugin's init file"
|
|||
#found plugin in a file...
|
||||
#@return a dict {'path_list': [...], 'plugins': { see @ref _discover }}
|
||||
@classmethod
|
||||
def discover(cls, paths):
|
||||
def discover(cls, paths = None):
|
||||
if paths is None:
|
||||
paths = DEFAULT_PLUGINS_PATH_LIST
|
||||
tmp_res = []
|
||||
for path in paths:
|
||||
tmp_res += cls._discover(path)
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
__plugin_name__ = 'webui'
|
||||
__version__ = '0.0.1'
|
||||
__type__ = 'ui'
|
||||
__loader__ = 'main.py'
|
||||
__confspec__ = 'confspec.py'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue