Skip to content

Commit

Permalink
0.19.1 (#196)
Browse files Browse the repository at this point in the history
0.19.1
- Text header is now properly set (fix for empty strings)
- Added info about openhabian
  • Loading branch information
spacemanspiff2007 authored Jan 12, 2021
1 parent de5f8f5 commit 16e35cd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion HABApp/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.19.0'
__version__ = '0.19.1'
18 changes: 16 additions & 2 deletions HABApp/openhab/connection_handler/http_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,15 @@ async def post(url: str, log_404=True, json=None, data=None, **kwargs: Any) -> O
assert not url.startswith('/'), url
url = f'{HTTP_PREFIX}/rest/{url}/'

# todo: remove this workaround once there is a fix in aiohttp
headers = None
if data is not None:
headers = {'Content-Type': 'text/plain; charset=utf-8'}

mgr = _RequestContextManager(
HTTP_SESSION._request(METH_POST, url, allow_redirects=HTTP_ALLOW_REDIRECTS, data=data, json=json, **kwargs)
HTTP_SESSION._request(
METH_POST, url, allow_redirects=HTTP_ALLOW_REDIRECTS, headers=headers, data=data, json=json, **kwargs
)
)

if data is None:
Expand All @@ -84,8 +91,15 @@ async def put(url: str, log_404=True, json=None, data=None, **kwargs: Any) -> Op
assert not url.startswith('/'), url
url = f'{HTTP_PREFIX}/rest/{url}/'

# todo: remove this workaround once there is a fix in aiohttp
headers = None
if data is not None:
headers = {'Content-Type': 'text/plain; charset=utf-8'}

mgr = _RequestContextManager(
HTTP_SESSION._request(METH_PUT, url, allow_redirects=HTTP_ALLOW_REDIRECTS, data=data, json=json, **kwargs)
HTTP_SESSION._request(
METH_PUT, url, allow_redirects=HTTP_ALLOW_REDIRECTS, headers=headers, data=data, json=json, **kwargs
)
)

if data is None:
Expand Down
4 changes: 3 additions & 1 deletion _doc/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Installation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. hint::
HABApp requires at least Python 3.6
With openhabian the installation can be performed through the openhabian-config tool (option 2B).
HABApp will be installed into ``/opt/habapp``, so it is the same as the installation described here.

.. hint::
On Windows use the ``python`` command instead of ``python3``

Expand Down
13 changes: 10 additions & 3 deletions conf_testing/lib/HABAppTests/_rest_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ async def resp_wrap(*args, **kwargs):
resp = await to_call(*args, **kwargs)

out = ''
if kwargs.get('json'):
if kwargs.get('json') is not None:
out = f' {kwargs["json"]}'
if kwargs.get('data'):
if kwargs.get('data') is not None:
out = f' "{kwargs["data"]}"'
self.log.debug(f'{resp.request_info.method:^6s} {shorten_url(resp.request_info.url)} ({resp.status}){out}')

self.log.debug(
f'{resp.request_info.method:^6s} {shorten_url(resp.request_info.url)} ({resp.status}){out}'
)

if resp.status >= 300:
self.log.debug(f'{"":6s} Header request : {resp.request_info.headers}')
self.log.debug(f'{"":6s} Header response: {resp.headers}')

def wrap_content(content_func):
async def content_func_wrap(*cargs, **ckwargs):
Expand Down
2 changes: 1 addition & 1 deletion conf_testing/lib/HABAppTests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'Number': [-111, 222, -13.13, 55.55],
'Player': ["PLAY", "PAUSE", "REWIND", "FASTFORWARD"],
'Rollershutter': [0, 100, 30.5],
'String': ['A', 'B', 'C', 'öäüß'],
'String': ['A', 'B', 'C', '', 'öäüß'],
'Switch': ['ON', 'OFF'],
}

Expand Down

0 comments on commit 16e35cd

Please sign in to comment.