Skip to content

Commit

Permalink
Raise timeout only when 80 and 8080 time out / catch httpx.RemoteProt…
Browse files Browse the repository at this point in the history
…ocolError exception
  • Loading branch information
ol-iver committed May 6, 2021
1 parent 77fa2fe commit 8b6cb2c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# denonavr
[![Version](https://img.shields.io/badge/version-v0.10.6-orange.svg)](https://github.com/scarface-4711/denonavr)
[![Version](https://img.shields.io/badge/version-v0.10.7.dev1-orange.svg)](https://github.com/scarface-4711/denonavr)
[![Build Status](https://travis-ci.com/scarface-4711/denonavr.svg?branch=master)](https://travis-ci.com/scarface-4711/denonavr)
[![PyPi](https://img.shields.io/pypi/v/denonavr.svg)](https://pypi.org/project/denonavr)
[![License](https://img.shields.io/github/license/scarface-4711/denonavr.svg)](LICENSE)

Automation Library for Denon AVR receivers - current version 0.10.6
Automation Library for Denon AVR receivers - current version 0.10.7.dev1

## Important change

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ denonavr
.. |Build Status| .. image:: https://travis-ci.com/scarface-4711/denonavr.svg?branch=master
:target: https://travis-ci.com/scarface-4711/denonavr

Automation Library for Denon AVR receivers - current version 0.10.6
Automation Library for Denon AVR receivers - current version 0.10.7.dev1

Important change
----------------
Expand Down
2 changes: 1 addition & 1 deletion denonavr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
logging.getLogger(__name__).addHandler(logging.NullHandler())

__title__ = "denonavr"
__version__ = "0.10.6"
__version__ = "0.10.7.dev1"


async def async_discover():
Expand Down
6 changes: 6 additions & 0 deletions denonavr/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ async def wrapper(*args, **kwargs):
exc_info=True)
raise AvrNetworkError(
"NetworkError: {}".format(err), err.request) from err
except httpx.RemoteProtocolError as err:
_LOGGER.debug(
"Remote protocol error exception on request %s", err.request,
exc_info=True)
raise AvrInvalidResponseError(
"RemoteProtocolError: {}".format(err), err.request) from err
except (
ET.ParseError, DefusedXmlException, ParseError,
UnicodeDecodeError) as err:
Expand Down
6 changes: 4 additions & 2 deletions denonavr/foundation.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ async def async_identify_receiver(self) -> None:
# 2016 models has also some of the XML but not all, try first 2016
r_types = [AVR_X, AVR_X_2016]

timeout_errors = 0
for r_type in r_types:
self.api.port = r_type.port
# This XML is needed to get the sources of the receiver
Expand All @@ -134,8 +135,9 @@ async def async_identify_receiver(self) -> None:
_LOGGER.debug(
"Connection error when identifying receiver", exc_info=err)

# Raise error only when ran over all models
if r_types.index(r_type) == len(r_types) - 1:
# Raise error only when occured at both types
timeout_errors += 1
if timeout_errors == len(r_types):
raise

except AvrRequestError as err:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools import find_packages, setup

setup(name='denonavr',
version='0.10.6',
version='0.10.7.dev1',
description='Automation Library for Denon AVR receivers',
long_description='Automation Library for Denon AVR receivers',
url='https://github.com/scarface-4711/denonavr',
Expand Down

0 comments on commit 8b6cb2c

Please sign in to comment.