From 42b1189cd11f794afff6c7f53d8717d6c372f57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Sun, 16 Nov 2014 13:00:08 +0100 Subject: [PATCH] [enh] Look for and load additional YunoHost modules --- bin/yunohost | 13 ++++++++++++- bin/yunohost-api | 12 +++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/bin/yunohost b/bin/yunohost index 84f7d5a29..b24fffb77 100755 --- a/bin/yunohost +++ b/bin/yunohost @@ -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) diff --git a/bin/yunohost-api b/bin/yunohost-api index dda606cfb..a15ba4f34 100755 --- a/bin/yunohost-api +++ b/bin/yunohost-api @@ -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: