mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Merge branch 'dev' of github.com:YunoHost/moulinette into dev
This commit is contained in:
commit
1a39660f1e
1 changed files with 11 additions and 4 deletions
15
yunohost.tac
15
yunohost.tac
|
@ -18,6 +18,8 @@ if not __debug__:
|
|||
|
||||
gettext.install('YunoHost')
|
||||
|
||||
dev = False
|
||||
installed = True
|
||||
action_dict = {}
|
||||
api = APIResource()
|
||||
|
||||
|
@ -35,10 +37,10 @@ def http_exec(request, **kwargs):
|
|||
return ''
|
||||
|
||||
# Simple HTTP auth
|
||||
else:
|
||||
elif installed:
|
||||
authorized = request.getUser() == 'admin'
|
||||
pwd = request.getPassword()
|
||||
if 'api_key' in request.args:
|
||||
if dev and 'api_key' in request.args:
|
||||
pwd = request.args['api_key'][0]
|
||||
authorized = True
|
||||
if authorized:
|
||||
|
@ -55,7 +57,7 @@ def http_exec(request, **kwargs):
|
|||
if kwargs:
|
||||
for k, v in kwargs.iteritems():
|
||||
dynamic_key = path.split('/')[-1]
|
||||
path = path.replace(dynamic_key, '(?P<'+ k +'>[^/]+)')
|
||||
path = path.replace(dynamic_key, '{'+ k +'}')
|
||||
given_args[k] = [v]
|
||||
|
||||
print given_args
|
||||
|
@ -202,6 +204,7 @@ def main():
|
|||
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)
|
||||
|
@ -213,7 +216,11 @@ def main():
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
startLogging(open('/var/log/yunohost.log', 'a+')) # Log actions to API
|
||||
if '--dev' in sys.argv:
|
||||
dev = True
|
||||
startLogging(sys.stdout)
|
||||
else:
|
||||
startLogging(open('/var/log/yunohost.log', 'a+')) # Log actions to file
|
||||
main()
|
||||
reactor.listenTCP(6767, Site(api, timeout=None))
|
||||
reactor.run()
|
||||
|
|
Loading…
Reference in a new issue