mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
API bugfixes
This commit is contained in:
parent
655550ec6b
commit
ba0cc75db3
1 changed files with 34 additions and 27 deletions
33
yunohost.tac
33
yunohost.tac
|
@ -167,9 +167,15 @@ def favicon(request):
|
|||
request.setResponseCode(404, 'Not Found')
|
||||
return ''
|
||||
|
||||
def is_installed(request):
|
||||
request.setHeader('Access-Control-Allow-Origin', '*') # Allow cross-domain requests
|
||||
request.setResponseCode(200, 'OK')
|
||||
return json.dumps({ 'installed': installed })
|
||||
|
||||
def main():
|
||||
global action_dict
|
||||
global api
|
||||
global installed
|
||||
|
||||
# Generate API doc
|
||||
os.system('python ./generate_api_doc.py')
|
||||
|
@ -180,6 +186,19 @@ def main():
|
|||
# favicon.ico error
|
||||
api.register('ALL', '/favicon.ico', favicon)
|
||||
|
||||
# Register only postinstall action if YunoHost isn't completely set up
|
||||
try:
|
||||
with open('/etc/yunohost/installed') as f: pass
|
||||
except IOError:
|
||||
installed = False
|
||||
api.register('POST', '/postinstall', http_exec)
|
||||
api.register('OPTIONS', '/postinstall', http_exec)
|
||||
action_dict['POST /postinstall'] = {
|
||||
'function' : 'yunohost_tools.tools_postinstall',
|
||||
'help' : 'Execute post-install',
|
||||
'arguments' : action_map['tools']['postinstall']['arguments']
|
||||
}
|
||||
else:
|
||||
# Load & parse yaml file
|
||||
with open('action_map.yml') as f:
|
||||
action_map = yaml.load(f)
|
||||
|
@ -205,20 +224,8 @@ def main():
|
|||
if 'arguments' in action_params:
|
||||
action_dict[action_params['api']]['arguments'] = action_params['arguments']
|
||||
|
||||
api.register('ALL', '/installed', is_installed)
|
||||
|
||||
# Register only postinstall action if YunoHost isn't completely set up
|
||||
try:
|
||||
with open('/etc/yunohost/installed') as f: pass
|
||||
except IOError:
|
||||
installed = False
|
||||
api = APIResource()
|
||||
api.register('POST', '/postinstall', http_exec)
|
||||
api.register('OPTIONS', '/postinstall', http_exec)
|
||||
action_dict['POST /postinstall'] = {
|
||||
'function' : 'yunohost_tools.tools_postinstall',
|
||||
'help' : 'Execute post-install',
|
||||
'arguments' : action_map['tools']['postinstall']['arguments']
|
||||
}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in a new issue