-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Both values for ValueChangeEvent are properly unpacked - Bumped library versions - Fixed a bug where the configuration for a link was not set properly - The test client does log all rest communication in the testcase
- Loading branch information
1 parent
020578c
commit 20f6bbe
Showing
24 changed files
with
237 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.15.1' | ||
__version__ = '0.15.2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,3 @@ | |
from . import topics | ||
from .const import MISSING | ||
from .loop import loop | ||
|
||
# utilities last! | ||
from . import utilities |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .funcs import list_files | ||
from .pending_future import PendingFuture |
4 changes: 2 additions & 2 deletions
4
...pp/core/const/utilities/pending_future.py → HABApp/core/lib/pending_future.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import logging | ||
from pprint import pformat | ||
|
||
import HABApp.openhab.connection_handler.http_connection | ||
from HABApp.openhab.connection_handler.http_connection import HTTP_PREFIX | ||
|
||
FUNC_PATH = HABApp.openhab.connection_handler.func_async | ||
|
||
|
||
def shorten_url(url: str): | ||
url = str(url) | ||
if url.startswith(HTTP_PREFIX): | ||
return url[len(HTTP_PREFIX):] | ||
return url | ||
|
||
|
||
class RestPatcher: | ||
def __init__(self, name): | ||
self.log = logging.getLogger('HABApp.Rest') | ||
self.log.debug('') | ||
self.log.debug(f'{name}:') | ||
|
||
def wrap(self, to_call): | ||
async def resp_wrap(*args, **kwargs): | ||
|
||
resp = await to_call(*args, **kwargs) | ||
|
||
out = '' | ||
if kwargs.get('json'): | ||
out = f' {kwargs["json"]}' | ||
if kwargs.get('data'): | ||
out = f' "{kwargs["data"]}"' | ||
self.log.debug(f'{resp.request_info.method:^6s} {shorten_url(resp.request_info.url)} ({resp.status}){out}') | ||
|
||
def wrap_content(content_func): | ||
async def content_func_wrap(*cargs, **ckwargs): | ||
t = await content_func(*cargs, **ckwargs) | ||
|
||
# pretty print the response | ||
obj = pformat(t, indent=2) | ||
if obj[0] == '[' and obj[-1] == ']': | ||
obj = f'[\n {obj[1:-1]}\n]' | ||
elif obj[0] == '{' and obj[-1] == '}': | ||
obj = f'{{\n {obj[1:-1]}\n}}' | ||
lines = obj.splitlines() | ||
if len(lines) <= 1: | ||
self.log.debug(f'{"->":6s}') | ||
else: | ||
for i, l in enumerate(lines): | ||
self.log.debug(f'{"->" if not i else "":^6s} {l}') | ||
|
||
return t | ||
return content_func_wrap | ||
|
||
resp.text = wrap_content(resp.text) | ||
resp.json = wrap_content(resp.json) | ||
return resp | ||
return resp_wrap | ||
|
||
def __enter__(self): | ||
self._get = FUNC_PATH.get | ||
self._put = FUNC_PATH.put | ||
self._post = FUNC_PATH.post | ||
self._delete = FUNC_PATH.delete | ||
|
||
FUNC_PATH.get = self.wrap(self._get) | ||
FUNC_PATH.put = self.wrap(self._put) | ||
FUNC_PATH.post = self.wrap(self._post) | ||
FUNC_PATH.delete = self.wrap(self._delete) | ||
|
||
def __exit__(self, exc_type, exc_val, exc_tb): | ||
FUNC_PATH.get = self._get | ||
FUNC_PATH.put = self._put | ||
FUNC_PATH.post = self._post | ||
FUNC_PATH.delete = self._delete | ||
|
||
return False |
Oops, something went wrong.