Skip to content

Commit

Permalink
Catch more connection errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Shutgun committed Jan 19, 2021
1 parent 5da6516 commit 0407e79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions devolo_plc_api/clients/protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Callable

from google.protobuf.json_format import MessageToDict
from httpx import AsyncClient, ConnectTimeout, DigestAuth, Response
from httpx import AsyncClient, ConnectError, ConnectTimeout, DigestAuth, ReadTimeout, Response

from ..exceptions.device import DevicePasswordProtected, DeviceUnavailable

Expand Down Expand Up @@ -54,7 +54,7 @@ async def _async_get(self, sub_url: str, timeout: float = TIMEOUT) -> Response:
return await self._session.get(url, auth=DigestAuth(self._user, self.password), timeout=timeout)
except TypeError:
raise DevicePasswordProtected("The used password is wrong.") from None
except ConnectTimeout:
except (ConnectTimeout, ConnectError, ReadTimeout):
raise DeviceUnavailable("The device is currenctly not available. Maybe on standby?") from None

async def _async_post(self, sub_url: str, content: bytes, timeout: float = TIMEOUT) -> Response:
Expand All @@ -65,7 +65,7 @@ async def _async_post(self, sub_url: str, content: bytes, timeout: float = TIMEO
return await self._session.post(url, auth=DigestAuth(self._user, self.password), content=content, timeout=timeout)
except TypeError:
raise DevicePasswordProtected("The used password is wrong.") from None
except ConnectTimeout:
except (ConnectTimeout, ConnectError, ReadTimeout):
raise DeviceUnavailable("The device is currenctly not available. Maybe on standby?") from None

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion devolo_plc_api/plcnet_api/plcnetapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def async_identify_device_stop(self) -> bool:
response.FromString(await query.aread()) # pylint: disable=no-member
return bool(not response.result) # pylint: disable=no-member

async def async_set_user_device_name(self, name):
async def async_set_user_device_name(self, name) -> bool:
"""
Set device name.
Expand Down

0 comments on commit 0407e79

Please sign in to comment.