From b0e994f3f595f1b4053f6c24f8dbd8e484f8ab3d Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 25 Jun 2019 17:38:57 +0200 Subject: [PATCH 1/6] Bump version 168 --- hassio/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hassio/const.py b/hassio/const.py index 8e49f1b5e..cf3eedcd0 100644 --- a/hassio/const.py +++ b/hassio/const.py @@ -3,7 +3,7 @@ from pathlib import Path from ipaddress import ip_network -HASSIO_VERSION = "167" +HASSIO_VERSION = "168" URL_HASSIO_ADDONS = "https://github.com/home-assistant/hassio-addons" URL_HASSIO_VERSION = "https://s3.amazonaws.com/hassio-version/{channel}.json" From 157740e374a8c79785c2ad615d71b702f509c062 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Thu, 4 Jul 2019 17:28:50 +0200 Subject: [PATCH 2/6] Update devcontainer.json --- .devcontainer/devcontainer.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a27fe99b0..6979f8569 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,6 +3,9 @@ "name": "Hass.io dev", "context": "..", "dockerFile": "Dockerfile", + "runArgs": [ + "-e", "GIT_EDTIOR='code --wait'" + ], "extensions": [ "ms-python.python" ], @@ -13,6 +16,7 @@ "python.formatting.provider": "black", "editor.formatOnPaste": false, "editor.formatOnSave": true, - "editor.formatOnType": true + "editor.formatOnType": true, + "files.trimTrailingWhitespace": true } -} \ No newline at end of file +} From 0a34f427f8c903a613a0c24affa5d01d5cb84021 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Thu, 4 Jul 2019 17:30:42 +0200 Subject: [PATCH 3/6] Fix error on save special permission (#1145) --- hassio/api/addons.py | 2 +- hassio/ingress.py | 2 -- tests/test_ingress.py | 9 ++++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hassio/api/addons.py b/hassio/api/addons.py index 2c10870d0..41e0767b3 100644 --- a/hassio/api/addons.py +++ b/hassio/api/addons.py @@ -291,7 +291,7 @@ class APIAddons(CoreSysAttributes): _LOGGER.warning("Protected flag changing for %s!", addon.slug) addon.protected = body[ATTR_PROTECTED] - addon.save_data() + addon.save_persist() @api_process async def stats(self, request: web.Request) -> Dict[str, Any]: diff --git a/hassio/ingress.py b/hassio/ingress.py index cc87b242b..83dda70b0 100644 --- a/hassio/ingress.py +++ b/hassio/ingress.py @@ -96,8 +96,6 @@ class Ingress(JsonConfig, CoreSysAttributes): valid = utcnow() + timedelta(minutes=15) self.sessions[session] = valid.timestamp() - self.save_data() - return session def validate_session(self, session: str) -> bool: diff --git a/tests/test_ingress.py b/tests/test_ingress.py index 50f1d5de4..a1aaf570e 100644 --- a/tests/test_ingress.py +++ b/tests/test_ingress.py @@ -9,7 +9,6 @@ def test_session_handling(coresys): session = coresys.ingress.create_session() validate = coresys.ingress.sessions[session] - assert coresys.ingress.save_data.called assert session assert validate @@ -22,6 +21,14 @@ def test_session_handling(coresys): assert not coresys.ingress.validate_session("invalid session") +async def test_save_on_unload(coresys): + """Test called save on unload.""" + coresys.ingress.create_session() + await coresys.ingress.unload() + + assert coresys.ingress.save_data.called + + def test_dynamic_ports(coresys): """Test dyanmic port handling.""" port_test1 = coresys.ingress.get_dynamic_port("test1") From 0a3a752b4cf52c4547bfbbb65fc4e764454bf2c3 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Thu, 4 Jul 2019 18:20:46 +0200 Subject: [PATCH 4/6] Add timezone to info call (#1146) --- API.md | 3 ++- hassio/api/info.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/API.md b/API.md index 87226f6c4..48c2cc5f5 100644 --- a/API.md +++ b/API.md @@ -730,7 +730,8 @@ return: "arch": "arch", "supported_arch": ["arch1", "arch2"], "channel": "stable|beta|dev", - "logging": "debug|info|warning|error|critical" + "logging": "debug|info|warning|error|critical", + "timezone": "Europe/Zurich" } ``` diff --git a/hassio/api/info.py b/hassio/api/info.py index 527397946..249f6f03c 100644 --- a/hassio/api/info.py +++ b/hassio/api/info.py @@ -14,6 +14,7 @@ from ..const import ( ATTR_MACHINE, ATTR_SUPERVISOR, ATTR_SUPPORTED_ARCH, + ATTR_TIMEZONE, ) from ..coresys import CoreSysAttributes from .utils import api_process @@ -37,4 +38,5 @@ class APIInfo(CoreSysAttributes): ATTR_SUPPORTED_ARCH: self.sys_arch.supported, ATTR_CHANNEL: self.sys_updater.channel, ATTR_LOGGING: self.sys_config.logging, + ATTR_TIMEZONE: self.sys_timezone, } From a37c90af96204f5aa2334ee0cc521ccba74b8565 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sat, 6 Jul 2019 18:06:39 +0200 Subject: [PATCH 5/6] Forward Params (#1150) --- hassio/api/proxy.py | 11 ++++++----- hassio/homeassistant.py | 10 ++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/hassio/api/proxy.py b/hassio/api/proxy.py index fe026cec5..c193aeb60 100644 --- a/hassio/api/proxy.py +++ b/hassio/api/proxy.py @@ -20,7 +20,7 @@ _LOGGER = logging.getLogger(__name__) class APIProxy(CoreSysAttributes): """API Proxy for Home Assistant.""" - def _check_access(self, request): + def _check_access(self, request: web.Request): """Check the Hass.io token.""" if AUTHORIZATION in request.headers: bearer = request.headers[AUTHORIZATION] @@ -40,7 +40,7 @@ class APIProxy(CoreSysAttributes): raise HTTPUnauthorized() @asynccontextmanager - async def _api_client(self, request, path, timeout=300): + async def _api_client(self, request: web.Request, path: str, timeout: int = 300): """Return a client request with proxy origin for Home Assistant.""" try: # read data @@ -58,6 +58,7 @@ class APIProxy(CoreSysAttributes): content_type=content_type, data=data, timeout=timeout, + params=request.query, ) as resp: yield resp return @@ -73,7 +74,7 @@ class APIProxy(CoreSysAttributes): raise HTTPBadGateway() - async def stream(self, request): + async def stream(self, request: web.Request): """Proxy HomeAssistant EventStream Requests.""" self._check_access(request) @@ -92,7 +93,7 @@ class APIProxy(CoreSysAttributes): _LOGGER.info("Home Assistant EventStream close") return response - async def api(self, request): + async def api(self, request: web.Request): """Proxy Home Assistant API Requests.""" self._check_access(request) @@ -162,7 +163,7 @@ class APIProxy(CoreSysAttributes): raise APIError() - async def websocket(self, request): + async def websocket(self, request: web.Request): """Initialize a WebSocket API connection.""" _LOGGER.info("Home Assistant WebSocket API request initialize") diff --git a/hassio/homeassistant.py b/hassio/homeassistant.py index 72d178a4c..0e831c907 100644 --- a/hassio/homeassistant.py +++ b/hassio/homeassistant.py @@ -460,7 +460,8 @@ class HomeAssistant(JsonConfig, CoreSysAttributes): json: Optional[Dict[str, Any]] = None, content_type: Optional[str] = None, data: Optional[bytes] = None, - timeout=30, + timeout: int = 30, + params: Optional[Dict[str, str]] = None, ) -> AsyncContextManager[aiohttp.ClientResponse]: """Async context manager to make a request with right auth.""" url = f"{self.api_url}/{path}" @@ -482,7 +483,12 @@ class HomeAssistant(JsonConfig, CoreSysAttributes): try: async with getattr(self.sys_websession_ssl, method)( - url, data=data, timeout=timeout, json=json, headers=headers + url, + data=data, + timeout=timeout, + json=json, + headers=headers, + params=params, ) as resp: # Access token expired if resp.status == 401 and self.refresh_token: From d262151727f4f498043eb33dd5d619745780fe08 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 6 Jul 2019 18:07:15 +0200 Subject: [PATCH 6/6] Bump pytest from 4.6.3 to 5.0.1 (#1148) * Bump pytest from 4.6.3 to 5.0.1 Bumps [pytest](https://github.com/pytest-dev/pytest) from 4.6.3 to 5.0.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/4.6.3...5.0.1) Signed-off-by: dependabot-preview[bot] * Update tox.ini --- requirements_tests.txt | 2 +- tox.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements_tests.txt b/requirements_tests.txt index a5678efc3..d6830550d 100644 --- a/requirements_tests.txt +++ b/requirements_tests.txt @@ -1,5 +1,5 @@ flake8==3.7.7 pylint==2.3.1 -pytest==4.6.3 +pytest==5.0.1 pytest-timeout==1.3.3 pytest-aiohttp==0.3.0 diff --git a/tox.ini b/tox.ini index 970b3f383..99aa3aa26 100644 --- a/tox.ini +++ b/tox.ini @@ -16,4 +16,4 @@ commands = [testenv:tests] basepython = python3 commands = - pytest --duration=10 tests + pytest --timeout=10 tests