Show ANSI color codes in logs in Hass.io (#18834)

* Hass.io: Show ANSI color codes in logs

* Lint

* Fix test

* Lint
This commit is contained in:
Otto Winter authored and Paulus Schoutsen committed 2018-12-02 15:46:14 +01:00
1 parent b7e2522083
commit eec4564c71
2 files changed
+4 -19

No files matched your search

-15
View File
@@ -15,7 +15,6 @@ from aiohttp import web
from aiohttp.hdrs import CONTENT_TYPE
from aiohttp.web_exceptions import HTTPBadGateway
from homeassistant.const import CONTENT_TYPE_TEXT_PLAIN
from homeassistant.components.http import KEY_AUTHENTICATED, HomeAssistantView
from .const import X_HASSIO
@@ -63,8 +62,6 @@ class HassIOView(HomeAssistantView):
client = await self._command_proxy(path, request)
data = await client.read()
if path.endswith('/logs'):
return _create_response_log(client, data)
return _create_response(client, data)
get = _handle
@@ -114,18 +111,6 @@ def _create_response(client, data):
)
def _create_response_log(client, data):
"""Convert a response from client request."""
# Remove color codes
log = re.sub(r"\x1b(\[.*?[@-~]|\].*?(\x07|\x1b\\))", "", data.decode())
return web.Response(
text=log,
status=client.status,
content_type=CONTENT_TYPE_TEXT_PLAIN,
)
def _get_timeout(path):
"""Return timeout for a URL path."""
if NO_TIMEOUT.match(path):