From 8d50045971b8145faf6810106325db10a26f799f Mon Sep 17 00:00:00 2001 From: William Scanlon Date: Thu, 4 May 2017 16:13:09 -0400 Subject: [PATCH] Suppress logs when octorpint goes offline (#7441) * Suppress logs when octorpint goes offline * Fixed line length --- homeassistant/components/octoprint.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/octoprint.py b/homeassistant/components/octoprint.py index db6dd9931be..b06b15c7973 100644 --- a/homeassistant/components/octoprint.py +++ b/homeassistant/components/octoprint.py @@ -85,18 +85,16 @@ class OctoPrintAPI(object): self.printer_last_reading[0] = response.json() self.printer_last_reading[1] = time.time() return response.json() - except requests.exceptions.ConnectionError as conn_exc: + except (requests.exceptions.ConnectionError, + requests.exceptions.HTTPError) as conn_exc: _LOGGER.error("Failed to update OctoPrint status. Error: %s", conn_exc) - raise def update(self, sensor_type, end_point, group, tool=None): """Return the value for sensor_type from the provided endpoint.""" - try: - return get_value_from_json( - self.get(end_point), sensor_type, group, tool) - except requests.exceptions.ConnectionError: - raise + response = self.get(end_point) + if response is not None: + return get_value_from_json(response, sensor_type, group, tool) # pylint: disable=unused-variable