[enh] Support modules system

[enh] List modules for adminjs
This commit is contained in:
zamentur 2014-11-03 21:29:59 +01:00
parent 86a9debea7
commit 6749a96425
4 changed files with 47 additions and 6 deletions

View file

@ -35,7 +35,7 @@
_global:
configuration:
authenticate:
- api
- cli
authenticator:
default:
vendor: ldap
@ -550,6 +550,14 @@ app:
apps:
nargs: "+"
#~ ### app_listmodules()
listmodules:
action_help: List all web admin modules
api: GET /modules
configuration:
authenticate:
authenticator: ldap-anonymous
#############################
# Backup #
#############################

13
app.py
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():
"""
@ -950,7 +951,17 @@ 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

View file

@ -51,5 +51,9 @@ if __name__ == '__main__':
sys.exit(1)
# Execute the action
ret = cli(['yunohost'], args, print_json=json, use_cache=cache)
from os import listdir
from os.path import isfile, join
path='/usr/share/moulinette/actionsmap/'
modules = [ f[:-4] for f in listdir(path) if isfile(join(path,f))]
ret = cli(modules, args, print_json=json, use_cache=cache)
sys.exit(ret)

View file

@ -3,6 +3,9 @@
import sys
import os.path
import yaml
from os import listdir
from os.path import isfile, join
from_source = False
@ -28,6 +31,17 @@ def is_installed():
return { 'installed': installed }
def _get_modules():
"""
Get a dict of managed services with their parameters
"""
from os import listdir
from os.path import isfile, join
path='/usr/share/moulinette/actionsmap/'
onlyfiles = [ f[:-4] for f in listdir(path) if isfile(join(path,f))]
return onlyfiles
## Main action
if __name__ == '__main__':
@ -46,10 +60,14 @@ if __name__ == '__main__':
# TODO: Add log argument
try:
# Run the server
api(['yunohost'], port=6787,
# Run the server
from os import listdir
from os.path import isfile, join
path='/usr/share/moulinette/actionsmap/'
modules = [ f[:-4] for f in listdir(path) if isfile(join(path,f))]
api(modules, port=6787,
routes={('GET', '/installed'): is_installed},
use_cache=cache, use_websocket=websocket)
use_cache=False, use_websocket=websocket)
except MoulinetteError as e:
from moulinette.interfaces.cli import colorize
print('%s %s' % (colorize(m18n.g('error'), 'red'), e.strerror))