Compare commits
9 Commits
d93bab0fcf
...
v0.7.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 7dec38109a | |||
| b6ede1af3b | |||
| e38a402d44 | |||
| e59cd77908 | |||
| 6ab8749f11 | |||
| 13df6822c8 | |||
| b78c503b31 | |||
| e69b2dfab9 | |||
| f168ad9e47 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,5 +3,4 @@ __pycache__
|
|||||||
**/__pycache__
|
**/__pycache__
|
||||||
dist/
|
dist/
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
build/
|
build/
|
||||||
ressources/
|
|
||||||
@@ -27,7 +27,7 @@ This library has been tested with python 3.7 and above, functionality for older
|
|||||||
## Main repo:
|
## Main repo:
|
||||||
- https://git.tontontux.fr/mduval/pyGeoride
|
- https://git.tontontux.fr/mduval/pyGeoride
|
||||||
## Github repo:
|
## Github repo:
|
||||||
- https://github.com/ptimatth/georide-api
|
- https://github.com/ptimatth/pyGeoride
|
||||||
|
|
||||||
## Todo
|
## Todo
|
||||||
- [ ] Add support of "Get a shared trip" endpoint
|
- [ ] Add support of "Get a shared trip" endpoint
|
||||||
|
|||||||
@@ -28,13 +28,10 @@ def example():
|
|||||||
def locked_locked(data):
|
def locked_locked(data):
|
||||||
_LOGGER.info("Lock received")
|
_LOGGER.info("Lock received")
|
||||||
|
|
||||||
def refresh_tracker():
|
|
||||||
_LOGGER.info("Refresh tracker recieved")
|
|
||||||
|
|
||||||
def connect_socket(account):
|
def connect_socket(account):
|
||||||
socket = GeoRideSocket()
|
socket = GeoRideSocket()
|
||||||
socket.subscribe_locked(locked_locked)
|
socket.subscribe_locked(locked_locked)
|
||||||
socket.subscribe_refresh_tracker(refresh_tracker)
|
|
||||||
socket.init()
|
socket.init()
|
||||||
socket.connect(account.auth_token)
|
socket.connect(account.auth_token)
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ from georideapilib.objects import (
|
|||||||
GeoRideUser,
|
GeoRideUser,
|
||||||
GeoRideTrackerTrip,
|
GeoRideTrackerTrip,
|
||||||
GeoRideTrackerPosition,
|
GeoRideTrackerPosition,
|
||||||
GeoRideSharedTrip,
|
GeoRideSharedTrip
|
||||||
GeoRideTrackerBeacon
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from georideapilib.exception import (
|
from georideapilib.exception import (
|
||||||
@@ -129,7 +128,7 @@ def get_trackers(token):
|
|||||||
trackers.append(GeoRideTracker.from_json(json_tracker))
|
trackers.append(GeoRideTracker.from_json(json_tracker))
|
||||||
return trackers
|
return trackers
|
||||||
|
|
||||||
def get_tracker_beacons(token, tracker_id):
|
def get_tracker_beacon(token, tracker_id):
|
||||||
""" get user trackers """
|
""" get user trackers """
|
||||||
|
|
||||||
headers = {"Authorization": "Bearer " + token}
|
headers = {"Authorization": "Bearer " + token}
|
||||||
@@ -138,13 +137,10 @@ def get_tracker_beacons(token, tracker_id):
|
|||||||
headers=headers)
|
headers=headers)
|
||||||
|
|
||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
trackers_beacons = []
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
for json_tracker_beacon in response_data:
|
return GeoRideTrackerBeacon.from_json(response_data)
|
||||||
_LOGGER.debug(json_tracker_beacon)
|
else:
|
||||||
json_tracker_beacon['linked_tracker_id'] = tracker_id
|
return None
|
||||||
trackers_beacons.append(GeoRideTrackerBeacon.from_json(json_tracker_beacon))
|
|
||||||
return trackers_beacons
|
|
||||||
|
|
||||||
def get_trips(token, tracker_id, from_date, to_date):
|
def get_trips(token, tracker_id, from_date, to_date):
|
||||||
""" return all trips between two dates """
|
""" return all trips between two dates """
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
Georide objects implementation
|
Georide objects implementation
|
||||||
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
||||||
"""
|
"""
|
||||||
import time
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
@@ -288,8 +288,6 @@ class GeoRideTracker(metaclass=JsonMgtMetaClass): # pylint: disable=R0904,R0902
|
|||||||
self._has_beacon = has_beacon
|
self._has_beacon = has_beacon
|
||||||
self._has_outdated_beacons = has_outdated_beacons
|
self._has_outdated_beacons = has_outdated_beacons
|
||||||
self._ecall_activated = ecall_activated
|
self._ecall_activated = ecall_activated
|
||||||
self._is_siren_on = False
|
|
||||||
self._siren_last_on_date = time.time()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tracker_id(self):
|
def tracker_id(self):
|
||||||
@@ -600,28 +598,6 @@ class GeoRideTracker(metaclass=JsonMgtMetaClass): # pylint: disable=R0904,R0902
|
|||||||
def is_in_eco(self):
|
def is_in_eco(self):
|
||||||
""" is_in_eco property """
|
""" is_in_eco property """
|
||||||
return self._is_in_eco
|
return self._is_in_eco
|
||||||
|
|
||||||
@is_in_eco.setter
|
|
||||||
def is_in_eco(self, is_in_eco):
|
|
||||||
""" is_in_eco setter """
|
|
||||||
self._is_in_eco = is_in_eco
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_siren_on(self):
|
|
||||||
""" is_siren_on property """
|
|
||||||
return self._is_siren_on
|
|
||||||
|
|
||||||
@is_siren_on.setter
|
|
||||||
def is_siren_on(self, is_siren_on):
|
|
||||||
""" is_siren_on setter """
|
|
||||||
if is_siren_on:
|
|
||||||
self._siren_last_on_date = time.time()
|
|
||||||
self._is_siren_on = is_siren_on
|
|
||||||
|
|
||||||
@property
|
|
||||||
def siren_last_on_date(self):
|
|
||||||
""" siren_last_on_date property """
|
|
||||||
return self._siren_last_on_date
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_calibrated(self):
|
def is_calibrated(self):
|
||||||
@@ -777,11 +753,10 @@ class GeoRideTracker(metaclass=JsonMgtMetaClass): # pylint: disable=R0904,R0902
|
|||||||
|
|
||||||
class GeoRideTrackerBeacon:
|
class GeoRideTrackerBeacon:
|
||||||
""" GeoRideTrackerBeacon representation """
|
""" GeoRideTrackerBeacon representation """
|
||||||
def __init__(self, beacon_id, linked_tracker_id, name, created_at, updated_at,
|
def __init__(self, beacon_id, name, created_at, updated_at, mac_address,
|
||||||
mac_address, battery_level, last_battery_level_update, sleep_delay,
|
battery_level, last_battery_level_update, sleep_delay,
|
||||||
is_updated, power):
|
is_updated, power):
|
||||||
self._beacon_id = beacon_id
|
self._beacon_id = beacon_id
|
||||||
self._linked_tracker_id = linked_tracker_id
|
|
||||||
self._name = name
|
self._name = name
|
||||||
self._created_at = created_at
|
self._created_at = created_at
|
||||||
self._updated_at = updated_at
|
self._updated_at = updated_at
|
||||||
@@ -791,18 +766,6 @@ class GeoRideTrackerBeacon:
|
|||||||
self._sleep_delay = sleep_delay
|
self._sleep_delay = sleep_delay
|
||||||
self._is_updated = is_updated
|
self._is_updated = is_updated
|
||||||
self._power = power
|
self._power = power
|
||||||
|
|
||||||
|
|
||||||
@property
|
|
||||||
def linked_tracker_id(self):
|
|
||||||
""" linked_tracker_id property """
|
|
||||||
return self._linked_tracker_id
|
|
||||||
|
|
||||||
@linked_tracker_id.setter
|
|
||||||
def linked_tracker_id(self, linked_tracker_id):
|
|
||||||
""" linked_tracker_id setter """
|
|
||||||
self._linked_tracker_id = linked_tracker_id
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def beacon_id(self):
|
def beacon_id(self):
|
||||||
"""beacon_id property"""
|
"""beacon_id property"""
|
||||||
@@ -858,7 +821,6 @@ class GeoRideTrackerBeacon:
|
|||||||
"""return new object from_json"""
|
"""return new object from_json"""
|
||||||
return GeoRideTrackerBeacon(
|
return GeoRideTrackerBeacon(
|
||||||
json['id'],
|
json['id'],
|
||||||
json['linked_tracker_id'],
|
|
||||||
json['name'],
|
json['name'],
|
||||||
json['createdAt'],
|
json['createdAt'],
|
||||||
json['updatedAt'],
|
json['updatedAt'],
|
||||||
@@ -868,24 +830,11 @@ class GeoRideTrackerBeacon:
|
|||||||
json['sleepDelay'],
|
json['sleepDelay'],
|
||||||
json['isUpdated'],
|
json['isUpdated'],
|
||||||
json['power'])
|
json['power'])
|
||||||
|
|
||||||
def update_all_data(self, tracker_beacon):
|
|
||||||
"""update all data of the tracker beacon from a new object"""
|
|
||||||
self._name = tracker_beacon.name
|
|
||||||
self._created_at = tracker_beacon.created_at
|
|
||||||
self._updated_at = tracker_beacon.updated_at
|
|
||||||
self._mac_address = tracker_beacon.mac_address
|
|
||||||
self._battery_level = tracker_beacon.battery_level
|
|
||||||
self._last_battery_level_update = tracker_beacon.last_battery_level_update
|
|
||||||
self._sleep_delay = tracker_beacon.sleep_delay
|
|
||||||
self._is_updated = tracker_beacon.is_updated
|
|
||||||
self._power = tracker_beacon.power
|
|
||||||
|
|
||||||
|
|
||||||
class GeoRideSubscription:
|
class GeoRideSubscription:
|
||||||
""" Account object representation """
|
""" Account object representation """
|
||||||
def __init__(self, subscription_id, subscription_type, initial_date, next_payment_date,
|
def __init__(self, subscription_id, subscription_type, initialDate, nextPaymentDate,
|
||||||
status, paused_since, cancel_requested, price, first_name, last_name, card_information):
|
status, pausedSince, cancelRequested, price, firstName, lastName, cardInformation):
|
||||||
self._subscription_id = subscription_id
|
self._subscription_id = subscription_id
|
||||||
self._subscription_type = subscription_type
|
self._subscription_type = subscription_type
|
||||||
self._initial_date = initial_date
|
self._initial_date = initial_date
|
||||||
@@ -896,7 +845,6 @@ class GeoRideSubscription:
|
|||||||
self._price = price
|
self._price = price
|
||||||
self._first_name = first_name
|
self._first_name = first_name
|
||||||
self._last_name = last_name
|
self._last_name = last_name
|
||||||
self._card_information = card_information
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def subscription_id(self):
|
def subscription_id(self):
|
||||||
@@ -948,11 +896,6 @@ class GeoRideSubscription:
|
|||||||
"""last_name property"""
|
"""last_name property"""
|
||||||
return self._last_name
|
return self._last_name
|
||||||
|
|
||||||
@property
|
|
||||||
def card_information(self):
|
|
||||||
"""card_information property"""
|
|
||||||
return self._card_information
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, json):
|
def from_json(cls, json):
|
||||||
"""return new object from_json"""
|
"""return new object from_json"""
|
||||||
@@ -977,22 +920,6 @@ class GeoRideSubscription_CardInfo:
|
|||||||
self._expiry = expiry
|
self._expiry = expiry
|
||||||
self._brand = brand
|
self._brand = brand
|
||||||
|
|
||||||
@property
|
|
||||||
def last_digits(self):
|
|
||||||
"""last_digits property"""
|
|
||||||
return self._last_digits
|
|
||||||
|
|
||||||
@property
|
|
||||||
def expiry(self):
|
|
||||||
"""expiry property"""
|
|
||||||
return self._expiry
|
|
||||||
|
|
||||||
@property
|
|
||||||
def brand(self):
|
|
||||||
"""brand property"""
|
|
||||||
return self._brand
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, json):
|
def from_json(cls, json):
|
||||||
"""return new object from_json"""
|
"""return new object from_json"""
|
||||||
@@ -1110,4 +1037,96 @@ class GeoRideUser: # pylint: disable= R0902
|
|||||||
json['pushUserToken'],
|
json['pushUserToken'],
|
||||||
json['legal'],
|
json['legal'],
|
||||||
json['dateOfBirth']
|
json['dateOfBirth']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#TODO: remove in v0.8.0
|
||||||
|
class GeorideSharedTrip(GeoRideSharedTrip):
|
||||||
|
""" Shared trip object representation """
|
||||||
|
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"GeorideSharedTrip is deprecated, modify %s to use GeoRideSharedTrip",
|
||||||
|
cls.__name__,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, *argv):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init__(*argv)
|
||||||
|
_LOGGER.warning("GeorideSharedTrip is deprecated, modify your code to use GeoRideSharedTrip")
|
||||||
|
|
||||||
|
class GeorideTrackerTrip(GeoRideTrackerTrip):
|
||||||
|
""" Trip object representation """
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"GeorideTrackerTrip is deprecated, modify %s to use GeoRideTrackerTrip",
|
||||||
|
cls.__name__,
|
||||||
|
)
|
||||||
|
def __init__(self, *argv):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init__(*argv)
|
||||||
|
_LOGGER.warning("GeorideTrackerTrip is deprecated, modify your code to use GeoRideTrackerTrip")
|
||||||
|
|
||||||
|
class GeorideTrackerPosition(GeoRideTrackerPosition):
|
||||||
|
""" Trip object representation """
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"GeorideTrackerPosition is deprecated, modify %s to use GeoRideTrackerPosition",
|
||||||
|
cls.__name__,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, *argv):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init__(*argv)
|
||||||
|
_LOGGER.warning("GeorideTrackerPosition is deprecated, modify your code to use GeoRideTrackerPosition")
|
||||||
|
|
||||||
|
class GeorideTracker(GeoRideTracker):
|
||||||
|
""" Trip object representation """
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"GeorideTracker is deprecated, modify %s to use GeoRideTracker",
|
||||||
|
cls.__name__,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, *argv):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init__(*argv)
|
||||||
|
_LOGGER.warning("GeorideTracker is deprecated, modify your code to use GeoRideTracker")
|
||||||
|
|
||||||
|
|
||||||
|
class GeorideAccount(GeoRideAccount):
|
||||||
|
""" Trip object representation """
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"GeorideAccount is deprecated, modify %s to use GeoRideAccount",
|
||||||
|
cls.__name__,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, *argv):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init__(*argv)
|
||||||
|
_LOGGER.warning("GeorideAccount is deprecated, modify your code to use GeoRideAccount")
|
||||||
|
|
||||||
|
class GeorideUser(GeoRideUser):
|
||||||
|
""" Trip object representation """
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"GeorideUser is deprecated, modify %s to use GeoRideUser",
|
||||||
|
cls.__name__,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, *argv):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init__(*argv)
|
||||||
|
_LOGGER.warning("GeorideUser is deprecated, modify your code to use GeoRideUser")
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ handlers=consoleHandler
|
|||||||
qualname=engineio.client
|
qualname=engineio.client
|
||||||
propagate=0
|
propagate=0
|
||||||
|
|
||||||
|
|
||||||
[handler_consoleHandler]
|
[handler_consoleHandler]
|
||||||
class=StreamHandler
|
class=StreamHandler
|
||||||
level=DEBUG
|
level=DEBUG
|
||||||
|
|||||||
4
setup.py
4
setup.py
@@ -19,13 +19,13 @@ 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.8.2',
|
version='0.7.0',
|
||||||
description='Lib to control GeoRide tracker devices with theire rest api',
|
description='Lib to control GeoRide tracker devices with theire rest api',
|
||||||
author='Matthieu DUVAL',
|
author='Matthieu DUVAL',
|
||||||
author_email='georideapilib@duval-dev.fr',
|
author_email='georideapilib@duval-dev.fr',
|
||||||
# use the URL to the github repo
|
# use the URL to the github repo
|
||||||
url='https://github.com/hacf/georide-api',
|
url='https://github.com/hacf/georide-api',
|
||||||
download_url='https://codeload.github.com/hacf/georide-api/tar.gz/0.8.1',
|
download_url='https://codeload.github.com/hacf/georide-api/tar.gz/0.7.0',
|
||||||
keywords=['rest', 'georide', 'api', 'grutier', 'GeoRide'], # arbitrary keywords
|
keywords=['rest', 'georide', 'api', 'grutier', 'GeoRide'], # arbitrary keywords
|
||||||
classifiers=[],
|
classifiers=[],
|
||||||
install_requires=["python-socketio[client]==4.6.1"],
|
install_requires=["python-socketio[client]==4.6.1"],
|
||||||
|
|||||||
Reference in New Issue
Block a user