Compare commits
2 Commits
906ad9f42a
...
0.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
| e69b2dfab9 | |||
| f168ad9e47 |
@@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
⚠️ this is not an official implementation
|
⚠️ this is not an official implementation
|
||||||
|
|
||||||
[](https://pypi.org/project/georideapilib/)
|
|
||||||
|
|
||||||
Official georide website: https://georide.fr/
|
Official georide website: https://georide.fr/
|
||||||
|
|
||||||
This library can control your georide tracker tracker
|
This library can control your georide tracker tracker
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ from georideapilib.objects import GeorideAccount
|
|||||||
import georideapilib.api as GeorideApi
|
import georideapilib.api as GeorideApi
|
||||||
from georideapilib.socket import GeorideSocket
|
from georideapilib.socket import GeorideSocket
|
||||||
|
|
||||||
from threading import Thread
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger('example')
|
_LOGGER = logging.getLogger('example')
|
||||||
|
|
||||||
|
|
||||||
@@ -24,21 +22,12 @@ def example():
|
|||||||
print("token 1: ", account.auth_token)
|
print("token 1: ", account.auth_token)
|
||||||
_LOGGER.info("token 1: %s", account.auth_token)
|
_LOGGER.info("token 1: %s", account.auth_token)
|
||||||
# pylint: disable=W0105
|
# pylint: disable=W0105
|
||||||
|
|
||||||
def locked_locked(data):
|
# socket = GeorideSocket()
|
||||||
_LOGGER.info("Locke received")
|
# socket.init()
|
||||||
|
# socket.connect(account.auth_token)
|
||||||
|
# time.sleep(10)
|
||||||
def connect_socket(account):
|
# socket.disconnect()
|
||||||
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)
|
account.auth_token = GeorideApi.renewToken(account.auth_token)
|
||||||
|
|||||||
@@ -53,12 +53,11 @@ def get_authorisation_token(email, password):
|
|||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
account = GeorideAccount.from_json(response_data)
|
account = GeorideAccount.from_json(response_data)
|
||||||
elif response.status_code == 403:
|
elif response.status_code == 403:
|
||||||
_LOGGER.warning("Login failed")
|
_LOGGER.warnning("Login failed")
|
||||||
raise LoginException(get_authorisation_token, "Login failed")
|
raise LoginException("Login failed")
|
||||||
else:
|
else:
|
||||||
_LOGGER.error("Georide login, http error code: %s", response.status_code)
|
_LOGGER.error("Georide login, http error code: %s", response.status_code)
|
||||||
raise SeverException(get_authorisation_token,
|
raise SeverException("Georide login, http error code: {}".format(response.status_code))
|
||||||
"Georide login, http error code: {}".format(response.status_code))
|
|
||||||
return account
|
return account
|
||||||
|
|
||||||
|
|
||||||
@@ -74,11 +73,10 @@ def renew_token(token):
|
|||||||
new_token = response_data['authToken']
|
new_token = response_data['authToken']
|
||||||
elif response.status_code == 401:
|
elif response.status_code == 401:
|
||||||
_LOGGER.warnning("Renew token refused")
|
_LOGGER.warnning("Renew token refused")
|
||||||
raise UnauthorizedException(renew_token, "Renew token refused")
|
raise UnauthorizedException("Renew token refused")
|
||||||
else:
|
else:
|
||||||
_LOGGER.error("Georide login, http error code: %s", response.status_code)
|
_LOGGER.error("Georide login, http error code: %s", response.status_code)
|
||||||
raise SeverException(renew_token,
|
raise SeverException("Georide login, http error code: {}".format(response.status_code))
|
||||||
"Georide login, http error code: {}".format(response.status_code))
|
|
||||||
return new_token
|
return new_token
|
||||||
|
|
||||||
def revoke_token(token):
|
def revoke_token(token):
|
||||||
@@ -89,7 +87,7 @@ def revoke_token(token):
|
|||||||
headers=headers)
|
headers=headers)
|
||||||
if response.status_code == 401:
|
if response.status_code == 401:
|
||||||
_LOGGER.warnning("Token allready revoked")
|
_LOGGER.warnning("Token allready revoked")
|
||||||
raise UnauthorizedException(revoke_token, "Token allready revoked")
|
raise UnauthorizedException("Token allready revoked")
|
||||||
if response.status_code == 401:
|
if response.status_code == 401:
|
||||||
_LOGGER.warnning("Token allready revoked")
|
_LOGGER.warnning("Token allready revoked")
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -63,21 +63,21 @@ class GeorideSocket():
|
|||||||
""" on_message """
|
""" on_message """
|
||||||
_LOGGER.debug('Message received: %s', data)
|
_LOGGER.debug('Message received: %s', data)
|
||||||
if self._on_message_callback is not None:
|
if self._on_message_callback is not None:
|
||||||
self._on_message_callback(data)
|
self._on_message_callback()
|
||||||
|
|
||||||
@sio.on('device')
|
@sio.on('device')
|
||||||
def on_device(data):
|
def on_device(data):
|
||||||
""" on_device """
|
""" on_device """
|
||||||
_LOGGER.debug('Device received: %s', data)
|
_LOGGER.debug('Device received: %s', data)
|
||||||
if self._on_device_callback is not None:
|
if self._on_device_callback is not None:
|
||||||
self._on_device_callback(data)
|
self._on_device_callback()
|
||||||
|
|
||||||
@sio.on('position')
|
@sio.on('position')
|
||||||
def on_position(data):
|
def on_position(data):
|
||||||
""" on_position """
|
""" on_position """
|
||||||
_LOGGER.debug('Position received:%s', data)
|
_LOGGER.debug('Position received:%s', data)
|
||||||
if self._on_position_callback is not None:
|
if self._on_position_callback is not None:
|
||||||
self._on_position_callback(data)
|
self._on_position_callback()
|
||||||
|
|
||||||
@sio.on('alarm')
|
@sio.on('alarm')
|
||||||
def on_alarm(data):
|
def on_alarm(data):
|
||||||
@@ -98,9 +98,9 @@ class GeorideSocket():
|
|||||||
""" on_locked """
|
""" on_locked """
|
||||||
_LOGGER.debug('Locked received: %s', data)
|
_LOGGER.debug('Locked received: %s', data)
|
||||||
if self._on_locked_callback is not None:
|
if self._on_locked_callback is not None:
|
||||||
self._on_locked_callback(data)
|
self._on_locked_callback()
|
||||||
else:
|
|
||||||
self._initialised = True
|
self._initialised = True
|
||||||
|
|
||||||
def connect(self, auth_token):
|
def connect(self, auth_token):
|
||||||
""" connect to the georide socket"""
|
""" connect to the georide socket"""
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -19,7 +19,7 @@ CURRENT_DIR = os.path.dirname(__file__)
|
|||||||
setup(
|
setup(
|
||||||
name='georideapilib',
|
name='georideapilib',
|
||||||
packages=['georideapilib'], # this must be the same as the name above
|
packages=['georideapilib'], # this must be the same as the name above
|
||||||
version='0.4.2',
|
version='0.4.0',
|
||||||
description='Lib to control georide tracker devices with their rest api',
|
description='Lib to control georide tracker devices with their rest api',
|
||||||
author='Matthieu DUVAL',
|
author='Matthieu DUVAL',
|
||||||
author_email='georideapilib@duval-dev.fr',
|
author_email='georideapilib@duval-dev.fr',
|
||||||
|
|||||||
Reference in New Issue
Block a user