From 4645f9daeaad8ccd344fd72bc26300f73e3264e0 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 20 Jun 2020 13:23:47 -0500 Subject: [PATCH 1/3] handle when diskspace is not available --- sonarr/sonarr.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index d342dad3..fcfab78b 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -143,8 +143,6 @@ async def update(self, full_update: bool = False) -> Application: raise SonarrError("Sonarr returned an empty API status response") diskspace = await self._request("diskspace") - if not diskspace or diskspace is None: - raise SonarrError("Sonarr returned an empty API diskspace response") self._application = Application({"info": status, "diskspace": diskspace}) return self._application From c9b924cd65b4bd59ad9e3d1937559fcc6e707029 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 20 Jun 2020 13:26:13 -0500 Subject: [PATCH 2/3] Update models.py --- sonarr/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sonarr/models.py b/sonarr/models.py index 103c50d2..278924a7 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -365,7 +365,7 @@ class Application: def __init__(self, data: dict): """Initialize an empty Sonarr application class.""" # Check if all elements are in the passed dict, else raise an Error - if any(k not in data for k in ["info", "diskspace"]): + if any(k not in data for k in ["info"]): raise SonarrError("Sonarr data is incomplete, cannot construct object") self.update_from_dict(data) @@ -374,7 +374,7 @@ def update_from_dict(self, data: dict) -> "Application": if "info" in data and data["info"]: self.info = Info.from_dict(data["info"]) - if "diskspace" in data and data["diskspace"]: + if "diskspace" in data and data["diskspace"] and data["diskspace"] is not None: disks = [Disk.from_dict(disk) for disk in data["diskspace"]] self.disks = disks From 936775fc803d656eb7059e1a03d64b47a7a75d03 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 20 Jun 2020 13:32:48 -0500 Subject: [PATCH 3/3] Update models.py --- sonarr/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonarr/models.py b/sonarr/models.py index 278924a7..784d8e6f 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -374,7 +374,7 @@ def update_from_dict(self, data: dict) -> "Application": if "info" in data and data["info"]: self.info = Info.from_dict(data["info"]) - if "diskspace" in data and data["diskspace"] and data["diskspace"] is not None: + if "diskspace" in data and data["diskspace"]: disks = [Disk.from_dict(disk) for disk in data["diskspace"]] self.disks = disks