add logo support (#104)

* fix lint

* fix lint p2

* fix api output

* fix decorator

* fix decorator p2

* fix UnboundLocalError

* revert

* fix trace bug

* fix conent type

* allow logo
This commit is contained in:
Pascal Vizeli
2017-07-21 00:23:31 +02:00
committed by GitHub
parent 251a43216e
commit 7e1bb42bb7
6 changed files with 25 additions and 18 deletions

View File

@@ -66,21 +66,23 @@ def api_process_hostcontrol(method):
return wrap_hostcontrol
def api_process_raw(content=CONTENT_TYPE_BINARY):
def api_raw(method):
def api_process_raw(content):
"""Wrap content_type into function."""
def wrap_method(method):
"""Wrap function with raw output to rest api."""
async def wrap_api(api, *args, **kwargs):
"""Return api information."""
try:
message = await method(api, *args, **kwargs)
msg_data = await method(api, *args, **kwargs)
msg_type = content
except RuntimeError as err:
message = str(err).encode()
content = CONTENT_TYPE_BINARY
msg_data = str(err).encode()
msg_type = CONTENT_TYPE_BINARY
return web.Response(body=message, content_type=content)
return web.Response(body=msg_data, content_type=msg_type)
return wrap_api
return api_raw
return wrap_method
def api_return_error(message=None):