Refactor after enabling pylint

This commit is contained in:
2019-10-26 00:10:01 +02:00
parent cd5adffbd0
commit c30180221f
4 changed files with 684 additions and 556 deletions

View File

@@ -1,63 +1,72 @@
import api as GeorideApi
from objects import GeorideAccount
""" Example georideapilib code """
import datetime
import time
import datetime
from georideapilib.objects import GeorideAccount
import georideapilib.api as GeorideApi
""" If ypu out to reuse account """
"""
account = GeorideAccount(<your_id>, <yout_email>, <is_admin>, <your_token>)
"""
def example():
""" simple example function """
token = "<your_token>"# pylint: disable=C0301
account = GeorideAccount(0, "<your_email>", False, token)
""" Get an acces token """
account = GeorideApi.getAuthorisationToken("<your_email>", "<your_passord>")
print("token 1: ", account.authToken)
"""
GeorideApi.getAuthorisationToken("<your_email>", "<your_password>")
print("token 1: ", account.auth_token)
""" # pylint: disable=W0105
""" do not abuse, renew when previous token have almost reached time """
"""
account.authToken = GeorideApi.renewToken(account.authToken)
print("token 2: ", account.authToken)
"""
"""
account.auth_token = GeorideApi.renewToken(account.auth_token)
print("token 2: ", account.auth_token)
""" # pylint: disable=W0105
user = GeorideApi.getUser(account.authToken)
print("User: ", user.firstName)
user = GeorideApi.get_user(account.auth_token)
print("User: ", user.first_name)
trackers = GeorideApi.getTrackers(account.authToken)
tracker = trackers[0]
print("Tracker name: ", tracker.trackerName)
trackers = GeorideApi.get_trackers(account.auth_token)
tracker = trackers[0]
print("Tracker name: ", tracker.tracker_name)
trips = GeorideApi.getTrips(account.authToken, tracker.trackerId, "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')
print("Trip date: {}, from: {}, to: {}".format(trip_date, trip.niceStartAddress, trip.niceEndAddress))
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')
print("Trip date: {}, from: {}, to: {}".format(trip_date, trip.nice_start_address,
trip.nice_end_address))
positions = GeorideApi.getPositions(account.authToken, tracker.trackerId, "2019-10-10", "2019-10-24")
position = positions[0];
print("Position speed: {}, lon: {}, lat: {}".format(position.speed, position.longitude, position.latitude))
positions = GeorideApi.get_positions(account.auth_token, tracker.tracker_id,
"2019-10-10", "2019-10-24")
position = positions[0]
print("Position speed: {}, lon: {}, lat: {}".format(position.speed, position.longitude,
position.latitude))
tripShared = GeorideApi.shareATripByDate(account.authToken, tracker.trackerId, fromDate="2019-10-10", toDate="2019-10-24")
print("tripShared url: {}, id: {}".format(tripShared.url, tripShared.shareId))
trip_shared = GeorideApi.share_a_trip_by_date(account.auth_token, tracker.tracker_id,
"2019-10-10", "2019-10-24")
print("tripShared url: {}, id: {}".format(trip_shared.url, trip_shared.share_id))
time.sleep(30)
haveBeenLocked = GeorideApi.lockTracker(account.authToken, tracker.trackerId)
print("Tracker have been locked: ", haveBeenLocked)
time.sleep(10)
have_been_locked = GeorideApi.lock_tracker(account.auth_token, tracker.tracker_id)
print("Tracker have been locked: ", have_been_locked)
time.sleep(30)
haveBeenUnlocked = GeorideApi.lockTracker(account.authToken, tracker.trackerId)
print("Tracker have been unlocked: ", haveBeenUnlocked)
time.sleep(10)
have_been_unlocked = GeorideApi.unlock_tracker(account.auth_token, tracker.tracker_id)
print("Tracker have been unlocked: ", have_been_unlocked)
time.sleep(30)
isLocked = GeorideApi.toogleLockTracker(account.authToken, tracker.trackerId)
print("Tracker is locked: ", haveBeenUnlocked)
time.sleep(10)
is_locked = GeorideApi.toogle_lock_tracker(account.auth_token, tracker.tracker_id)
print("Tracker is locked: ", is_locked)
time.sleep(30)
trackers = GeorideApi.getTrackers(account.authToken)
tracker = trackers[0]
print("Tracker name: ", tracker.trackerName, " is locked: ", tracker.isLocked)
time.sleep(10)
trackers = GeorideApi.get_trackers(account.auth_token)
tracker = trackers[0]
print("Tracker name: ", tracker.tracker_name, " is locked: ", tracker.is_locked)
"""
GeorideApi.revokeToken(account.authToken)
"""
"""
GeorideApi.revokeToken(account.auth_token)
""" # pylint: disable=W0105
example()