From 341ce8d31723983f54f41f01ea63d2358c010e62 Mon Sep 17 00:00:00 2001 From: zamentur Date: Sun, 22 Feb 2015 19:00:02 +0100 Subject: [PATCH] [enh] An api to list modules in /usr/share/yunohost/admin/modules/ which doesn't need authentication --- data/actionsmap/yunohost.yml | 6 ++++++ lib/yunohost/app.py | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 389a32581..c0e256620 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -538,6 +538,12 @@ app: apps: nargs: "+" + ### app_listmodules() + listmodules: + action_help: List all web admin modules + api: GET /modules + configuration: + authenticate: False ############################# # Backup # ############################# diff --git a/lib/yunohost/app.py b/lib/yunohost/app.py index 262fd5711..813783e11 100644 --- a/lib/yunohost/app.py +++ b/lib/yunohost/app.py @@ -42,6 +42,7 @@ apps_path = '/usr/share/yunohost/apps' apps_setting_path= '/etc/yunohost/apps/' install_tmp = '/var/cache/yunohost' app_tmp_folder = install_tmp + '/from_file' +modules_path = '/usr/share/yunohost/admin/modules/' def app_listlists(): """ @@ -954,6 +955,18 @@ def app_ssowatconf(auth): msignals.display(m18n.n('ssowat_conf_generated'), 'success') +def app_listmodules(): + """ + List all modules set up in modules directory + /usr/share/yunohost/admin/modules/ + """ + try: + modules=os.walk(modules_path).next()[1] #[x[0] for x in os.walk(modules_path)] + except OSError: + modules = [] + return { 'modules' : modules } + + def _extract_app_from_file(path, remove=False): """ Unzip or untar application tarball in app_tmp_folder, or copy it from a directory