8 Commits
0.4.0 ... 0.4.4

Author SHA1 Message Date
e59cd77908 Shipping v0.4.4 2019-11-03 20:26:49 +01:00
1275ffa882 Fix socket init error 2019-11-03 20:26:00 +01:00
6ab8749f11 Shipping v0.4.3 2019-11-02 17:51:48 +01:00
9923f45a95 Add pypi badge 2019-11-02 17:51:25 +01:00
13df6822c8 Shipping v0.4.2 2019-11-02 17:42:36 +01:00
9bb33b6020 Fix exception bug 2019-11-02 17:40:53 +01:00
b78c503b31 Shipping v0.4.1 2019-10-30 20:35:02 +01:00
b0caa42ca2 Fix data on callback function 2019-10-30 20:33:07 +01:00
5 changed files with 33 additions and 20 deletions

View File

@@ -3,6 +3,8 @@
⚠️ this is not an official implementation
[![pypi_badge](https://img.shields.io/pypi/v/georideapilib?style=for-the-badge)](https://pypi.org/project/georideapilib/)
Official georide website: https://georide.fr/
This library can control your georide tracker tracker
@@ -10,7 +12,7 @@ This library can control your georide tracker tracker
Some code have been taken from @alexmohr https://github.com/alexmohr/sonyapilib
This library is used as communication interface in a home assistant component to control media players, which can be found here:(Not ready yet ;))
This library is used as communication interface in a home assistant component to control media players, which can be found here: https://github.com/ptimatth/GeorideHA
At the moment not all functions offered by the api are implemented. If you miss a function feel free to create a pull request or open a feature request.
@@ -28,5 +30,4 @@ This library has been tested with python 3.7 and above, functionality for older
- https://github.com/ptimatth/pyGeoride
## Todo
- [ ] Add support of SocketIO connection
- [ ] Add support of "Get a shared trip" endpoint

View File

@@ -9,6 +9,8 @@ from georideapilib.objects import GeorideAccount
import georideapilib.api as GeorideApi
from georideapilib.socket import GeorideSocket
from threading import Thread
_LOGGER = logging.getLogger('example')
@@ -22,12 +24,21 @@ def example():
print("token 1: ", account.auth_token)
_LOGGER.info("token 1: %s", account.auth_token)
# pylint: disable=W0105
# socket = GeorideSocket()
# socket.init()
# socket.connect(account.auth_token)
# time.sleep(10)
# socket.disconnect()
def locked_locked(data):
_LOGGER.info("Locke received")
def connect_socket(account):
socket = GeorideSocket()
socket.subscribe_locked(locked_locked)
socket.init()
socket.connect(account.auth_token)
time.sleep(10)
socket.disconnect()
thread = Thread(target=connect_socket, args=(account))
thread.start()
"""
account.auth_token = GeorideApi.renewToken(account.auth_token)

View File

@@ -53,11 +53,12 @@ def get_authorisation_token(email, password):
response_data = response.json()
account = GeorideAccount.from_json(response_data)
elif response.status_code == 403:
_LOGGER.warnning("Login failed")
raise LoginException("Login failed")
_LOGGER.warning("Login failed")
raise LoginException(get_authorisation_token, "Login failed")
else:
_LOGGER.error("Georide login, http error code: %s", response.status_code)
raise SeverException("Georide login, http error code: {}".format(response.status_code))
raise SeverException(get_authorisation_token,
"Georide login, http error code: {}".format(response.status_code))
return account
@@ -73,10 +74,11 @@ def renew_token(token):
new_token = response_data['authToken']
elif response.status_code == 401:
_LOGGER.warnning("Renew token refused")
raise UnauthorizedException("Renew token refused")
raise UnauthorizedException(renew_token, "Renew token refused")
else:
_LOGGER.error("Georide login, http error code: %s", response.status_code)
raise SeverException("Georide login, http error code: {}".format(response.status_code))
raise SeverException(renew_token,
"Georide login, http error code: {}".format(response.status_code))
return new_token
def revoke_token(token):
@@ -87,7 +89,7 @@ def revoke_token(token):
headers=headers)
if response.status_code == 401:
_LOGGER.warnning("Token allready revoked")
raise UnauthorizedException("Token allready revoked")
raise UnauthorizedException(revoke_token, "Token allready revoked")
if response.status_code == 401:
_LOGGER.warnning("Token allready revoked")
return False

View File

@@ -63,21 +63,21 @@ class GeorideSocket():
""" on_message """
_LOGGER.debug('Message received: %s', data)
if self._on_message_callback is not None:
self._on_message_callback()
self._on_message_callback(data)
@sio.on('device')
def on_device(data):
""" on_device """
_LOGGER.debug('Device received: %s', data)
if self._on_device_callback is not None:
self._on_device_callback()
self._on_device_callback(data)
@sio.on('position')
def on_position(data):
""" on_position """
_LOGGER.debug('Position received:%s', data)
if self._on_position_callback is not None:
self._on_position_callback()
self._on_position_callback(data)
@sio.on('alarm')
def on_alarm(data):
@@ -98,8 +98,7 @@ class GeorideSocket():
""" on_locked """
_LOGGER.debug('Locked received: %s', data)
if self._on_locked_callback is not None:
self._on_locked_callback()
self._on_locked_callback(data)
self._initialised = True
def connect(self, auth_token):

View File

@@ -19,7 +19,7 @@ CURRENT_DIR = os.path.dirname(__file__)
setup(
name='georideapilib',
packages=['georideapilib'], # this must be the same as the name above
version='0.4.0',
version='0.4.4',
description='Lib to control georide tracker devices with their rest api',
author='Matthieu DUVAL',
author_email='georideapilib@duval-dev.fr',