From 93f089c4313a05cd6ee2a033ff3e03038c3f4809 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Tue, 26 May 2020 23:46:06 +0200 Subject: [PATCH 1/5] Update GeoRide trademark wording --- README.md | 4 +- examples/example.py | 30 ++++----- georideapilib/api.py | 24 +++---- georideapilib/exception.py | 2 +- georideapilib/objects.py | 127 ++++++++++++++++++++++++++++++++----- georideapilib/socket.py | 22 ++++++- logging.conf | 6 ++ setup.py | 6 +- 8 files changed, 168 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index 6f726d8..a9eecde 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# Georideapilib -![Logo Georide](georide-logo.png) +# georideapilib +![Logo GeoRide](georide-logo.png) ⚠️ this is not an official implementation diff --git a/examples/example.py b/examples/example.py index 791e7e3..84b4840 100644 --- a/examples/example.py +++ b/examples/example.py @@ -5,9 +5,9 @@ import time import datetime logging.config.fileConfig('logging.conf') -from georideapilib.objects import GeorideAccount -import georideapilib.api as GeorideApi -from georideapilib.socket import GeorideSocket +from georideapilib.objects import GeoRideAccount +import georideapilib.api as GeoRideApi +from georideapilib.socket import GeoRideSocket from threading import Thread @@ -20,17 +20,17 @@ def example(): # account = GeorideAccount(0, "", False, token) - account = GeorideApi.get_authorisation_token("", "") + account = GeoRideApi.get_authorisation_token("", "") print("token 1: ", account.auth_token) _LOGGER.info("token 1: %s", account.auth_token) # pylint: disable=W0105 def locked_locked(data): - _LOGGER.info("Locke received") + _LOGGER.info("Lock received") def connect_socket(account): - socket = GeorideSocket() + socket = GeoRideSocket() socket.subscribe_locked(locked_locked) socket.init() socket.connect(account.auth_token) @@ -45,44 +45,44 @@ def example(): print("token 2: ", account.auth_token) """ # pylint: disable=W0105 - user = GeorideApi.get_user(account.auth_token) + user = GeoRideApi.get_user(account.auth_token) _LOGGER.info("User: %s", user.first_name) - trackers = GeorideApi.get_trackers(account.auth_token) + trackers = GeoRideApi.get_trackers(account.auth_token) tracker = trackers[0] _LOGGER.info("Tracker name: %s", tracker.tracker_name) - trips = GeorideApi.get_trips(account.auth_token, tracker.tracker_id, "2019-10-10", "2019-10-24") + trips = GeoRideApi.get_trips(account.auth_token, tracker.tracker_id, "2019-10-10", "2019-10-24") trip = trips[0] trip_date = datetime.datetime.strptime("2019-10-10T06:45:34.000Z", '%Y-%m-%dT%H:%M:%S.%fZ') _LOGGER.info("Trip date: %s, from: %s, to: %s", trip_date, trip.nice_start_address, trip.nice_end_address) - positions = GeorideApi.get_positions(account.auth_token, tracker.tracker_id, + positions = GeoRideApi.get_positions(account.auth_token, tracker.tracker_id, "2019-10-10", "2019-10-24") position = positions[0] _LOGGER.info("Position speed: %s, lon: %s, lat: %s", position.speed, position.longitude, position.latitude) - trip_shared = GeorideApi.share_a_trip_by_date(account.auth_token, tracker.tracker_id, + trip_shared = GeoRideApi.share_a_trip_by_date(account.auth_token, tracker.tracker_id, "2019-10-10", "2019-10-24") _LOGGER.info("tripShared url: %s, id: %s", trip_shared.url, trip_shared.share_id) time.sleep(10) - have_been_locked = GeorideApi.lock_tracker(account.auth_token, tracker.tracker_id) + have_been_locked = GeoRideApi.lock_tracker(account.auth_token, tracker.tracker_id) _LOGGER.info("Tracker have been locked: %s", have_been_locked) time.sleep(10) - have_been_unlocked = GeorideApi.unlock_tracker(account.auth_token, tracker.tracker_id) + have_been_unlocked = GeoRideApi.unlock_tracker(account.auth_token, tracker.tracker_id) _LOGGER.info("Tracker have been unlocked: %s", have_been_unlocked) time.sleep(10) - is_locked = GeorideApi.toogle_lock_tracker(account.auth_token, tracker.tracker_id) + is_locked = GeoRideApi.toogle_lock_tracker(account.auth_token, tracker.tracker_id) _LOGGER.info("Tracker is locked: %s", is_locked) time.sleep(10) - trackers = GeorideApi.get_trackers(account.auth_token) + trackers = GeoRideApi.get_trackers(account.auth_token) tracker = trackers[0] _LOGGER.info("Tracker name: %s is locked: %s", tracker.tracker_name, tracker.is_locked) diff --git a/georideapilib/api.py b/georideapilib/api.py index 4d72f09..3475997 100644 --- a/georideapilib/api.py +++ b/georideapilib/api.py @@ -8,12 +8,12 @@ import logging import requests from georideapilib.objects import ( - GeorideTracker, - GeorideAccount, - GeorideUser, - GeorideTrackerTrip, - GeorideTrackerPosition, - GeorideSharedTrip + GeoRideTracker, + GeoRideAccount, + GeoRideUser, + GeoRideTrackerTrip, + GeoRideTrackerPosition, + GeoRideSharedTrip ) from georideapilib.exception import ( @@ -51,7 +51,7 @@ def get_authorisation_token(email, password): if response.status_code == 200: _LOGGER.debug("Login success") response_data = response.json() - account = GeorideAccount.from_json(response_data) + account = GeoRideAccount.from_json(response_data) elif response.status_code == 403: _LOGGER.warning("Login failed") raise LoginException(get_authorisation_token, "Login failed") @@ -104,7 +104,7 @@ def get_user(token): headers=headers) response_data = response.json() _LOGGER.debug(response_data) - account = GeorideUser.from_json(response_data) + account = GeoRideUser.from_json(response_data) return account def get_trackers(token): @@ -117,7 +117,7 @@ def get_trackers(token): response_data = response.json() trackers = [] for json_tracker in response_data: - trackers.append(GeorideTracker.from_json(json_tracker)) + trackers.append(GeoRideTracker.from_json(json_tracker)) return trackers @@ -132,7 +132,7 @@ def get_trips(token, tracker_id, from_date, to_date): response_data = response.json() trips = [] for json_trip in response_data: - trips.append(GeorideTrackerTrip.from_json(json_trip)) + trips.append(GeoRideTrackerTrip.from_json(json_trip)) return trips def get_positions(token, tracker_id, from_date, to_date): @@ -146,7 +146,7 @@ def get_positions(token, tracker_id, from_date, to_date): response_data = response.json() positions = [] for json_position in response_data: - positions.append(GeorideTrackerPosition.from_json(json_position)) + positions.append(GeoRideTrackerPosition.from_json(json_position)) return positions def share_a_trip_by_trip_id(token, tracker_id, trip_id): @@ -184,7 +184,7 @@ def _share_a_trip(token, tracker_id, trip_id=None, from_date=None, # pylint: dis headers=headers) response_data = response.json() - return GeorideSharedTrip.from_json(response_data) + return GeoRideSharedTrip.from_json(response_data) def lock_tracker(token, tracker_id): """ used to lock a tracker """ diff --git a/georideapilib/exception.py b/georideapilib/exception.py index 07c58b4..74528d1 100644 --- a/georideapilib/exception.py +++ b/georideapilib/exception.py @@ -1,4 +1,4 @@ -""" all geroide exception """ +""" all GeoRide exception """ class Error(Exception): """Base class for exceptions in this module.""" diff --git a/georideapilib/objects.py b/georideapilib/objects.py index 9bf9767..d93047b 100644 --- a/georideapilib/objects.py +++ b/georideapilib/objects.py @@ -3,7 +3,12 @@ Georide objects implementation @author Matthieu DUVAL """ -class GeorideSharedTrip: +import logging + + +_LOGGER = logging.getLogger(__name__) + +class GeoRideSharedTrip: """ Shared trip object representation """ def __init__(self, url, shareId): self._url = url @@ -22,12 +27,12 @@ class GeorideSharedTrip: @staticmethod def from_json(json): """return new object fromjson""" - return GeorideSharedTrip( + return GeoRideSharedTrip( json['url'], json['shareId'] ) -class GeorideTrackerTrip: # pylint: disable=too-many-instance-attributes +class GeoRideTrackerTrip: # pylint: disable=too-many-instance-attributes """ Trip object representation """ def __init__(self, trip_id, tracker_id, average_speed, max_speed, distance, duration, # pylint: disable=R0914, R0913 start_address, nice_start_address, start_lat, start_lon, end_address, @@ -134,7 +139,7 @@ class GeorideTrackerTrip: # pylint: disable=too-many-instance-attributes @staticmethod def from_json(json): """return new object from json""" - return GeorideTrackerTrip( + return GeoRideTrackerTrip( json['id'], json['trackerId'], json['averageSpeed'], @@ -153,8 +158,7 @@ class GeorideTrackerTrip: # pylint: disable=too-many-instance-attributes json['endTime'] ) - -class GeorideTrackerPosition: +class GeoRideTrackerPosition: """ Tracker position object representation """ def __init__(self, fixtime, latitude, longitude, altitude, speed, address): # pylint: disable= R0913 self._fixtime = fixtime @@ -197,7 +201,7 @@ class GeorideTrackerPosition: @staticmethod def from_json(json): """return new object fromjson""" - return GeorideTrackerPosition( + return GeoRideTrackerPosition( json['fixtime'], json['latitude'], json['longitude'], @@ -206,10 +210,7 @@ class GeorideTrackerPosition: json['address'] ) - - - -class GeorideTracker: # pylint: disable=R0904,R0902 +class GeoRideTracker: # pylint: disable=R0904,R0902 """ Tracker position object representation """ def __init__(self, tracker_id, tracker_name, device_button_action, device_button_delay, # pylint: disable= R0913, R0914, R0915 vibration_level, is_old_tracker, auto_lock_freezed_to, fixtime, role, @@ -490,7 +491,7 @@ class GeorideTracker: # pylint: disable=R0904,R0902 @staticmethod def from_json(json): """return new object fromjson""" - return GeorideTracker( + return GeoRideTracker( json['trackerId'], json['trackerName'], json['deviceButtonAction'], @@ -530,8 +531,7 @@ class GeorideTracker: # pylint: disable=R0904,R0902 json['status'] ) - -class GeorideAccount: +class GeoRideAccount: """ Account object representation """ def __init__(self, account_id, email, is_admin, auth_token): self._account_id = account_id @@ -567,7 +567,7 @@ class GeorideAccount: @staticmethod def from_json(json): """return new object from_json""" - return GeorideAccount( + return GeoRideAccount( json['id'], json['email'], json['isAdmin'], @@ -575,7 +575,8 @@ class GeorideAccount: ) -class GeorideUser: # pylint: disable= R0902 + +class GeoRideUser: # pylint: disable= R0902 """ User object representation """ def __init__(self, user_id, email, first_name, created_at, phone_number, # pylint: disable= R0913 push_user_token, legal, date_of_birth): @@ -631,7 +632,7 @@ class GeorideUser: # pylint: disable= R0902 @staticmethod def from_json(json): """return new object fromjson""" - return GeorideUser( + return GeoRideUser( json['id'], json['email'], json['firstName'], @@ -641,3 +642,95 @@ class GeorideUser: # pylint: disable= R0902 json['legal'], 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") diff --git a/georideapilib/socket.py b/georideapilib/socket.py index 356bde7..505bc73 100644 --- a/georideapilib/socket.py +++ b/georideapilib/socket.py @@ -1,4 +1,4 @@ -""" Georide socket-io implementation """ +""" GeoRide socket-io implementation """ import logging import socketio @@ -19,8 +19,8 @@ def on_disconnect(): _LOGGER.debug('GeoRide socket disconnected') -class GeorideSocket(): - """docstring for GeorideSocket""" +class GeoRideSocket(): + """docstring for GeoRideSocket""" def __init__(self): self._on_message_callback = None self._on_device_callback = None @@ -112,3 +112,19 @@ class GeorideSocket(): def disconnect(self): """disconnect from the georide socket""" sio.disconnect() + + +#TODO: remove in v0.8.0 +class GeorideSocket(GeoRideSocket): + """ Trip object representation """ + def __init_subclass__(cls, **kwargs): + """Print deprecation warning.""" + super().__init_subclass__(**kwargs) + _LOGGER.warning( + "GeorideSocket is deprecated, modify %s to use GeoRideSocket", + cls.__name__, + ) + def __init__(self, *argv): + """Print deprecation warning.""" + super().__init__(*argv) + _LOGGER.warning("GeorideSocket is deprecated, modify your code to use GeoRideSocket") \ No newline at end of file diff --git a/logging.conf b/logging.conf index da3b459..8fcfa2a 100644 --- a/logging.conf +++ b/logging.conf @@ -17,6 +17,12 @@ handlers=consoleHandler qualname=simpleExample propagate=0 +[logger_engine_io] +level=ERROR +handlers=consoleHandler +qualname=engineio.client +propagate=0 + [handler_consoleHandler] class=StreamHandler diff --git a/setup.py b/setup.py index decb6aa..923ad04 100644 --- a/setup.py +++ b/setup.py @@ -19,14 +19,14 @@ CURRENT_DIR = os.path.dirname(__file__) setup( name='georideapilib', packages=['georideapilib'], # this must be the same as the name above - version='0.4.4', - description='Lib to control georide tracker devices with their rest api', + version='0.5.0', + description='Lib to control GeoRide tracker devices with their rest api', author='Matthieu DUVAL', author_email='georideapilib@duval-dev.fr', # use the URL to the github repo url='https://github.com/ptimatth/pyGeoride', download_url='https://codeload.github.com/ptimatth/pyGeoride/tar.gz/0.1.0', - keywords=['rest', 'georide', 'api', 'grutier'], # arbitrary keywords + keywords=['rest', 'georide', 'api', 'grutier', 'GeoRide'], # arbitrary keywords classifiers=[], install_requires=["python-socketio[client]"], tests_require=[ From 60254999dfa3a3e9e80bb5ce464d6eacfb285312 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Tue, 1 Dec 2020 19:49:40 +0100 Subject: [PATCH 2/5] Small wording fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a9eecde..ecee3ff 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Official georide website: https://georide.fr/ -This library can control your georide tracker tracker +This library can control your georide tracker Some code have been taken from @alexmohr https://github.com/alexmohr/sonyapilib From 859d962cae8df53e6e6551a594428904405caa3d Mon Sep 17 00:00:00 2001 From: Matthieu Date: Sat, 10 Apr 2021 20:02:44 +0200 Subject: [PATCH 3/5] Update wording and add new method for tracker --- examples/example.py | 2 +- georideapilib/api.py | 2 ++ georideapilib/objects.py | 69 ++++++++++++++++++++++++++++++++++------ setup.py | 4 +-- 4 files changed, 65 insertions(+), 12 deletions(-) diff --git a/examples/example.py b/examples/example.py index 84b4840..902bbe3 100644 --- a/examples/example.py +++ b/examples/example.py @@ -41,7 +41,7 @@ def example(): thread.start() """ - account.auth_token = GeorideApi.renewToken(account.auth_token) + account.auth_token = GeoRideApi.renewToken(account.auth_token) print("token 2: ", account.auth_token) """ # pylint: disable=W0105 diff --git a/georideapilib/api.py b/georideapilib/api.py index 3475997..f3c5128 100644 --- a/georideapilib/api.py +++ b/georideapilib/api.py @@ -109,6 +109,7 @@ def get_user(token): def get_trackers(token): """ get user trackers """ + headers = {"Authorization": "Bearer " + token} response = _SESSION.get( GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRAKERS, @@ -117,6 +118,7 @@ def get_trackers(token): response_data = response.json() trackers = [] for json_tracker in response_data: + _LOGGER.debug(json_tracker) trackers.append(GeoRideTracker.from_json(json_tracker)) return trackers diff --git a/georideapilib/objects.py b/georideapilib/objects.py index d93047b..a252221 100644 --- a/georideapilib/objects.py +++ b/georideapilib/objects.py @@ -226,27 +226,27 @@ class GeoRideTracker: # pylint: disable=R0904,R0902 self._device_button_delay = device_button_delay self._vibration_level = vibration_level self._is_old_tracker = is_old_tracker - self._auto_lock_freezed_to = auto_lock_freezed_to + self._position_id = position_id self._fixtime = fixtime + self._latitude = latitude + self._longitude = longitude + self._altitude = altitude + self._locked_position_id = locked_position_id + self._locked_latitude = locked_latitude + self._locked_longitude = locked_longitude self._role = role + self._subscription_id = subscription_id self._last_payment_date = last_payment_date self._gift_card_id = gift_card_id self._expires = expires self._activation_date = activation_date self._odometer = odometer + self._is_locked = is_locked self._is_stolen = is_stolen self._is_crashed = is_crashed self._crash_detection_disabled = crash_detection_disabled self._speed = speed self._moving = moving - self._position_id = position_id - self._latitude = latitude - self._longitude = longitude - self._altitude = altitude - self._locked_position_id = locked_position_id - self._locked_latitude = locked_latitude - self._locked_longitude = locked_longitude - self._is_locked = is_locked self._can_see_position = can_see_position self._can_lock = can_lock self._can_unlock = can_unlock @@ -257,6 +257,7 @@ class GeoRideTracker: # pylint: disable=R0904,R0902 self._can_send_broken_down_signal = can_send_broken_down_signal self._can_send_stolen_signal = can_send_stolen_signal self._status = status + self._auto_lock_freezed_to = auto_lock_freezed_to @property def tracker_id(self): @@ -337,12 +338,22 @@ class GeoRideTracker: # pylint: disable=R0904,R0902 def is_stolen(self): """ is_stolen """ return self._is_stolen + + @is_stolen.setter + def is_stolen(self, is_stolen): + """ is_stolen setter""" + self._is_stolen = is_stolen @property def is_crashed(self): """ is_crashed """ return self._is_crashed + @is_crashed.setter + def is_crashed(self, is_crashed): + """ is_crashed setter""" + self._is_crashed = is_crashed + @property def crash_detection_disabled(self): """ crash_detection_disabled """ @@ -531,6 +542,46 @@ class GeoRideTracker: # pylint: disable=R0904,R0902 json['status'] ) + def update_all_data(self, tracker): + """update all data of th tracker from anew object""" + self._tracker_name = tracker.tracker_name + self._device_button_action = tracker.device_button_action + self._device_button_delay = tracker.device_button_delay + self._vibration_level = tracker.vibration_level + self._is_old_tracker = tracker.is_old_tracker + self._position_id = tracker.position_id + self._fixtime = tracker.fixtime + self._latitude = tracker.latitude + self._longitude = tracker.longitude + self._altitude = tracker.altitude + self._locked_position_id = tracker.locked_position_id + self._locked_latitude = tracker.locked_latitude + self._locked_longitude = tracker.locked_longitude + self._role = tracker.role + self._subscription_id = tracker.subscription_id + self._last_payment_date = tracker.last_payment_date + self._gift_card_id = tracker.gift_card_id + self._expires = tracker.expires + self._activation_date = tracker.activation_date + self._odometer = tracker.odometer + self._is_locked = tracker.is_locked + self._is_stolen = tracker.is_stolen + self._is_crashed = tracker.is_crashed + self._crash_detection_disabled = tracker.crash_detection_disabled + self._speed = tracker.speed + self._moving = tracker.moving + self._can_see_position = tracker.can_see_position + self._can_lock = tracker.can_lock + self._can_unlock = tracker.can_unlock + self._can_share = tracker.can_share + self._can_unshare = tracker.can_unshare + self._can_check_speed = tracker.can_check_speed + self._can_see_statistics = tracker.can_see_statistics + self._can_send_broken_down_signal = tracker.can_send_broken_down_signal + self._can_send_stolen_signal = tracker.can_send_stolen_signal + self._status = tracker.status + self._auto_lock_freezed_to = tracker.auto_lock_freezed_to + class GeoRideAccount: """ Account object representation """ def __init__(self, account_id, email, is_admin, auth_token): diff --git a/setup.py b/setup.py index 923ad04..7eb5d6a 100644 --- a/setup.py +++ b/setup.py @@ -24,8 +24,8 @@ setup( author='Matthieu DUVAL', author_email='georideapilib@duval-dev.fr', # use the URL to the github repo - url='https://github.com/ptimatth/pyGeoride', - download_url='https://codeload.github.com/ptimatth/pyGeoride/tar.gz/0.1.0', + url='https://github.com/hacf/georide-api', + download_url='https://codeload.github.com/hacf/georide-api/tar.gz/0.5.0', keywords=['rest', 'georide', 'api', 'grutier', 'GeoRide'], # arbitrary keywords classifiers=[], install_requires=["python-socketio[client]"], From 3053f2db697e3b9b692f9acd15cedb3a7a02e9e0 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Sat, 10 Apr 2021 22:49:21 +0200 Subject: [PATCH 4/5] Fix small mistakes --- .gitignore | 3 ++- georideapilib/objects.py | 2 -- setup.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 688707c..0030e1a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ examples/__main__.py __pycache__ **/__pycache__ dist/ -*.egg-info/ \ No newline at end of file +*.egg-info/ +build/ \ No newline at end of file diff --git a/georideapilib/objects.py b/georideapilib/objects.py index a252221..a8fe220 100644 --- a/georideapilib/objects.py +++ b/georideapilib/objects.py @@ -235,7 +235,6 @@ class GeoRideTracker: # pylint: disable=R0904,R0902 self._locked_latitude = locked_latitude self._locked_longitude = locked_longitude self._role = role - self._subscription_id = subscription_id self._last_payment_date = last_payment_date self._gift_card_id = gift_card_id self._expires = expires @@ -558,7 +557,6 @@ class GeoRideTracker: # pylint: disable=R0904,R0902 self._locked_latitude = tracker.locked_latitude self._locked_longitude = tracker.locked_longitude self._role = tracker.role - self._subscription_id = tracker.subscription_id self._last_payment_date = tracker.last_payment_date self._gift_card_id = tracker.gift_card_id self._expires = tracker.expires diff --git a/setup.py b/setup.py index 7eb5d6a..a085e99 100644 --- a/setup.py +++ b/setup.py @@ -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.5.0', + version='0.5.1', description='Lib to control GeoRide tracker devices with their rest api', author='Matthieu DUVAL', author_email='georideapilib@duval-dev.fr', From a05b5bdaa6ef3312b7374d684d2e487564e1217a Mon Sep 17 00:00:00 2001 From: Matthieu Date: Sun, 11 Apr 2021 12:42:16 +0200 Subject: [PATCH 5/5] Add new tracker fields --- georideapilib/objects.py | 55 +++++++++++++++++++++++++++++++++++++--- setup.py | 4 +-- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/georideapilib/objects.py b/georideapilib/objects.py index a8fe220..55e6e75 100644 --- a/georideapilib/objects.py +++ b/georideapilib/objects.py @@ -219,7 +219,8 @@ class GeoRideTracker: # pylint: disable=R0904,R0902 longitude, altitude, locked_position_id, locked_latitude, locked_longitude, is_locked, can_see_position, can_lock, can_unlock, can_share, can_unshare, can_check_speed, can_see_statistics, can_send_broken_down_signal, - can_send_stolen_signal, status): + can_send_stolen_signal, status, subscription_id, external_battery_voltage, + internal_battery_voltage, timezone, is_second_gen, is_up_to_date): self._tracker_id = tracker_id self._tracker_name = tracker_name self._device_button_action = device_button_action @@ -257,7 +258,12 @@ class GeoRideTracker: # pylint: disable=R0904,R0902 self._can_send_stolen_signal = can_send_stolen_signal self._status = status self._auto_lock_freezed_to = auto_lock_freezed_to - + self._subscription_id = subscription_id + self._external_battery_voltage = external_battery_voltage + self._internal_battery_voltage = internal_battery_voltage + self._timezone = timezone + self._is_second_gen = is_second_gen + self._is_up_to_date = is_up_to_date @property def tracker_id(self): """ tracker_id """ @@ -498,6 +504,37 @@ class GeoRideTracker: # pylint: disable=R0904,R0902 """ status """ self._status = status + @property + def subscription_id(self): + """subscription_id property""" + return self._subscription_id + + @property + def external_battery_voltage(self): + """_external_battery_voltage property""" + return self._external_battery_voltage + + @property + def internal_battery_voltage(self): + """internal_battery_voltage property""" + return self._internal_battery_voltage + + @property + def timezone(self): + """timezone property""" + return self._timezone + + @property + def is_second_gen(self): + """is_second_gen property""" + return self._is_second_gen + + @property + def is_up_to_date(self): + """is_up_to_date property""" + return self._is_up_to_date + + @staticmethod def from_json(json): """return new object fromjson""" @@ -538,7 +575,13 @@ class GeoRideTracker: # pylint: disable=R0904,R0902 json['canSeeStatistics'], json['canSendBrokenDownSignal'], json['canSendStolenSignal'], - json['status'] + json['status'], + None if json['subscriptionId'] == "None" else json['subscriptionId'], + None if json['externalBatteryVoltage'] == "None" else json['externalBatteryVoltage'], + None if json['internalBatteryVoltage'] == "None" else json['internalBatteryVoltage'], + json['timezone'], + json['isSecondGen'], + json['isUpToDate'] ) def update_all_data(self, tracker): @@ -579,6 +622,12 @@ class GeoRideTracker: # pylint: disable=R0904,R0902 self._can_send_stolen_signal = tracker.can_send_stolen_signal self._status = tracker.status self._auto_lock_freezed_to = tracker.auto_lock_freezed_to + self._subscription_id = tracker.subscription_id + self._external_battery_voltage = tracker.external_battery_voltage + self._internal_battery_voltage = tracker.internal_battery_voltage + self._timezone = tracker.timezone + self._is_second_gen = tracker.is_second_gen + self._is_up_to_date = tracker.is_up_to_date class GeoRideAccount: """ Account object representation """ diff --git a/setup.py b/setup.py index a085e99..10451a3 100644 --- a/setup.py +++ b/setup.py @@ -19,13 +19,13 @@ CURRENT_DIR = os.path.dirname(__file__) setup( name='georideapilib', packages=['georideapilib'], # this must be the same as the name above - version='0.5.1', + version='0.6.0', description='Lib to control GeoRide tracker devices with their rest api', author='Matthieu DUVAL', author_email='georideapilib@duval-dev.fr', # use the URL to the github repo url='https://github.com/hacf/georide-api', - download_url='https://codeload.github.com/hacf/georide-api/tar.gz/0.5.0', + download_url='https://codeload.github.com/hacf/georide-api/tar.gz/0.6.0', keywords=['rest', 'georide', 'api', 'grutier', 'GeoRide'], # arbitrary keywords classifiers=[], install_requires=["python-socketio[client]"],