diff --git a/connection_request.py b/connection_request.py index c4a26be..73ab586 100644 --- a/connection_request.py +++ b/connection_request.py @@ -54,9 +54,13 @@ def execute(self, template, value): warnings.filterwarnings("ignore", category=InsecureRequestWarning) with requests.sessions.Session() as session: self.logger.info(self._params) - resp = session.request(**self._params) - self.logger.info("Command executed with code: {}".format(resp.status_code)) - + try: + resp = session.request(**self._params) + self.logger.info("Command executed with code: {}".format(resp.status_code)) + except (requests.exceptions.ConnectionError, OSError): + # OSError is returned when there is no route to the host + resp = None + if resp is not None and resp.ok: try: j = resp.json() diff --git a/properties.py b/properties.py index 1a05381..0206375 100644 --- a/properties.py +++ b/properties.py @@ -286,7 +286,7 @@ def value(self): try: f = float(self._value) except: - f = -1000 + f = None return f @property