[enh] Look for and load additional YunoHost modules

This commit is contained in:
Jérôme Lebleu 2014-11-16 13:00:08 +01:00
parent 0375091769
commit 42b1189cd1
2 changed files with 23 additions and 2 deletions

View file

@ -123,6 +123,16 @@ def _init_moulinette():
# Initialize moulinette
init(logging_config=logging, _from_source=IN_DEVEL)
def _retrieve_namespaces():
"""Return the list of namespaces to load"""
from moulinette.actionsmap import ActionsMap
ret = ['yunohost']
for n in ActionsMap.get_namespaces():
# Append YunoHost modules
if n.startswith('ynh_'):
ret.append(n)
return ret
# Main action ----------------------------------------------------------
@ -146,5 +156,6 @@ if __name__ == '__main__':
# Execute the action
from moulinette import cli
ret = cli(['yunohost'], args, print_json=PRINT_JSON, use_cache=USE_CACHE)
ret = cli(_retrieve_namespaces(), args,
print_json=PRINT_JSON, use_cache=USE_CACHE)
sys.exit(ret)

View file

@ -123,6 +123,16 @@ def _init_moulinette():
# Initialize moulinette
init(logging_config=logging, _from_source=IN_DEVEL)
def _retrieve_namespaces():
"""Return the list of namespaces to load"""
from moulinette.actionsmap import ActionsMap
ret = ['yunohost']
for n in ActionsMap.get_namespaces():
# Append YunoHost modules
if n.startswith('ynh_'):
ret.append(n)
return ret
# Callbacks for additional routes --------------------------------------
@ -147,7 +157,7 @@ if __name__ == '__main__':
from moulinette import (api, MoulinetteError)
try:
# Run the server
api(['yunohost'], port=6787,
api(_retrieve_namespaces(), port=6787,
routes={('GET', '/installed'): is_installed},
use_cache=USE_CACHE, use_websocket=USE_WEBSOCKET)
except MoulinetteError as e: