mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Support modules system
[enh] List modules for adminjs
This commit is contained in:
parent
86a9debea7
commit
6749a96425
4 changed files with 47 additions and 6 deletions
|
@ -35,7 +35,7 @@
|
||||||
_global:
|
_global:
|
||||||
configuration:
|
configuration:
|
||||||
authenticate:
|
authenticate:
|
||||||
- api
|
- cli
|
||||||
authenticator:
|
authenticator:
|
||||||
default:
|
default:
|
||||||
vendor: ldap
|
vendor: ldap
|
||||||
|
@ -550,6 +550,14 @@ app:
|
||||||
apps:
|
apps:
|
||||||
nargs: "+"
|
nargs: "+"
|
||||||
|
|
||||||
|
#~ ### app_listmodules()
|
||||||
|
listmodules:
|
||||||
|
action_help: List all web admin modules
|
||||||
|
api: GET /modules
|
||||||
|
configuration:
|
||||||
|
authenticate:
|
||||||
|
authenticator: ldap-anonymous
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
# Backup #
|
# Backup #
|
||||||
#############################
|
#############################
|
||||||
|
|
11
app.py
11
app.py
|
@ -42,6 +42,7 @@ apps_path = '/usr/share/yunohost/apps'
|
||||||
apps_setting_path= '/etc/yunohost/apps/'
|
apps_setting_path= '/etc/yunohost/apps/'
|
||||||
install_tmp = '/var/cache/yunohost'
|
install_tmp = '/var/cache/yunohost'
|
||||||
app_tmp_folder = install_tmp + '/from_file'
|
app_tmp_folder = install_tmp + '/from_file'
|
||||||
|
modules_path = '/usr/share/yunohost/admin/modules/'
|
||||||
|
|
||||||
def app_listlists():
|
def app_listlists():
|
||||||
"""
|
"""
|
||||||
|
@ -950,6 +951,16 @@ def app_ssowatconf(auth):
|
||||||
|
|
||||||
msignals.display(m18n.n('ssowat_conf_generated'), 'success')
|
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):
|
def _extract_app_from_file(path, remove=False):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -51,5 +51,9 @@ if __name__ == '__main__':
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Execute the action
|
# 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)
|
sys.exit(ret)
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os.path
|
import os.path
|
||||||
|
import yaml
|
||||||
|
from os import listdir
|
||||||
|
from os.path import isfile, join
|
||||||
|
|
||||||
from_source = False
|
from_source = False
|
||||||
|
|
||||||
|
@ -28,6 +31,17 @@ def is_installed():
|
||||||
return { 'installed': 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
|
## Main action
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -47,9 +61,13 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Run the server
|
# Run the server
|
||||||
api(['yunohost'], port=6787,
|
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},
|
routes={('GET', '/installed'): is_installed},
|
||||||
use_cache=cache, use_websocket=websocket)
|
use_cache=False, use_websocket=websocket)
|
||||||
except MoulinetteError as e:
|
except MoulinetteError as e:
|
||||||
from moulinette.interfaces.cli import colorize
|
from moulinette.interfaces.cli import colorize
|
||||||
print('%s %s' % (colorize(m18n.g('error'), 'red'), e.strerror))
|
print('%s %s' % (colorize(m18n.g('error'), 'red'), e.strerror))
|
||||||
|
|
Loading…
Add table
Reference in a new issue