Fix route registering

This commit is contained in:
Kload 2013-11-21 11:33:48 +01:00
parent d9d7d0ef24
commit 8f12b330b0

View file

@ -117,6 +117,10 @@ def http_exec(request, **kwargs):
raise YunoHostError(1, _("A YunoHost command is already running"))
except IOError:
if dict['function'].split('.')[1] != 'tools_postinstall':
try:
with open('/etc/yunohost/installed'): pass
except IOError:
raise YunoHostError(1, _("You must run postinstall before any other actions"))
with open('/var/run/yunohost.pid', 'w') as f:
f.write('ldap')
os.system('chmod 400 /var/run/yunohost.pid')
@ -212,18 +216,6 @@ def main():
action_map = yaml.load(f)
# 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']['actions']['postinstall']['arguments']
}
else:
del action_map['general_arguments']
for category, category_params in action_map.items():
api.register('ALL', '/api/'+ category, api_doc)