mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Hook system bugfixes
This commit is contained in:
parent
41b90067e5
commit
37d87cad09
3 changed files with 18 additions and 24 deletions
|
@ -712,7 +712,7 @@ hook:
|
|||
api: GET /hook/check
|
||||
arguments:
|
||||
file:
|
||||
help: Script to check
|
||||
help: File to check
|
||||
|
||||
### hook_exec()
|
||||
exec:
|
||||
|
|
|
@ -652,12 +652,12 @@ def app_ssowatconf():
|
|||
if 'allowed_users' not in app_settings:
|
||||
app_settings['allowed_users'] = ''
|
||||
|
||||
apps[app] = {
|
||||
'domain': app_settings['domain'],
|
||||
'path': app_settings['path'],
|
||||
'mode': app_settings['mode'],
|
||||
'allowed_users': app_settings['allowed_users']
|
||||
}
|
||||
apps[app] = {
|
||||
'domain': app_settings['domain'],
|
||||
'path': app_settings['path'],
|
||||
'mode': app_settings['mode'],
|
||||
'allowed_users': app_settings['allowed_users']
|
||||
}
|
||||
|
||||
users = {}
|
||||
for user in user_list()['Users']:
|
||||
|
|
|
@ -67,27 +67,21 @@ def hook_check(file):
|
|||
Parse the script file and get arguments
|
||||
|
||||
Keyword argument:
|
||||
file -- Script to check
|
||||
file -- File to check
|
||||
|
||||
"""
|
||||
try:
|
||||
with open(file[:file.index('scripts/install')] + 'manifest.json') as f:
|
||||
manifest = json.loads(str(f.read()))
|
||||
except:
|
||||
raise YunoHostError(22, _("Invalid app package"))
|
||||
|
||||
with open(file, 'r') as conf:
|
||||
script_lines = conf.readlines()
|
||||
|
||||
in_block = False
|
||||
json_string = ""
|
||||
for line in script_lines:
|
||||
if re.search(r'^#### json"', line):
|
||||
in_block = True
|
||||
if in_block and re.search(r'^####', line):
|
||||
in_block = False
|
||||
elif re.search(r'^##[^#;]', line):
|
||||
json_string = json_string + line[2:]
|
||||
|
||||
if json_string == "":
|
||||
return {}
|
||||
action = file[file.index('scripts/') + 8:]
|
||||
if action in manifest["arguments"]:
|
||||
return manifest["arguments"][action]
|
||||
else:
|
||||
return json.loads(json_string)['arguments']
|
||||
return {}
|
||||
|
||||
|
||||
def hook_exec(file, args=None):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue