From 92e67f89bb8e5b046f4f6239e4626bb03065bf39 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sun, 21 Apr 2019 15:15:54 +0200 Subject: [PATCH] Do not log test runs --- pytraccar/api.py | 19 ++++++++++++------- setup.py | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pytraccar/api.py b/pytraccar/api.py index 4216795..42795dd 100644 --- a/pytraccar/api.py +++ b/pytraccar/api.py @@ -36,7 +36,7 @@ def __init__(self, loop, session, username, password, host, port=8082, ssl=False self._positions = [] self._device_info = {} - async def api(self, endpoint, params=None): + async def api(self, endpoint, params=None, test=False): """Comunicate with the API.""" data = {} url = "{}/{}".format(self._api, endpoint) @@ -56,25 +56,30 @@ async def api(self, endpoint, params=None): except asyncio.TimeoutError as error: self._authenticated, self._connected = False, False - _LOGGER.warning("Timeouterror connecting to Traccar, %s", error) + if not test: + _LOGGER.warning("Timeouterror connecting to Traccar, %s", error) except aiohttp.ClientError as error: self._authenticated, self._connected = False, False - _LOGGER.warning("Error connecting to Traccar, %s", error) + if not test: + _LOGGER.warning("Error connecting to Traccar, %s", error) except socket.gaierror as error: self._authenticated, self._connected = False, False - _LOGGER.warning("Error connecting to Traccar, %s", error) + if not test: + _LOGGER.warning("Error connecting to Traccar, %s", error) except TypeError as error: self._authenticated, self._connected = False, False - _LOGGER.warning("Error connecting to Traccar, %s", error) + if not test: + _LOGGER.warning("Error connecting to Traccar, %s", error) except Exception as error: # pylint: disable=broad-except self._authenticated, self._connected = False, False - _LOGGER.warning("Error connecting to Traccar, %s", error) + if not test: + _LOGGER.warning("Error connecting to Traccar, %s", error) return data async def test_connection(self): """Get the local installed version.""" - await self.api("devices") + await self.api("devices", test=True) async def get_device_info(self, custom_attributes=None): """Get the local installed version.""" diff --git a/setup.py b/setup.py index 5a1c19d..797348c 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ LONG = fh.read() setuptools.setup( name="pytraccar", - version="0.7.1", + version="0.8.0", author="Joakim Sorensen", author_email="ludeeus@gmail.com", description="",