Skip to content

Commit

Permalink
Do not log test runs
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Apr 21, 2019
1 parent 5f5850d commit 92e67f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions pytraccar/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
LONG = fh.read()
setuptools.setup(
name="pytraccar",
version="0.7.1",
version="0.8.0",
author="Joakim Sorensen",
author_email="[email protected]",
description="",
Expand Down

0 comments on commit 92e67f8

Please sign in to comment.