[enh] An api to list modules in /usr/share/yunohost/admin/modules/ which doesn't need authentication

This commit is contained in:
zamentur 2015-02-22 19:00:02 +01:00
parent 219e5c83a4
commit 341ce8d317
2 changed files with 19 additions and 0 deletions

View file

@ -538,6 +538,12 @@ app:
apps:
nargs: "+"
### app_listmodules()
listmodules:
action_help: List all web admin modules
api: GET /modules
configuration:
authenticate: False
#############################
# Backup #
#############################

View file

@ -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