Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 39b2c3c776 | |||
|
|
7e399cf982 | ||
| 733ef83127 | |||
| edf209272d | |||
| b53fdc07f8 | |||
| 9c7d2890da | |||
| d93bab0fcf | |||
| eb260b7a7e | |||
| e29e530d42 | |||
| 6db3afcd28 | |||
| 841740ec4c | |||
| 00c66320b5 | |||
| a01bb7bb7f | |||
| e85903bf8b | |||
| 5823012259 | |||
| a62ae48001 | |||
| 7dec38109a | |||
| e6e471deae | |||
| b6ede1af3b | |||
| 6f02f0b925 | |||
| e38a402d44 | |||
| a05b5bdaa6 | |||
| 3053f2db69 | |||
| 859d962cae | |||
| 60254999df | |||
| 93f089c431 | |||
| e59cd77908 | |||
| 1275ffa882 | |||
| 6ab8749f11 | |||
| 9923f45a95 | |||
| 13df6822c8 | |||
| 9bb33b6020 | |||
| b78c503b31 | |||
| b0caa42ca2 | |||
| e69b2dfab9 | |||
| 0368c17321 | |||
| f168ad9e47 | |||
| 3e53a339ba | |||
| c548a789a8 | |||
| 1660b1eb3a | |||
| 602b081dd7 | |||
| 6d8330a2b5 | |||
| 1706631393 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,3 +1,7 @@
|
|||||||
examples/__main__.py
|
examples/__main__.py
|
||||||
__pycache__
|
__pycache__
|
||||||
**/__pycache__
|
**/__pycache__
|
||||||
|
dist/
|
||||||
|
*.egg-info/
|
||||||
|
build/
|
||||||
|
ressources/
|
||||||
674
LICENSE
Normal file
674
LICENSE
Normal file
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
13
README.md
13
README.md
@@ -1,16 +1,18 @@
|
|||||||
# Georideapilib
|
# georideapilib
|
||||||

|

|
||||||
|
|
||||||
⚠️ 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
|
||||||
|
|
||||||
|
|
||||||
Some code have been taken from @alexmohr https://github.com/alexmohr/sonyapilib
|
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.
|
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.
|
||||||
|
|
||||||
@@ -25,8 +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/pyGeoride
|
- https://github.com/ptimatth/georide-api
|
||||||
|
|
||||||
## Todo
|
## Todo
|
||||||
- [ ] Add support of SocketIO connection
|
|
||||||
- [ ] Add support of "Get a shared trip" endpoint
|
- [ ] Add support of "Get a shared trip" endpoint
|
||||||
|
|||||||
@@ -1,72 +1,128 @@
|
|||||||
""" Example georideapilib code """
|
""" Example georideapilib code """
|
||||||
|
import logging.config
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import datetime
|
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
|
from threading import Thread
|
||||||
import georideapilib.api as GeorideApi
|
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger('example')
|
||||||
|
|
||||||
|
DATE_START="2019-10-10"
|
||||||
|
DATE_END="2019-10-24"
|
||||||
|
|
||||||
def example():
|
def example():
|
||||||
""" simple example function """
|
""" simple example function """
|
||||||
token = "<your_token>"# pylint: disable=C0301
|
# token = "<your_token>"# pylint: disable=C0301
|
||||||
account = GeorideAccount(0, "<your_email>", False, token)
|
# account = GeoRideAccount(0, "<your_email>", False, token)
|
||||||
|
|
||||||
"""
|
|
||||||
GeorideApi.getAuthorisationToken("<your_email>", "<your_password>")
|
account = GeoRideApi.get_authorisation_token("<your_email>", "<your_password>")
|
||||||
print("token 1: ", account.auth_token)
|
print("token 1: ", account.auth_token)
|
||||||
""" # pylint: disable=W0105
|
_LOGGER.info("token 1: %s", account.auth_token)
|
||||||
|
# pylint: disable=W0105
|
||||||
|
|
||||||
|
def locked_locked(data):
|
||||||
|
_LOGGER.info("Lock received")
|
||||||
|
|
||||||
|
def refresh_tracker():
|
||||||
|
_LOGGER.info("Refresh tracker recieved")
|
||||||
|
|
||||||
|
def connect_socket(account):
|
||||||
|
socket = GeoRideSocket()
|
||||||
|
socket.subscribe_locked(locked_locked)
|
||||||
|
socket.subscribe_refresh_tracker(refresh_tracker)
|
||||||
|
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)
|
||||||
print("token 2: ", account.auth_token)
|
print("token 2: ", account.auth_token)
|
||||||
""" # pylint: disable=W0105
|
""" # pylint: disable=W0105
|
||||||
|
|
||||||
user = GeorideApi.get_user(account.auth_token)
|
user = GeoRideApi.get_user(account.auth_token)
|
||||||
print("User: ", user.first_name)
|
_LOGGER.info("User: %s", user.first_name)
|
||||||
|
|
||||||
trackers = GeorideApi.get_trackers(account.auth_token)
|
trackers = GeoRideApi.get_trackers(account.auth_token)
|
||||||
tracker = trackers[0]
|
tracker = trackers[0]
|
||||||
print("Tracker name: ", tracker.tracker_name)
|
_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, DATE_START, DATE_END)
|
||||||
trip = trips[0]
|
if len(trips) < 1:
|
||||||
trip_date = datetime.datetime.strptime("2019-10-10T06:45:34.000Z", '%Y-%m-%dT%H:%M:%S.%fZ')
|
_LOGGER.info("No trip found for tracker name: %s between: %s and %s", tracker.tracker_name, DATE_START, DATE_END)
|
||||||
print("Trip date: {}, from: {}, to: {}".format(trip_date, trip.nice_start_address,
|
else:
|
||||||
trip.nice_end_address))
|
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")
|
DATE_START, DATE_END)
|
||||||
position = positions[0]
|
if len(positions) < 1:
|
||||||
print("Position speed: {}, lon: {}, lat: {}".format(position.speed, position.longitude,
|
_LOGGER.info("No positions found for tracker name: %s between: %s and %s", tracker.tracker_name, DATE_START, DATE_END)
|
||||||
position.latitude))
|
else:
|
||||||
|
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,
|
DATE_START, DATE_END)
|
||||||
"2019-10-10", "2019-10-24")
|
_LOGGER.info("tripShared url: %s, id: %s", trip_shared.url, trip_shared.share_id)
|
||||||
print("tripShared url: {}, id: {}".format(trip_shared.url, trip_shared.share_id))
|
|
||||||
|
|
||||||
time.sleep(10)
|
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)
|
||||||
print("Tracker have been locked: ", have_been_locked)
|
_LOGGER.info("Tracker have been locked: %s", have_been_locked)
|
||||||
|
|
||||||
time.sleep(10)
|
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)
|
||||||
print("Tracker have been unlocked: ", have_been_unlocked)
|
_LOGGER.info("Tracker have been unlocked: %s", have_been_unlocked)
|
||||||
|
|
||||||
time.sleep(10)
|
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)
|
||||||
print("Tracker is locked: ", is_locked)
|
_LOGGER.info("Tracker is locked: %s", is_locked)
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
trackers = GeorideApi.get_trackers(account.auth_token)
|
trackers = GeoRideApi.get_trackers(account.auth_token)
|
||||||
tracker = trackers[0]
|
tracker = trackers[0]
|
||||||
print("Tracker name: ", tracker.tracker_name, " is locked: ", tracker.is_locked)
|
_LOGGER.info("Tracker name: %s is locked: %s", tracker.tracker_name, tracker.is_locked)
|
||||||
|
|
||||||
|
if tracker.version >= 3:
|
||||||
|
_LOGGER.info("Congrat for your new gen GeoRide \o/")
|
||||||
|
|
||||||
|
# Have been commented for your neighbor ;)
|
||||||
|
# time.sleep(10)
|
||||||
|
# have_been_siren_turned_on = GeoRideApi.change_tracker_siren_state(account.auth_token, tracker.tracker_id, True)
|
||||||
|
# _LOGGER.info("Tracker siren is on: %s", have_been_siren_turned_on)
|
||||||
|
|
||||||
|
# time.sleep(5)
|
||||||
|
# have_been_siren_turned_off = GeoRideApi.change_tracker_siren_state(account.auth_token, tracker.tracker_id, False)
|
||||||
|
# _LOGGER.info("Tracker siren is off: %s", have_been_siren_turned_off)
|
||||||
|
|
||||||
|
time.sleep(10)
|
||||||
|
changed_to_eco_mode = GeoRideApi.change_tracker_eco_mode_state(account.auth_token, tracker.tracker_id, True)
|
||||||
|
_LOGGER.info("Tracker eco mode is on: %s", changed_to_eco_mode)
|
||||||
|
|
||||||
|
time.sleep(5)
|
||||||
|
changed_to_normal_mode = GeoRideApi.change_tracker_eco_mode_state(account.auth_token, tracker.tracker_id, False)
|
||||||
|
_LOGGER.info("Tracker eco mode is off: %s", changed_to_normal_mode)
|
||||||
|
|
||||||
|
tracker_beacon = GeoRideApi.get_tracker_beacon(account.auth_token, tracker.tracker_id)
|
||||||
|
_LOGGER.info("Your tracker beacon state: %s", tracker_beacon)
|
||||||
|
|
||||||
|
#you can also shutdown your tracker with shutdown_tracker(<token>, tracker_id) but i d'on give you an example.
|
||||||
|
else:
|
||||||
|
_LOGGER.info("You are from the first wave ;)")
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
GeorideApi.revokeToken(account.auth_token)
|
GeorideApi.revokeToken(account.auth_token)
|
||||||
""" # pylint: disable=W0105
|
""" # pylint: disable=W0105
|
||||||
|
example()
|
||||||
example()
|
|
||||||
|
|||||||
@@ -4,15 +4,22 @@ Georide api lib
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import urllib3
|
import logging
|
||||||
|
import requests
|
||||||
from georideapilib.objects import (
|
from georideapilib.objects import (
|
||||||
GeorideTracker,
|
GeoRideTracker,
|
||||||
GeorideAccount,
|
GeoRideAccount,
|
||||||
GeorideUser,
|
GeoRideUser,
|
||||||
GeorideTrackerTrip,
|
GeoRideTrackerTrip,
|
||||||
GeorideTrackerPosition,
|
GeoRideTrackerPosition,
|
||||||
GeorideSharedTrip
|
GeoRideSharedTrip,
|
||||||
|
GeoRideTrackerBeacon
|
||||||
|
)
|
||||||
|
|
||||||
|
from georideapilib.exception import (
|
||||||
|
LoginException,
|
||||||
|
SeverException,
|
||||||
|
UnauthorizedException
|
||||||
)
|
)
|
||||||
|
|
||||||
GEORIDE_API_HOST = "https://api.georide.fr"
|
GEORIDE_API_HOST = "https://api.georide.fr"
|
||||||
@@ -20,114 +27,152 @@ GEORIDE_API_ENDPOINT_LOGIN = "/user/login"
|
|||||||
GEORIDE_API_ENDPOINT_NEW_TOKEN = "/user/new-token"
|
GEORIDE_API_ENDPOINT_NEW_TOKEN = "/user/new-token"
|
||||||
GEORIDE_API_ENDPOINT_LOGOUT = "/user/logout"
|
GEORIDE_API_ENDPOINT_LOGOUT = "/user/logout"
|
||||||
GEORIDE_API_ENDPOINT_USER = "/user"
|
GEORIDE_API_ENDPOINT_USER = "/user"
|
||||||
GEORIDE_API_ENDPOINT_TRAKERS = "/user/trackers"
|
GEORIDE_API_ENDPOINT_TRACKERS = "/user/trackers"
|
||||||
GEORIDE_API_ENDPOINT_TRIPS = "/tracker/:trackerId/trips"
|
GEORIDE_API_ENDPOINT_TRIPS = "/tracker/{trackerId}/trips"
|
||||||
GEORIDE_API_ENDPOINT_LOCK = "/tracker/:trackerId/lock"
|
GEORIDE_API_ENDPOINT_LOCK = "/tracker/{trackerId}/lock"
|
||||||
GEORIDE_API_ENDPOINT_UNLOCK = "/tracker/:trackerId/unlock"
|
GEORIDE_API_ENDPOINT_TRACKER_BEACON = "/tracker/{trackerId}/beacon"
|
||||||
GEORIDE_API_ENDPOINT_TOGGLE_LOCK = "/tracker/:trackerId/toggleLock"
|
GEORIDE_API_ENDPOINT_UNLOCK = "/tracker/{trackerId}/unlock"
|
||||||
GEORIDE_API_ENDPOINT_POSITIONS = "/tracker/:trackerId/trips/positions"
|
GEORIDE_API_ENDPOINT_TOGGLE_LOCK = "/tracker/{trackerId}/toggleLock"
|
||||||
GEORIDE_API_ENDPOINT_TRIP_SHARE = "/tracker/:trackerId/share/trip"
|
GEORIDE_API_ENDPOINT_POSITIONS = "/tracker/{trackerId}/trips/positions"
|
||||||
|
GEORIDE_API_ENDPOINT_TRIP_SHARE = "/tracker/{trackerId}/share/trip"
|
||||||
|
GEORIDE_API_ENDPOINT_SHUTDOWN_TRACKER = "/tracker/{trackerId}/shutdown"
|
||||||
|
GEORIDE_API_ENDPOINT_TRACKER_ALARM_OFF = "/tracker/{trackerId}/sonor-alarm/off"
|
||||||
|
GEORIDE_API_ENDPOINT_TRACKER_ALARM_ON = "/tracker/{trackerId}/sonor-alarm/on"
|
||||||
|
GEORIDE_API_ENDPOINT_TRACKER_ECO_MODE_OFF = "/tracker/{trackerId}/eco-mode/off"
|
||||||
|
GEORIDE_API_ENDPOINT_TRACKER_ECO_MODE_ON = "/tracker/{trackerId}/eco-mode/on"
|
||||||
|
|
||||||
|
_SESSION = requests.Session()
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
def get_authorisation_token(email, password):
|
def get_authorisation_token(email, password):
|
||||||
""" return an authorization token """
|
""" return an authorization token or no"""
|
||||||
http = urllib3.PoolManager()
|
|
||||||
data = {"email": email, "password": password}
|
data = {"email": email, "password": password}
|
||||||
encoded_data = json.dumps(data).encode('utf-8')
|
encoded_data = json.dumps(data).encode('utf-8')
|
||||||
response = http.request(
|
|
||||||
'POST',
|
response = _SESSION.post(
|
||||||
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_LOGIN,
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_LOGIN,
|
||||||
body=encoded_data,
|
data=encoded_data,
|
||||||
headers={'Content-Type': 'application/json'})
|
headers={'Content-Type': 'application/json'})
|
||||||
response_data = json.loads(response.data.decode('utf-8'))
|
|
||||||
account = GeorideAccount.from_json(response_data)
|
if response.status_code == 200:
|
||||||
|
_LOGGER.debug("Login success")
|
||||||
|
response_data = response.json()
|
||||||
|
account = GeoRideAccount.from_json(response_data)
|
||||||
|
elif response.status_code == 403:
|
||||||
|
_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(get_authorisation_token,
|
||||||
|
"Georide login, http error code: {}".format(response.status_code))
|
||||||
return account
|
return account
|
||||||
|
|
||||||
|
|
||||||
def renew_token(token):
|
def renew_token(token):
|
||||||
""" renew the authorization token """
|
""" renew the authorization token """
|
||||||
http = urllib3.PoolManager()
|
|
||||||
headers = {"Authorization": "Bearer " + token}
|
headers = {"Authorization": "Bearer " + token}
|
||||||
response = http.request(
|
response = _SESSION.get(
|
||||||
'GET',
|
|
||||||
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_NEW_TOKEN,
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_NEW_TOKEN,
|
||||||
headers=headers)
|
headers=headers)
|
||||||
response_data = json.loads(response.data.decode('utf-8'))
|
if response.status_code == 200:
|
||||||
new_token = response_data['authToken']
|
_LOGGER.debug("Token updated")
|
||||||
|
response_data = response.json()
|
||||||
|
new_token = response_data['authToken']
|
||||||
|
elif response.status_code == 401:
|
||||||
|
_LOGGER.warnning("Renew token refused")
|
||||||
|
raise UnauthorizedException(renew_token, "Renew token refused")
|
||||||
|
else:
|
||||||
|
_LOGGER.error("Georide login, http error code: %s", response.status_code)
|
||||||
|
raise SeverException(renew_token,
|
||||||
|
"Georide login, http error code: {}".format(response.status_code))
|
||||||
return new_token
|
return new_token
|
||||||
|
|
||||||
|
|
||||||
def revoke_token(token):
|
def revoke_token(token):
|
||||||
""" invalidate the authorization token """
|
""" invalidate the authorization token """
|
||||||
http = urllib3.PoolManager()
|
|
||||||
headers = {"Authorization": "Bearer " + token}
|
headers = {"Authorization": "Bearer " + token}
|
||||||
response = http.request(
|
response = _SESSION.post(
|
||||||
'POST',
|
|
||||||
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_LOGOUT,
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_LOGOUT,
|
||||||
headers=headers)
|
headers=headers)
|
||||||
if response.status != 204:
|
if response.status_code == 401:
|
||||||
|
_LOGGER.warnning("Token allready revoked")
|
||||||
|
raise UnauthorizedException(revoke_token, "Token allready revoked")
|
||||||
|
if response.status_code == 403:
|
||||||
|
_LOGGER.warnning("Token allready revoked")
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def get_user(token):
|
def get_user(token):
|
||||||
""" get the georide user info """
|
""" get the georide user info """
|
||||||
http = urllib3.PoolManager()
|
|
||||||
headers = {"Authorization": "Bearer " + token}
|
headers = {"Authorization": "Bearer " + token}
|
||||||
response = http.request(
|
response = _SESSION.get(
|
||||||
'GET',
|
|
||||||
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_USER,
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_USER,
|
||||||
headers=headers)
|
headers=headers)
|
||||||
response_data = json.loads(response.data.decode('utf-8'))
|
response_data = response.json()
|
||||||
account = GeorideUser.from_json(response_data)
|
_LOGGER.debug(response_data)
|
||||||
|
account = GeoRideUser.from_json(response_data)
|
||||||
return account
|
return account
|
||||||
|
|
||||||
def get_trackers(token):
|
def get_trackers(token):
|
||||||
""" get user trackers """
|
""" get user trackers """
|
||||||
http = urllib3.PoolManager()
|
|
||||||
headers = {"Authorization": "Bearer " + token}
|
headers = {"Authorization": "Bearer " + token}
|
||||||
response = http.request(
|
response = _SESSION.get(
|
||||||
'GET',
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRACKERS,
|
||||||
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRAKERS,
|
|
||||||
headers=headers)
|
headers=headers)
|
||||||
|
|
||||||
response_data = json.loads(response.data.decode('utf-8'))
|
response_data = response.json()
|
||||||
trackers = []
|
trackers = []
|
||||||
for json_tracker in response_data:
|
for json_tracker in response_data:
|
||||||
trackers.append(GeorideTracker.from_json(json_tracker))
|
_LOGGER.debug(json_tracker)
|
||||||
|
trackers.append(GeoRideTracker.from_json(json_tracker))
|
||||||
return trackers
|
return trackers
|
||||||
|
|
||||||
|
def get_tracker_beacons(token, tracker_id):
|
||||||
|
""" get user trackers """
|
||||||
|
|
||||||
|
headers = {"Authorization": "Bearer " + token}
|
||||||
|
response = _SESSION.get(
|
||||||
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRACKER_BEACON.format(trackerId=str(tracker_id)),
|
||||||
|
headers=headers)
|
||||||
|
|
||||||
|
response_data = response.json()
|
||||||
|
trackers_beacons = []
|
||||||
|
if response.status_code == 200:
|
||||||
|
for json_tracker_beacon in response_data:
|
||||||
|
_LOGGER.debug(json_tracker_beacon)
|
||||||
|
json_tracker_beacon['linked_tracker_id'] = tracker_id
|
||||||
|
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 """
|
||||||
http = urllib3.PoolManager()
|
|
||||||
headers = {"Authorization": "Bearer " + token}
|
headers = {"Authorization": "Bearer " + token}
|
||||||
response = http.request(
|
response = _SESSION.get(
|
||||||
'GET',
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRIPS.format(trackerId=str(tracker_id)),
|
||||||
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRIPS.replace(':trackerId', str(tracker_id)),
|
params={'from': from_date, 'to': to_date},
|
||||||
fields={'from': from_date, 'to': to_date},
|
|
||||||
headers=headers)
|
headers=headers)
|
||||||
|
|
||||||
response_data = json.loads(response.data.decode('utf-8'))
|
response_data = response.json()
|
||||||
trips = []
|
trips = []
|
||||||
for json_trip in response_data:
|
if response.status_code == 200:
|
||||||
trips.append(GeorideTrackerTrip.from_json(json_trip))
|
for json_trip in response_data:
|
||||||
|
trips.append(GeoRideTrackerTrip.from_json(json_trip))
|
||||||
return trips
|
return trips
|
||||||
|
|
||||||
def get_positions(token, tracker_id, from_date, to_date):
|
def get_positions(token, tracker_id, from_date, to_date):
|
||||||
""" return all trips between two dates """
|
""" return all trips between two dates """
|
||||||
http = urllib3.PoolManager()
|
|
||||||
headers = {"Authorization": "Bearer " + token}
|
headers = {"Authorization": "Bearer " + token}
|
||||||
response = http.request(
|
response = _SESSION.get(
|
||||||
'GET',
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_POSITIONS.format(trackerId=str(tracker_id)),
|
||||||
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_POSITIONS.replace(':trackerId', str(tracker_id)),
|
params={'from': from_date, 'to': to_date},
|
||||||
fields={'from': from_date, 'to': to_date},
|
|
||||||
headers=headers)
|
headers=headers)
|
||||||
|
|
||||||
response_data = json.loads(response.data.decode('utf-8'))
|
response_data = response.json()
|
||||||
positions = []
|
positions = []
|
||||||
for json_position in response_data:
|
if response.status_code == 200:
|
||||||
positions.append(GeorideTrackerPosition.from_json(json_position))
|
for json_position in response_data:
|
||||||
|
positions.append(GeoRideTrackerPosition.from_json(json_position))
|
||||||
return positions
|
return positions
|
||||||
|
|
||||||
def share_a_trip_by_trip_id(token, tracker_id, trip_id):
|
def share_a_trip_by_trip_id(token, tracker_id, trip_id):
|
||||||
@@ -154,57 +199,92 @@ def _share_a_trip(token, tracker_id, trip_id=None, from_date=None, # pylint: dis
|
|||||||
data = {"tripMergedId": trip_merged_id}
|
data = {"tripMergedId": trip_merged_id}
|
||||||
|
|
||||||
encoded_data = json.dumps(data).encode('utf-8')
|
encoded_data = json.dumps(data).encode('utf-8')
|
||||||
print("Trip data: ", encoded_data)
|
|
||||||
|
|
||||||
http = urllib3.PoolManager()
|
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": "Bearer " + token,
|
"Authorization": "Bearer " + token,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
response = http.request(
|
response = _SESSION.post(
|
||||||
'POST',
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRIP_SHARE.format(trackerId=str(tracker_id)),
|
||||||
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRIP_SHARE.replace(':trackerId', str(tracker_id)),
|
data=encoded_data,
|
||||||
body=encoded_data,
|
|
||||||
headers=headers)
|
headers=headers)
|
||||||
|
|
||||||
response_data = json.loads(response.data.decode('utf-8'))
|
response_data = response.json()
|
||||||
print("Trip data: ", response_data)
|
if response.status_code == 200:
|
||||||
return GeorideSharedTrip.from_json(response_data)
|
return GeoRideSharedTrip.from_json(response_data)
|
||||||
|
return None
|
||||||
|
|
||||||
def lock_tracker(token, tracker_id):
|
def lock_tracker(token, tracker_id):
|
||||||
""" used to lock a tracker """
|
""" used to lock a tracker """
|
||||||
http = urllib3.PoolManager()
|
|
||||||
headers = {"Authorization": "Bearer " + token}
|
headers = {"Authorization": "Bearer " + token}
|
||||||
response = http.request(
|
response = _SESSION.post(
|
||||||
'POST',
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_LOCK.format(trackerId=str(tracker_id)),
|
||||||
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_LOCK.replace(':trackerId', str(tracker_id)),
|
|
||||||
headers=headers)
|
headers=headers)
|
||||||
if response.status != 204:
|
if response.status_code != 204:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def unlock_tracker(token, tracker_id):
|
def unlock_tracker(token, tracker_id):
|
||||||
""" used to unlock a tracker """
|
""" used to unlock a tracker """
|
||||||
http = urllib3.PoolManager()
|
|
||||||
headers = {"Authorization": "Bearer " + token}
|
headers = {"Authorization": "Bearer " + token}
|
||||||
response = http.request(
|
response = _SESSION.post(
|
||||||
'POST',
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_UNLOCK.format(trackerId=str(tracker_id)),
|
||||||
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_UNLOCK.replace(':trackerId', str(tracker_id)),
|
|
||||||
headers=headers)
|
headers=headers)
|
||||||
if response.status != 204:
|
if response.status_code != 204:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def toogle_lock_tracker(token, tracker_id):
|
def toogle_lock_tracker(token, tracker_id):
|
||||||
""" used to toggle lock a tracker """
|
""" used to toggle lock a tracker """
|
||||||
http = urllib3.PoolManager()
|
|
||||||
headers = {"Authorization": "Bearer " + token}
|
headers = {"Authorization": "Bearer " + token}
|
||||||
response = http.request(
|
response = _SESSION.post(
|
||||||
'POST',
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TOGGLE_LOCK.format(trackerId=str(tracker_id)),
|
||||||
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TOGGLE_LOCK.replace(':trackerId', str(tracker_id)),
|
|
||||||
headers=headers)
|
headers=headers)
|
||||||
response_data = json.loads(response.data.decode('utf-8'))
|
response_data = response.json()
|
||||||
return response_data['locked']
|
return response_data['locked']
|
||||||
|
|
||||||
|
def change_tracker_siren_state(token, tracker_id, state: bool):
|
||||||
|
""" used to toggle lock a tracker """
|
||||||
|
headers = {"Authorization": "Bearer " + token}
|
||||||
|
response = None
|
||||||
|
if state == True:
|
||||||
|
response = _SESSION.post(
|
||||||
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRACKER_ALARM_ON.format(trackerId=str(tracker_id)),
|
||||||
|
headers=headers)
|
||||||
|
else:
|
||||||
|
response = _SESSION.post(
|
||||||
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRACKER_ALARM_OFF.format(trackerId=str(tracker_id)),
|
||||||
|
headers=headers)
|
||||||
|
if response.status_code != 204:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def change_tracker_eco_mode_state(token, tracker_id, state: bool):
|
||||||
|
""" used to toggle lock a tracker """
|
||||||
|
headers = {"Authorization": "Bearer " + token}
|
||||||
|
response = None
|
||||||
|
if state == True:
|
||||||
|
response = _SESSION.post(
|
||||||
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRACKER_ECO_MODE_ON.format(trackerId=str(tracker_id)),
|
||||||
|
headers=headers)
|
||||||
|
else:
|
||||||
|
response = _SESSION.post(
|
||||||
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRACKER_ECO_MODE_OFF.format(trackerId=str(tracker_id)),
|
||||||
|
headers=headers)
|
||||||
|
if response.status_code != 204:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def shutdown_tracker(token, tracker_id):
|
||||||
|
""" used to toggle lock a tracker """
|
||||||
|
headers = {"Authorization": "Bearer " + token}
|
||||||
|
response = _SESSION.post(
|
||||||
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_SHUTDOWN_TRACKER.format(trackerId=str(tracker_id)),
|
||||||
|
headers=headers)
|
||||||
|
response_data = response.json()
|
||||||
|
if response.status_code == 200:
|
||||||
|
return response_data['locked']
|
||||||
|
return None
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print("Not a main module")
|
print("Not a main module")
|
||||||
|
|||||||
23
georideapilib/exception.py
Normal file
23
georideapilib/exception.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
""" all GeoRide exception """
|
||||||
|
|
||||||
|
class Error(Exception):
|
||||||
|
"""Base class for exceptions in this module."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
class LoginException(Error):
|
||||||
|
"""loggin exception"""
|
||||||
|
def __init__(self, expression, message):
|
||||||
|
self.expression = expression
|
||||||
|
self.message = message
|
||||||
|
|
||||||
|
class UnauthorizedException(Error):
|
||||||
|
"""loggin exception"""
|
||||||
|
def __init__(self, expression, message):
|
||||||
|
self.expression = expression
|
||||||
|
self.message = message
|
||||||
|
|
||||||
|
class SeverException(Error):
|
||||||
|
"""loggin exception"""
|
||||||
|
def __init__(self, expression, message):
|
||||||
|
self.expression = expression
|
||||||
|
self.message = message
|
||||||
@@ -1,598 +0,0 @@
|
|||||||
"""
|
|
||||||
Georide objects implementation
|
|
||||||
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
|
||||||
"""
|
|
||||||
|
|
||||||
class GeorideSharedTrip:
|
|
||||||
""" Shared trip object representation """
|
|
||||||
def __init__(self, url, shareId):
|
|
||||||
self._url = url
|
|
||||||
self._share_id = shareId
|
|
||||||
|
|
||||||
@property
|
|
||||||
def url(self):
|
|
||||||
""" shared trip url """
|
|
||||||
return self._url
|
|
||||||
|
|
||||||
@property
|
|
||||||
def share_id(self):
|
|
||||||
""" shared trip id """
|
|
||||||
return self._share_id
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def from_json(json):
|
|
||||||
"""return new object fromjson"""
|
|
||||||
return GeorideSharedTrip(
|
|
||||||
json['url'],
|
|
||||||
json['shareId']
|
|
||||||
)
|
|
||||||
|
|
||||||
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,
|
|
||||||
nice_end_address, end_lat, end_lon, start_time, end_time):
|
|
||||||
self._trip_id = trip_id
|
|
||||||
self._tracker_id = tracker_id
|
|
||||||
self._average_speed = average_speed
|
|
||||||
self._max_speed = max_speed
|
|
||||||
self._distance = distance
|
|
||||||
self._duration = duration
|
|
||||||
self._start_address = start_address
|
|
||||||
self._nice_start_address = nice_start_address
|
|
||||||
self._start_lat = start_lat
|
|
||||||
self._start_lon = start_lon
|
|
||||||
self._end_address = end_address
|
|
||||||
self._nice_end_address = nice_end_address
|
|
||||||
self._end_lat = end_lat
|
|
||||||
self._end_lon = end_lon
|
|
||||||
self._start_time = start_time
|
|
||||||
self._end_time = end_time
|
|
||||||
|
|
||||||
|
|
||||||
@property
|
|
||||||
def trip_id(self):
|
|
||||||
"""trip_id """
|
|
||||||
return self._trip_id
|
|
||||||
|
|
||||||
@property
|
|
||||||
def tracker_id(self):
|
|
||||||
""" tracker_id """
|
|
||||||
return self._tracker_id
|
|
||||||
|
|
||||||
@property
|
|
||||||
def average_speed(self):
|
|
||||||
""" average_speed """
|
|
||||||
return self._average_speed
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_speed(self):
|
|
||||||
""" max_speed """
|
|
||||||
return self._max_speed
|
|
||||||
|
|
||||||
@property
|
|
||||||
def distance(self):
|
|
||||||
""" distance """
|
|
||||||
return self._distance
|
|
||||||
|
|
||||||
@property
|
|
||||||
def duration(self):
|
|
||||||
""" duration """
|
|
||||||
return self._duration
|
|
||||||
|
|
||||||
@property
|
|
||||||
def start_address(self):
|
|
||||||
""" start_address """
|
|
||||||
return self._start_address
|
|
||||||
|
|
||||||
@property
|
|
||||||
def nice_start_address(self):
|
|
||||||
""" nice_start_address """
|
|
||||||
return self._nice_start_address
|
|
||||||
|
|
||||||
@property
|
|
||||||
def start_lat(self):
|
|
||||||
""" start_lat """
|
|
||||||
return self._start_lat
|
|
||||||
|
|
||||||
@property
|
|
||||||
def start_lon(self):
|
|
||||||
""" start_lon """
|
|
||||||
return self._start_lon
|
|
||||||
|
|
||||||
@property
|
|
||||||
def end_address(self):
|
|
||||||
""" end_address """
|
|
||||||
return self._end_address
|
|
||||||
|
|
||||||
@property
|
|
||||||
def nice_end_address(self):
|
|
||||||
""" nice_end_address """
|
|
||||||
return self._nice_end_address
|
|
||||||
|
|
||||||
@property
|
|
||||||
def end_lat(self):
|
|
||||||
"""end_lat """
|
|
||||||
return self._end_lat
|
|
||||||
|
|
||||||
@property
|
|
||||||
def end_lon(self):
|
|
||||||
"""end_lon """
|
|
||||||
return self._end_lon
|
|
||||||
|
|
||||||
@property
|
|
||||||
def start_time(self):
|
|
||||||
""" start_time """
|
|
||||||
return self._start_time
|
|
||||||
|
|
||||||
@property
|
|
||||||
def end_time(self):
|
|
||||||
""" end_time """
|
|
||||||
return self._end_time
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def from_json(json):
|
|
||||||
"""return new object from json"""
|
|
||||||
return GeorideTrackerTrip(
|
|
||||||
json['id'],
|
|
||||||
json['trackerId'],
|
|
||||||
json['averageSpeed'],
|
|
||||||
json['maxSpeed'],
|
|
||||||
json['distance'],
|
|
||||||
json['duration'],
|
|
||||||
json['startAddress'],
|
|
||||||
json['niceStartAddress'],
|
|
||||||
json['startLat'],
|
|
||||||
json['startLon'],
|
|
||||||
json['endAddress'],
|
|
||||||
json['niceEndAddress'],
|
|
||||||
json['endLat'],
|
|
||||||
json['endLon'],
|
|
||||||
json['startTime'],
|
|
||||||
json['endTime']
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class GeorideTrackerPosition:
|
|
||||||
""" Tracker position object representation """
|
|
||||||
def __init__(self, fixtime, latitude, longitude, altitude, speed, address): # pylint: disable= R0913
|
|
||||||
self._fixtime = fixtime
|
|
||||||
self._latitude = latitude
|
|
||||||
self._longitude = longitude
|
|
||||||
self._altitude = altitude
|
|
||||||
self._speed = speed
|
|
||||||
self._address = address
|
|
||||||
|
|
||||||
@property
|
|
||||||
def fixtime(self):
|
|
||||||
""" fixtime """
|
|
||||||
return self._fixtime
|
|
||||||
|
|
||||||
@property
|
|
||||||
def latitude(self):
|
|
||||||
""" latitude """
|
|
||||||
return self._latitude
|
|
||||||
|
|
||||||
@property
|
|
||||||
def longitude(self):
|
|
||||||
""" longitude """
|
|
||||||
return self._longitude
|
|
||||||
|
|
||||||
@property
|
|
||||||
def altitude(self):
|
|
||||||
""" altitude """
|
|
||||||
return self._altitude
|
|
||||||
|
|
||||||
@property
|
|
||||||
def speed(self):
|
|
||||||
""" speed (m/s) """
|
|
||||||
return self._speed
|
|
||||||
|
|
||||||
@property
|
|
||||||
def address(self):
|
|
||||||
""" address """
|
|
||||||
return self._address
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def from_json(json):
|
|
||||||
"""return new object fromjson"""
|
|
||||||
return GeorideTrackerPosition(
|
|
||||||
json['fixtime'],
|
|
||||||
json['latitude'],
|
|
||||||
json['longitude'],
|
|
||||||
json['altitude'],
|
|
||||||
json['speed'],
|
|
||||||
json['address']
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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,
|
|
||||||
last_payment_date, gift_card_id, expires, activation_date, odometer, is_stolen,
|
|
||||||
is_crashed, crash_detection_disabled, speed, moving, position_id, latitude,
|
|
||||||
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):
|
|
||||||
self._tracker_id = tracker_id
|
|
||||||
self._tracker_name = tracker_name
|
|
||||||
self._device_button_action = device_button_action
|
|
||||||
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._fixtime = fixtime
|
|
||||||
self._role = role
|
|
||||||
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_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
|
|
||||||
self._can_share = can_share
|
|
||||||
self._can_unshare = can_unshare
|
|
||||||
self._can_check_speed = can_check_speed
|
|
||||||
self._can_see_statistics = can_see_statistics
|
|
||||||
self._can_send_broken_down_signal = can_send_broken_down_signal
|
|
||||||
self._can_send_stolen_signal = can_send_stolen_signal
|
|
||||||
self._status = status
|
|
||||||
|
|
||||||
@property
|
|
||||||
def tracker_id(self):
|
|
||||||
""" tracker_id """
|
|
||||||
return self._tracker_id
|
|
||||||
|
|
||||||
@property
|
|
||||||
def tracker_name(self):
|
|
||||||
""" tracker_name """
|
|
||||||
return self._tracker_name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def device_button_action(self):
|
|
||||||
""" device_button_action """
|
|
||||||
return self._device_button_action
|
|
||||||
|
|
||||||
@property
|
|
||||||
def device_button_delay(self):
|
|
||||||
""" device_button_delay """
|
|
||||||
return self._device_button_delay
|
|
||||||
|
|
||||||
@property
|
|
||||||
def vibration_level(self):
|
|
||||||
""" vibration_level """
|
|
||||||
return self._vibration_level
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_old_tracker(self):
|
|
||||||
""" is_old_tracker """
|
|
||||||
return self._is_old_tracker
|
|
||||||
|
|
||||||
@property
|
|
||||||
def auto_lock_freezed_to(self):
|
|
||||||
""" auto_lock_freezed_to """
|
|
||||||
return self._auto_lock_freezed_to
|
|
||||||
|
|
||||||
@property
|
|
||||||
def fixtime(self):
|
|
||||||
""" fixtime """
|
|
||||||
return self._fixtime
|
|
||||||
|
|
||||||
@property
|
|
||||||
def role(self):
|
|
||||||
""" role """
|
|
||||||
return self._role
|
|
||||||
|
|
||||||
@property
|
|
||||||
def last_payment_date(self):
|
|
||||||
""" last_payment_date """
|
|
||||||
return self._last_payment_date
|
|
||||||
|
|
||||||
@property
|
|
||||||
def gift_card_id(self):
|
|
||||||
""" gift_card_id """
|
|
||||||
return self._gift_card_id
|
|
||||||
|
|
||||||
@property
|
|
||||||
def expires(self):
|
|
||||||
""" expires """
|
|
||||||
return self._expires
|
|
||||||
|
|
||||||
@property
|
|
||||||
def activation_date(self):
|
|
||||||
""" activation_date """
|
|
||||||
return self._activation_date
|
|
||||||
|
|
||||||
@property
|
|
||||||
def odometer(self):
|
|
||||||
""" odometer """
|
|
||||||
return self._odometer
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_stolen(self):
|
|
||||||
""" is_stolen """
|
|
||||||
return self._is_stolen
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_crashed(self):
|
|
||||||
""" is_crashed """
|
|
||||||
return self._is_crashed
|
|
||||||
|
|
||||||
@property
|
|
||||||
def crash_detection_disabled(self):
|
|
||||||
""" crash_detection_disabled """
|
|
||||||
return self._crash_detection_disabled
|
|
||||||
|
|
||||||
@property
|
|
||||||
def speed(self):
|
|
||||||
""" speed """
|
|
||||||
return self._speed
|
|
||||||
|
|
||||||
@property
|
|
||||||
def moving(self):
|
|
||||||
""" moving """
|
|
||||||
return self._moving
|
|
||||||
|
|
||||||
@property
|
|
||||||
def position_id(self):
|
|
||||||
""" position_id """
|
|
||||||
return self._position_id
|
|
||||||
|
|
||||||
@property
|
|
||||||
def latitude(self):
|
|
||||||
""" latitude """
|
|
||||||
return self._latitude
|
|
||||||
|
|
||||||
@property
|
|
||||||
def longitude(self):
|
|
||||||
""" longitude """
|
|
||||||
return self._longitude
|
|
||||||
|
|
||||||
@property
|
|
||||||
def altitude(self):
|
|
||||||
""" altitude """
|
|
||||||
return self._altitude
|
|
||||||
|
|
||||||
@property
|
|
||||||
def locked_position_id(self):
|
|
||||||
""" locked_position_id """
|
|
||||||
return self._locked_position_id
|
|
||||||
|
|
||||||
@property
|
|
||||||
def locked_latitude(self):
|
|
||||||
""" locked_latitude """
|
|
||||||
return self._locked_latitude
|
|
||||||
|
|
||||||
@property
|
|
||||||
def locked_longitude(self):
|
|
||||||
""" locked_longitude """
|
|
||||||
return self._locked_longitude
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_locked(self):
|
|
||||||
""" is_locked """
|
|
||||||
return self._is_locked
|
|
||||||
|
|
||||||
@property
|
|
||||||
def can_see_position(self):
|
|
||||||
""" can_see_position """
|
|
||||||
return self._can_see_position
|
|
||||||
|
|
||||||
@property
|
|
||||||
def can_lock(self):
|
|
||||||
""" can_lock """
|
|
||||||
return self._can_lock
|
|
||||||
|
|
||||||
@property
|
|
||||||
def can_unlock(self):
|
|
||||||
""" can_unlock """
|
|
||||||
return self._can_unlock
|
|
||||||
|
|
||||||
@property
|
|
||||||
def can_share(self):
|
|
||||||
""" can_share """
|
|
||||||
return self._can_share
|
|
||||||
|
|
||||||
@property
|
|
||||||
def can_unshare(self):
|
|
||||||
""" can_unshare """
|
|
||||||
return self._can_unshare
|
|
||||||
|
|
||||||
@property
|
|
||||||
def can_check_speed(self):
|
|
||||||
""" can_check_speed """
|
|
||||||
return self._can_check_speed
|
|
||||||
|
|
||||||
@property
|
|
||||||
def can_see_statistics(self):
|
|
||||||
""" can_see_statistics """
|
|
||||||
return self._can_see_statistics
|
|
||||||
|
|
||||||
@property
|
|
||||||
def can_send_broken_down_signal(self):
|
|
||||||
""" can_send_broken_down_signal """
|
|
||||||
return self._can_send_broken_down_signal
|
|
||||||
|
|
||||||
@property
|
|
||||||
def can_send_stolen_signal(self):
|
|
||||||
""" can_send_stolen_signal """
|
|
||||||
return self._can_send_stolen_signal
|
|
||||||
|
|
||||||
@property
|
|
||||||
def status(self):
|
|
||||||
""" status """
|
|
||||||
return self._status
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def from_json(json):
|
|
||||||
"""return new object fromjson"""
|
|
||||||
return GeorideTracker(
|
|
||||||
json['trackerId'],
|
|
||||||
json['trackerName'],
|
|
||||||
json['deviceButtonAction'],
|
|
||||||
json['deviceButtonDelay'],
|
|
||||||
json['vibrationLevel'],
|
|
||||||
json['isOldTracker'],
|
|
||||||
json['autoLockFreezedTo'],
|
|
||||||
json['fixtime'],
|
|
||||||
json['role'],
|
|
||||||
json['lastPaymentDate'],
|
|
||||||
json['giftCardId'],
|
|
||||||
json['expires'],
|
|
||||||
json['activationDate'],
|
|
||||||
json['odometer'],
|
|
||||||
json['isStolen'],
|
|
||||||
json['isCrashed'],
|
|
||||||
json['crashDetectionDisabled'],
|
|
||||||
json['speed'],
|
|
||||||
json['moving'],
|
|
||||||
json['positionId'],
|
|
||||||
json['latitude'],
|
|
||||||
json['longitude'],
|
|
||||||
json['altitude'],
|
|
||||||
json['lockedPositionId'],
|
|
||||||
json['lockedLatitude'],
|
|
||||||
json['lockedLongitude'],
|
|
||||||
json['isLocked'],
|
|
||||||
json['canSeePosition'],
|
|
||||||
json['canLock'],
|
|
||||||
json['canUnlock'],
|
|
||||||
json['canShare'],
|
|
||||||
json['canUnshare'],
|
|
||||||
json['canCheckSpeed'],
|
|
||||||
json['canSeeStatistics'],
|
|
||||||
json['canSendBrokenDownSignal'],
|
|
||||||
json['canSendStolenSignal'],
|
|
||||||
json['status']
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class GeorideAccount:
|
|
||||||
""" Account object representation """
|
|
||||||
def __init__(self, account_id, email, is_admin, auth_token):
|
|
||||||
self._account_id = account_id
|
|
||||||
self._email = email
|
|
||||||
self._is_admin = is_admin
|
|
||||||
self._auth_token = auth_token
|
|
||||||
|
|
||||||
@property
|
|
||||||
def account_id(self):
|
|
||||||
""" account_id """
|
|
||||||
return self._account_id
|
|
||||||
|
|
||||||
@property
|
|
||||||
def email(self):
|
|
||||||
""" email """
|
|
||||||
return self._email
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_admin(self):
|
|
||||||
""" is_admin """
|
|
||||||
return self._is_admin
|
|
||||||
|
|
||||||
@property
|
|
||||||
def auth_token(self):
|
|
||||||
""" auth_token """
|
|
||||||
return self._auth_token
|
|
||||||
|
|
||||||
@auth_token.setter
|
|
||||||
def auth_token(self, new_token):
|
|
||||||
""" change auth_token """
|
|
||||||
self._auth_token = new_token
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def from_json(json):
|
|
||||||
"""return new object from_json"""
|
|
||||||
return GeorideAccount(
|
|
||||||
json['id'],
|
|
||||||
json['email'],
|
|
||||||
json['isAdmin'],
|
|
||||||
json['authToken']
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
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):
|
|
||||||
self._user_id = user_id
|
|
||||||
self._email = email
|
|
||||||
self._first_name = first_name
|
|
||||||
self._created_at = created_at
|
|
||||||
self._phone_number = phone_number
|
|
||||||
self._push_user_token = push_user_token
|
|
||||||
self._legal = legal
|
|
||||||
self._date_of_birth = date_of_birth
|
|
||||||
|
|
||||||
@property
|
|
||||||
def user_id(self):
|
|
||||||
""" user_id """
|
|
||||||
return self._user_id
|
|
||||||
|
|
||||||
@property
|
|
||||||
def email(self):
|
|
||||||
""" email """
|
|
||||||
return self._email
|
|
||||||
|
|
||||||
@property
|
|
||||||
def first_name(self):
|
|
||||||
""" first_name """
|
|
||||||
return self._first_name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def created_at(self):
|
|
||||||
""" created_at """
|
|
||||||
return self._created_at
|
|
||||||
|
|
||||||
@property
|
|
||||||
def phone_number(self):
|
|
||||||
""" phone_number """
|
|
||||||
return self._phone_number
|
|
||||||
|
|
||||||
@property
|
|
||||||
def push_user_token(self):
|
|
||||||
""" push_user_token """
|
|
||||||
return self._push_user_token
|
|
||||||
|
|
||||||
@property
|
|
||||||
def legal(self):
|
|
||||||
""" legal """
|
|
||||||
return self._legal
|
|
||||||
|
|
||||||
@property
|
|
||||||
def date_of_birth(self):
|
|
||||||
""" date_ofo_birth """
|
|
||||||
return self._date_of_birth
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def from_json(json):
|
|
||||||
"""return new object fromjson"""
|
|
||||||
return GeorideUser(
|
|
||||||
json['id'],
|
|
||||||
json['email'],
|
|
||||||
json['firstName'],
|
|
||||||
json['createdAt'],
|
|
||||||
json['phoneNumber'],
|
|
||||||
json['pushUserToken'],
|
|
||||||
json['legal'],
|
|
||||||
json['dateOfBirth']
|
|
||||||
)
|
|
||||||
51
georideapilib/objects/GeoRideAccount.py
Normal file
51
georideapilib/objects/GeoRideAccount.py
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
"""
|
||||||
|
Georide objects implementation
|
||||||
|
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
||||||
|
"""
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class GeoRideAccount:
|
||||||
|
""" Account object representation """
|
||||||
|
def __init__(self, account_id, email, is_admin, auth_token):
|
||||||
|
self._account_id = account_id
|
||||||
|
self._email = emailgit
|
||||||
|
self._is_admin = is_admin
|
||||||
|
self._auth_token = auth_token
|
||||||
|
|
||||||
|
@property
|
||||||
|
def account_id(self):
|
||||||
|
""" account_id """
|
||||||
|
return self._account_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def email(self):
|
||||||
|
""" email """
|
||||||
|
return self._email
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_admin(self):
|
||||||
|
""" is_admin """
|
||||||
|
return self._is_admin
|
||||||
|
|
||||||
|
@property
|
||||||
|
def auth_token(self):
|
||||||
|
""" auth_token """
|
||||||
|
return self._auth_token
|
||||||
|
|
||||||
|
@auth_token.setter
|
||||||
|
def auth_token(self, new_token):
|
||||||
|
""" change auth_token """
|
||||||
|
self._auth_token = new_token
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_json(json):
|
||||||
|
"""return new object from_json"""
|
||||||
|
return GeoRideAccount(
|
||||||
|
json['id'],
|
||||||
|
json['email'],
|
||||||
|
json['isAdmin'],
|
||||||
|
json['authToken']
|
||||||
|
)
|
||||||
33
georideapilib/objects/GeoRideSharedTrip.py
Normal file
33
georideapilib/objects/GeoRideSharedTrip.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
"""
|
||||||
|
Georide objects implementation
|
||||||
|
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
||||||
|
"""
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class GeoRideSharedTrip:
|
||||||
|
""" Shared trip object representation """
|
||||||
|
def __init__(self, url, shareId):
|
||||||
|
self._url = url
|
||||||
|
self._share_id = shareId
|
||||||
|
|
||||||
|
@property
|
||||||
|
def url(self):
|
||||||
|
""" shared trip url """
|
||||||
|
return self._url
|
||||||
|
|
||||||
|
@property
|
||||||
|
def share_id(self):
|
||||||
|
""" shared trip id """
|
||||||
|
return self._share_id
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_json(json):
|
||||||
|
"""return new object fromjson"""
|
||||||
|
return GeoRideSharedTrip(
|
||||||
|
json['url'],
|
||||||
|
json['shareId']
|
||||||
|
)
|
||||||
98
georideapilib/objects/GeoRideSubscription.py
Normal file
98
georideapilib/objects/GeoRideSubscription.py
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
"""
|
||||||
|
Georide objects implementation
|
||||||
|
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
||||||
|
"""
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
from . import JsonMgtMetaClass, GeoRideSubscription_CardInfo
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class GeoRideSubscription(metaclass=JsonMgtMetaClass):
|
||||||
|
""" Account object representation """
|
||||||
|
def __init__(self, subscription_id, subscription_type, initial_date, next_payment_date,
|
||||||
|
status, paused_since, cancel_requested, price, first_name, last_name, card_information):
|
||||||
|
self._subscription_id = subscription_id
|
||||||
|
self._subscription_type = subscription_type
|
||||||
|
self._initial_date = initial_date
|
||||||
|
self._next_payment_date = next_payment_date
|
||||||
|
self._status = status
|
||||||
|
self._paused_since = paused_since
|
||||||
|
self._cancel_requested = cancel_requested
|
||||||
|
self._price = price
|
||||||
|
self._first_name = first_name
|
||||||
|
self._last_name = last_name
|
||||||
|
self._card_information = card_information
|
||||||
|
|
||||||
|
@property
|
||||||
|
def subscription_id(self):
|
||||||
|
"""subscription_id property"""
|
||||||
|
return self._subscription_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def subscription_type(self):
|
||||||
|
"""subscription_type property"""
|
||||||
|
return self._subscription_type
|
||||||
|
|
||||||
|
@property
|
||||||
|
def initial_date(self):
|
||||||
|
"""initial_date property"""
|
||||||
|
return self._initial_date
|
||||||
|
|
||||||
|
@property
|
||||||
|
def next_payment_date(self):
|
||||||
|
"""next_payment_date property"""
|
||||||
|
return self._next_payment_date
|
||||||
|
|
||||||
|
@property
|
||||||
|
def status(self):
|
||||||
|
"""status property"""
|
||||||
|
return self._status
|
||||||
|
|
||||||
|
@property
|
||||||
|
def paused_since(self):
|
||||||
|
"""paused_since property"""
|
||||||
|
return self._paused_since
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cancel_requested(self):
|
||||||
|
"""cancel_requested property"""
|
||||||
|
return self._cancel_requested
|
||||||
|
|
||||||
|
@property
|
||||||
|
def price(self):
|
||||||
|
"""price property"""
|
||||||
|
return self._price
|
||||||
|
|
||||||
|
@property
|
||||||
|
def first_name(self):
|
||||||
|
"""first_name property"""
|
||||||
|
return self._first_name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def last_name(self):
|
||||||
|
"""last_name property"""
|
||||||
|
return self._last_name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def card_information(self):
|
||||||
|
"""card_information property"""
|
||||||
|
return self._card_information
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json):
|
||||||
|
"""return new object from_json"""
|
||||||
|
card_info = GeoRideSubscription_CardInfo.from_json(json['cardInformation']) if cls.json_field_protect(json, 'cardInformation', None) is not None else {}
|
||||||
|
return GeoRideSubscription(
|
||||||
|
cls.json_field_protect(json, 'id', -1),
|
||||||
|
json['type'],
|
||||||
|
cls.json_field_protect(json, 'initialDate'),
|
||||||
|
cls.json_field_protect(json, 'nextPaymentDate'),
|
||||||
|
cls.json_field_protect(json, 'status'),
|
||||||
|
cls.json_field_protect(json, 'pausedSince'),
|
||||||
|
cls.json_field_protect(json, 'cancelRequested'),
|
||||||
|
cls.json_field_protect(json, 'price'),
|
||||||
|
cls.json_field_protect(json, 'firstName'),
|
||||||
|
cls.json_field_protect(json, 'lastName'),
|
||||||
|
card_info
|
||||||
|
)
|
||||||
41
georideapilib/objects/GeoRideSubscription_CardInfo.py
Normal file
41
georideapilib/objects/GeoRideSubscription_CardInfo.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
"""
|
||||||
|
Georide objects implementation
|
||||||
|
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
||||||
|
"""
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
from . import JsonMgtMetaClass
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class GeoRideSubscription_CardInfo(metaclass=JsonMgtMetaClass):
|
||||||
|
""" Account object representation """
|
||||||
|
def __init__(self, last_digits, expiry, brand):
|
||||||
|
self._last_digits = last_digits
|
||||||
|
self._expiry = expiry
|
||||||
|
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
|
||||||
|
def from_json(cls, json):
|
||||||
|
"""return new object from_json"""
|
||||||
|
return GeoRideSubscription_CardInfo(
|
||||||
|
cls.json_field_protect(json, 'lastDigits'),
|
||||||
|
cls.json_field_protect(json, 'expiry'),
|
||||||
|
cls.json_field_protect(json, 'brand')
|
||||||
|
)
|
||||||
618
georideapilib/objects/GeoRideTracker.py
Normal file
618
georideapilib/objects/GeoRideTracker.py
Normal file
@@ -0,0 +1,618 @@
|
|||||||
|
"""
|
||||||
|
Georide objects implementation
|
||||||
|
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
||||||
|
"""
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
from . import JsonMgtMetaClass, GeoRideSubscription
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class GeoRideTracker(metaclass=JsonMgtMetaClass): # 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,
|
||||||
|
last_payment_date, gift_card_id, expires, activation_date, odometer, is_stolen,
|
||||||
|
is_crashed, crash_detection_disabled, speed, moving, position_id, latitude,
|
||||||
|
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, subscription_id, external_battery_voltage,
|
||||||
|
internal_battery_voltage, timezone, is_second_gen, is_up_to_date,
|
||||||
|
subscription, version, gift_card_expires, gift_card_months, odometer_updated_at,
|
||||||
|
maintenance_mode_until, battery_updated_at, is_in_eco, is_calibrated,
|
||||||
|
is_oldsubscription, software_version, has_beacon, has_outdated_beacons, ecall_activated,
|
||||||
|
ecall_crash_mode, assistance_theft_activated,model, business_model, has_theft_case_opened):
|
||||||
|
self._tracker_id = tracker_id
|
||||||
|
self._tracker_name = tracker_name
|
||||||
|
self._device_button_action = device_button_action
|
||||||
|
self._device_button_delay = device_button_delay
|
||||||
|
self._vibration_level = vibration_level
|
||||||
|
self._is_old_tracker = is_old_tracker
|
||||||
|
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._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._can_see_position = can_see_position
|
||||||
|
self._can_lock = can_lock
|
||||||
|
self._can_unlock = can_unlock
|
||||||
|
self._can_share = can_share
|
||||||
|
self._can_unshare = can_unshare
|
||||||
|
self._can_check_speed = can_check_speed
|
||||||
|
self._can_see_statistics = can_see_statistics
|
||||||
|
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
|
||||||
|
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
|
||||||
|
self._subscription = subscription
|
||||||
|
self._version = version
|
||||||
|
self._gift_card_expires = gift_card_expires
|
||||||
|
self._gift_card_months = gift_card_months
|
||||||
|
self._odometer_updated_at = odometer_updated_at
|
||||||
|
self._maintenance_mode_until = maintenance_mode_until
|
||||||
|
self._battery_updated_at = battery_updated_at
|
||||||
|
self._is_in_eco = is_in_eco
|
||||||
|
self._is_calibrated = is_calibrated
|
||||||
|
self._is_oldsubscription = is_oldsubscription
|
||||||
|
self._software_version = software_version
|
||||||
|
self._has_beacon = has_beacon
|
||||||
|
self._has_outdated_beacons = has_outdated_beacons
|
||||||
|
self._ecall_activated = ecall_activated
|
||||||
|
self._ecall_crash_mode = ecall_crash_mode
|
||||||
|
self._assistance_theft_activated = assistance_theft_activated
|
||||||
|
self._model = model
|
||||||
|
self._business_model = business_model
|
||||||
|
self._has_theft_case_opened = has_theft_case_opened
|
||||||
|
self._is_siren_on = False
|
||||||
|
self._siren_last_on_date = time.time()
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tracker_id(self):
|
||||||
|
""" tracker_id """
|
||||||
|
return self._tracker_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tracker_name(self):
|
||||||
|
""" tracker_name """
|
||||||
|
return self._tracker_name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_button_action(self):
|
||||||
|
""" device_button_action """
|
||||||
|
return self._device_button_action
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_button_delay(self):
|
||||||
|
""" device_button_delay """
|
||||||
|
return self._device_button_delay
|
||||||
|
|
||||||
|
@property
|
||||||
|
def vibration_level(self):
|
||||||
|
""" vibration_level """
|
||||||
|
return self._vibration_level
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_old_tracker(self):
|
||||||
|
""" is_old_tracker """
|
||||||
|
return self._is_old_tracker
|
||||||
|
|
||||||
|
@property
|
||||||
|
def auto_lock_freezed_to(self):
|
||||||
|
""" auto_lock_freezed_to """
|
||||||
|
return self._auto_lock_freezed_to
|
||||||
|
|
||||||
|
@property
|
||||||
|
def fixtime(self):
|
||||||
|
""" fixtime """
|
||||||
|
return self._fixtime
|
||||||
|
|
||||||
|
@fixtime.setter
|
||||||
|
def fixtime(self, fixtime):
|
||||||
|
""" fixtime """
|
||||||
|
self._fixtime = fixtime
|
||||||
|
|
||||||
|
@property
|
||||||
|
def role(self):
|
||||||
|
""" role """
|
||||||
|
return self._role
|
||||||
|
|
||||||
|
@property
|
||||||
|
def last_payment_date(self):
|
||||||
|
""" last_payment_date """
|
||||||
|
return self._last_payment_date
|
||||||
|
|
||||||
|
@property
|
||||||
|
def gift_card_id(self):
|
||||||
|
""" gift_card_id """
|
||||||
|
return self._gift_card_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def expires(self):
|
||||||
|
""" expires """
|
||||||
|
return self._expires
|
||||||
|
|
||||||
|
@property
|
||||||
|
def activation_date(self):
|
||||||
|
""" activation_date """
|
||||||
|
return self._activation_date
|
||||||
|
|
||||||
|
@property
|
||||||
|
def odometer(self):
|
||||||
|
""" odometer """
|
||||||
|
return self._odometer
|
||||||
|
|
||||||
|
@property
|
||||||
|
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 """
|
||||||
|
return self._crash_detection_disabled
|
||||||
|
|
||||||
|
@property
|
||||||
|
def speed(self):
|
||||||
|
""" speed """
|
||||||
|
return self._speed
|
||||||
|
|
||||||
|
@speed.setter
|
||||||
|
def speed(self, speed):
|
||||||
|
""" speed """
|
||||||
|
self._speed = speed
|
||||||
|
|
||||||
|
@property
|
||||||
|
def moving(self):
|
||||||
|
""" moving """
|
||||||
|
return self._moving
|
||||||
|
|
||||||
|
@moving.setter
|
||||||
|
def moving(self, moving):
|
||||||
|
""" moving """
|
||||||
|
self._moving = moving
|
||||||
|
|
||||||
|
@property
|
||||||
|
def position_id(self):
|
||||||
|
""" position_id """
|
||||||
|
return self._position_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def latitude(self):
|
||||||
|
""" latitude """
|
||||||
|
return self._latitude
|
||||||
|
|
||||||
|
@latitude.setter
|
||||||
|
def latitude(self, latitude):
|
||||||
|
""" latitude """
|
||||||
|
self._latitude = latitude
|
||||||
|
|
||||||
|
@property
|
||||||
|
def longitude(self):
|
||||||
|
""" longitude """
|
||||||
|
return self._longitude
|
||||||
|
|
||||||
|
@longitude.setter
|
||||||
|
def longitude(self, longitude):
|
||||||
|
""" longitude """
|
||||||
|
self._longitude = longitude
|
||||||
|
|
||||||
|
@property
|
||||||
|
def altitude(self):
|
||||||
|
""" altitude """
|
||||||
|
return self._altitude
|
||||||
|
|
||||||
|
@property
|
||||||
|
def locked_position_id(self):
|
||||||
|
""" locked_position_id """
|
||||||
|
return self._locked_position_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def locked_latitude(self):
|
||||||
|
""" locked_latitude """
|
||||||
|
return self._locked_latitude
|
||||||
|
|
||||||
|
@locked_latitude.setter
|
||||||
|
def locked_latitude(self, locked_latitude):
|
||||||
|
""" locked_latitude """
|
||||||
|
self._locked_latitude = locked_latitude
|
||||||
|
|
||||||
|
@property
|
||||||
|
def locked_longitude(self):
|
||||||
|
""" locked_longitude """
|
||||||
|
return self._locked_longitude
|
||||||
|
|
||||||
|
@locked_longitude.setter
|
||||||
|
def locked_longitude(self, locked_longitude):
|
||||||
|
""" locked_longitude """
|
||||||
|
self._locked_longitude = locked_longitude
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_locked(self):
|
||||||
|
""" is_locked """
|
||||||
|
return self._is_locked
|
||||||
|
|
||||||
|
@is_locked.setter
|
||||||
|
def is_locked(self, is_locked):
|
||||||
|
""" is_locked """
|
||||||
|
self._is_locked = is_locked
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_see_position(self):
|
||||||
|
""" can_see_position """
|
||||||
|
return self._can_see_position
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_lock(self):
|
||||||
|
""" can_lock """
|
||||||
|
return self._can_lock
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_unlock(self):
|
||||||
|
""" can_unlock """
|
||||||
|
return self._can_unlock
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_share(self):
|
||||||
|
""" can_share """
|
||||||
|
return self._can_share
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_unshare(self):
|
||||||
|
""" can_unshare """
|
||||||
|
return self._can_unshare
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_check_speed(self):
|
||||||
|
""" can_check_speed """
|
||||||
|
return self._can_check_speed
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_see_statistics(self):
|
||||||
|
""" can_see_statistics """
|
||||||
|
return self._can_see_statistics
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_send_broken_down_signal(self):
|
||||||
|
""" can_send_broken_down_signal """
|
||||||
|
return self._can_send_broken_down_signal
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_send_stolen_signal(self):
|
||||||
|
""" can_send_stolen_signal """
|
||||||
|
return self._can_send_stolen_signal
|
||||||
|
|
||||||
|
@property
|
||||||
|
def status(self):
|
||||||
|
""" status """
|
||||||
|
return self._status
|
||||||
|
|
||||||
|
@status.setter
|
||||||
|
def status(self, status):
|
||||||
|
""" 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
|
||||||
|
|
||||||
|
@property
|
||||||
|
def subscription(self):
|
||||||
|
""" subscription property """
|
||||||
|
return self._subscription
|
||||||
|
|
||||||
|
@property
|
||||||
|
def version(self):
|
||||||
|
""" version property """
|
||||||
|
return self._version
|
||||||
|
|
||||||
|
@property
|
||||||
|
def gift_card_expires(self):
|
||||||
|
""" gift_card_expires property """
|
||||||
|
return self._gift_card_expires
|
||||||
|
|
||||||
|
@property
|
||||||
|
def gift_card_months(self):
|
||||||
|
""" gift_card_months property """
|
||||||
|
return self._gift_card_months
|
||||||
|
|
||||||
|
@property
|
||||||
|
def odometer_updated_at(self):
|
||||||
|
""" odometer_updated_at property """
|
||||||
|
return self._odometer_updated_at
|
||||||
|
|
||||||
|
@property
|
||||||
|
def maintenance_mode_until(self):
|
||||||
|
""" maintenance_mode_until property """
|
||||||
|
return self._maintenance_mode_until
|
||||||
|
|
||||||
|
@property
|
||||||
|
def battery_updated_at(self):
|
||||||
|
""" battery_updated_at property """
|
||||||
|
return self._battery_updated_at
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_in_eco(self):
|
||||||
|
""" is_in_eco property """
|
||||||
|
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
|
||||||
|
def is_calibrated(self):
|
||||||
|
""" is_calibrated property """
|
||||||
|
return self._is_calibrated
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_oldsubscription(self):
|
||||||
|
""" is_oldsubscription property """
|
||||||
|
return self._is_oldsubscription
|
||||||
|
|
||||||
|
@property
|
||||||
|
def software_version(self):
|
||||||
|
""" software_version property """
|
||||||
|
return self._software_version
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_beacon(self):
|
||||||
|
""" has_beacon property """
|
||||||
|
return self._has_beacon
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_outdated_beacons(self):
|
||||||
|
""" has_outdated_beacons property """
|
||||||
|
return self._has_outdated_beacons
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ecall_activated(self):
|
||||||
|
""" ecall_activated property """
|
||||||
|
return self._ecall_activated
|
||||||
|
|
||||||
|
@property
|
||||||
|
def version(self):
|
||||||
|
""" version property """
|
||||||
|
return self._version
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ecall_crash_mode(self):
|
||||||
|
""" eCallCrashMode property """
|
||||||
|
return self._ecall_crash_mode
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _ssistance_theft_activated(self):
|
||||||
|
""" assistanceTheftActivated property """
|
||||||
|
return self._assistance_theft_activated
|
||||||
|
|
||||||
|
@property
|
||||||
|
def model(self):
|
||||||
|
""" model property """
|
||||||
|
return self._model
|
||||||
|
|
||||||
|
@property
|
||||||
|
def business_model(self):
|
||||||
|
""" businessModel property """
|
||||||
|
return self._business_model
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_theft_case_opened(self):
|
||||||
|
""" hasTheftCaseOpened property """
|
||||||
|
return self._has_theft_case_opened
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json):
|
||||||
|
"""return new object fromjson"""
|
||||||
|
|
||||||
|
"version": 3,
|
||||||
|
"eCallCrashMode": "default",
|
||||||
|
"assistanceTheftActivated": True,
|
||||||
|
"model": "georide-3",
|
||||||
|
"businessModel": "leasing",
|
||||||
|
"hasTheftCaseOpened": False,
|
||||||
|
|
||||||
|
return GeoRideTracker(
|
||||||
|
json['trackerId'], # Mandatory
|
||||||
|
json['trackerName'], # Mandatory
|
||||||
|
cls.json_field_protect(json,'deviceButtonAction'),
|
||||||
|
cls.json_field_protect(json,'deviceButtonDelay'),
|
||||||
|
cls.json_field_protect(json,'vibrationLevel'),
|
||||||
|
cls.json_field_protect(json,'isOldTracker', False),
|
||||||
|
cls.json_field_protect(json,'autoLockFreezedTo'),
|
||||||
|
cls.json_field_protect(json,'fixtime'),
|
||||||
|
json['role'], # Mandatory
|
||||||
|
json['lastPaymentDate'],# Mandatory
|
||||||
|
cls.json_field_protect(json,'giftCardId'),
|
||||||
|
cls.json_field_protect(json,'expires'),
|
||||||
|
cls.json_field_protect(json,'activationDate'),
|
||||||
|
json['odometer'],#Mandatory
|
||||||
|
cls.json_field_protect(json,'isStolen', False),
|
||||||
|
cls.json_field_protect(json,'isCrashed', False),
|
||||||
|
cls.json_field_protect(json,'crashDetectionDisabled'),
|
||||||
|
json['speed'], # Mandatory
|
||||||
|
json['moving'], # Mandatory
|
||||||
|
cls.json_field_protect(json,'positionId', -1),
|
||||||
|
json['latitude'], # Mandatory
|
||||||
|
json['longitude'], # Mandatory
|
||||||
|
cls.json_field_protect(json,'altitude', 0),
|
||||||
|
cls.json_field_protect(json,'lockedPositionId'),
|
||||||
|
cls.json_field_protect(json,'lockedLatitude'),
|
||||||
|
cls.json_field_protect(json,'lockedLongitude'),
|
||||||
|
json['isLocked'], # Mandatory
|
||||||
|
json['canSeePosition'],# Mandatory
|
||||||
|
cls.json_field_protect(json,'canLock', False),
|
||||||
|
cls.json_field_protect(json,'canUnlock', False),
|
||||||
|
cls.json_field_protect(json,'canShare', False),
|
||||||
|
cls.json_field_protect(json,'canUnshare', False),
|
||||||
|
cls.json_field_protect(json,'canCheckSpeed', False),
|
||||||
|
cls.json_field_protect(json,'canSeeStatistics', False),
|
||||||
|
cls.json_field_protect(json,'canSendBrokenDownSignal', False),
|
||||||
|
cls.json_field_protect(json,'canSendStolenSignal', False),
|
||||||
|
json['status'],# Mandatory
|
||||||
|
cls.json_field_protect(json,'subscriptionId', -1),
|
||||||
|
cls.json_field_protect(json,'externalBatteryVoltage', -1.0),
|
||||||
|
cls.json_field_protect(json,'internalBatteryVoltage', -1.0),
|
||||||
|
cls.json_field_protect(json,'timezone', "Europe/Paris"),
|
||||||
|
cls.json_field_protect(json,'isSecondGen', False),
|
||||||
|
cls.json_field_protect(json,'isUpToDate', False),
|
||||||
|
GeoRideSubscription.from_json(json['subscription']) if cls.json_field_protect(json,'subscription') is not None else None,
|
||||||
|
cls.json_field_protect(json,'version', 1),
|
||||||
|
cls.json_field_protect(json,'giftCardExpires'),
|
||||||
|
cls.json_field_protect(json,'giftCardMonths'),
|
||||||
|
cls.json_field_protect(json,'odometerUpdatedAt'),
|
||||||
|
cls.json_field_protect(json,'maintenanceModeUntil'),
|
||||||
|
cls.json_field_protect(json,'batteryUpdatedAt'),
|
||||||
|
cls.json_field_protect(json,'isInEco', False),
|
||||||
|
cls.json_field_protect(json,'isCalibrated', True),
|
||||||
|
cls.json_field_protect(json,'isOldSubscription', True),
|
||||||
|
cls.json_field_protect(json,'softwareVersion', 1),
|
||||||
|
cls.json_field_protect(json,'hasBeacon', False),
|
||||||
|
cls.json_field_protect(json,'hasOutdatedBeacons', False),
|
||||||
|
cls.json_field_protect(json,'eCallActivated', False)
|
||||||
|
)
|
||||||
|
|
||||||
|
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._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
|
||||||
|
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
|
||||||
|
self._subscription = tracker.subscription
|
||||||
|
self._version = tracker.version
|
||||||
|
self._gift_card_expires = tracker.gift_card_expires
|
||||||
|
self._gift_card_months = tracker.gift_card_months
|
||||||
|
self._odometer_updated_at = tracker.odometer_updated_at
|
||||||
|
self._maintenance_mode_until = tracker.maintenance_mode_until
|
||||||
|
self._battery_updated_at = tracker.battery_updated_at
|
||||||
|
self._is_in_eco = tracker.is_in_eco
|
||||||
|
self._is_calibrated = tracker.is_calibrated
|
||||||
|
self._is_oldsubscription = tracker.is_oldsubscription
|
||||||
|
self._software_version = tracker.software_version
|
||||||
|
self._has_beacon = tracker.has_beacon
|
||||||
|
self._has_outdated_beacons = tracker.has_outdated_beacons
|
||||||
|
self._ecall_activated = tracker.ecall_activated
|
||||||
|
self._ecall_crash_mode = tracker.ecall_crash_mode
|
||||||
|
self._assistance_theft_activated = tracker.assistance_theft_activated
|
||||||
|
self._model = tracker.model
|
||||||
|
self._business_model = tracker.business_model
|
||||||
|
self._has_theft_case_opened = tracker.has_theft_case_opened
|
||||||
115
georideapilib/objects/GeoRideTrackerBeacon.py
Normal file
115
georideapilib/objects/GeoRideTrackerBeacon.py
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
"""
|
||||||
|
Georide objects implementation
|
||||||
|
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
||||||
|
"""
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
from . import JsonMgtMetaClass
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class GeoRideTrackerBeacon:
|
||||||
|
""" GeoRideTrackerBeacon representation """
|
||||||
|
def __init__(self, beacon_id, linked_tracker_id, name, created_at, updated_at,
|
||||||
|
mac_address, battery_level, last_battery_level_update, sleep_delay,
|
||||||
|
is_updated, power):
|
||||||
|
self._beacon_id = beacon_id
|
||||||
|
self._linked_tracker_id = linked_tracker_id
|
||||||
|
self._name = name
|
||||||
|
self._created_at = created_at
|
||||||
|
self._updated_at = updated_at
|
||||||
|
self._mac_address = mac_address
|
||||||
|
self._battery_level = battery_level
|
||||||
|
self._last_battery_level_update = last_battery_level_update
|
||||||
|
self._sleep_delay = sleep_delay
|
||||||
|
self._is_updated = is_updated
|
||||||
|
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
|
||||||
|
def beacon_id(self):
|
||||||
|
"""beacon_id property"""
|
||||||
|
return self._beacon_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
"""name property"""
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def created_at(self):
|
||||||
|
"""created_at property"""
|
||||||
|
return self._created_at
|
||||||
|
|
||||||
|
@property
|
||||||
|
def updated_at(self):
|
||||||
|
"""updated_at property"""
|
||||||
|
return self._updated_at
|
||||||
|
|
||||||
|
@property
|
||||||
|
def mac_address(self):
|
||||||
|
"""mac_address property"""
|
||||||
|
return self._mac_address
|
||||||
|
|
||||||
|
@property
|
||||||
|
def battery_level(self):
|
||||||
|
"""battery_level property"""
|
||||||
|
return self._battery_level
|
||||||
|
|
||||||
|
@property
|
||||||
|
def last_battery_level_update(self):
|
||||||
|
"""last_battery_level_update property"""
|
||||||
|
return self._last_battery_level_update
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sleep_delay(self):
|
||||||
|
"""sleep_delay property"""
|
||||||
|
return self._sleep_delay
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_updated(self):
|
||||||
|
"""is_updated property"""
|
||||||
|
return self._is_updated
|
||||||
|
|
||||||
|
@property
|
||||||
|
def power(self):
|
||||||
|
"""power property"""
|
||||||
|
return self._power
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json):
|
||||||
|
"""return new object from_json"""
|
||||||
|
return GeoRideTrackerBeacon(
|
||||||
|
json['id'],
|
||||||
|
json['linked_tracker_id'],
|
||||||
|
json['name'],
|
||||||
|
json['createdAt'],
|
||||||
|
json['updatedAt'],
|
||||||
|
json['macAddress'],
|
||||||
|
json['batteryLevel'],
|
||||||
|
json['lastBatteryLevelUpdate'],
|
||||||
|
json['sleepDelay'],
|
||||||
|
json['isUpdated'],
|
||||||
|
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
|
||||||
60
georideapilib/objects/GeoRideTrackerPosition.py
Normal file
60
georideapilib/objects/GeoRideTrackerPosition.py
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
"""
|
||||||
|
Georide objects implementation
|
||||||
|
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
||||||
|
"""
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class GeoRideTrackerPosition:
|
||||||
|
""" Tracker position object representation """
|
||||||
|
def __init__(self, fixtime, latitude, longitude, altitude, speed, address): # pylint: disable= R0913
|
||||||
|
self._fixtime = fixtime
|
||||||
|
self._latitude = latitude
|
||||||
|
self._longitude = longitude
|
||||||
|
self._altitude = altitude
|
||||||
|
self._speed = speed
|
||||||
|
self._address = address
|
||||||
|
|
||||||
|
@property
|
||||||
|
def fixtime(self):
|
||||||
|
""" fixtime """
|
||||||
|
return self._fixtime
|
||||||
|
|
||||||
|
@property
|
||||||
|
def latitude(self):
|
||||||
|
""" latitude """
|
||||||
|
return self._latitude
|
||||||
|
|
||||||
|
@property
|
||||||
|
def longitude(self):
|
||||||
|
""" longitude """
|
||||||
|
return self._longitude
|
||||||
|
|
||||||
|
@property
|
||||||
|
def altitude(self):
|
||||||
|
""" altitude """
|
||||||
|
return self._altitude
|
||||||
|
|
||||||
|
@property
|
||||||
|
def speed(self):
|
||||||
|
""" speed (m/s) """
|
||||||
|
return self._speed
|
||||||
|
|
||||||
|
@property
|
||||||
|
def address(self):
|
||||||
|
""" address """
|
||||||
|
return self._address
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_json(json):
|
||||||
|
"""return new object fromjson"""
|
||||||
|
return GeoRideTrackerPosition(
|
||||||
|
json['fixtime'],
|
||||||
|
json['latitude'],
|
||||||
|
json['longitude'],
|
||||||
|
json['altitude'],
|
||||||
|
json['speed'],
|
||||||
|
json['address']
|
||||||
|
)
|
||||||
134
georideapilib/objects/GeoRideTrackerTrip.py
Normal file
134
georideapilib/objects/GeoRideTrackerTrip.py
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
"""
|
||||||
|
Georide objects implementation
|
||||||
|
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
||||||
|
"""
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
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,
|
||||||
|
nice_end_address, end_lat, end_lon, start_time, end_time):
|
||||||
|
self._trip_id = trip_id
|
||||||
|
self._tracker_id = tracker_id
|
||||||
|
self._average_speed = average_speed
|
||||||
|
self._max_speed = max_speed
|
||||||
|
self._distance = distance
|
||||||
|
self._duration = duration
|
||||||
|
self._start_address = start_address
|
||||||
|
self._nice_start_address = nice_start_address
|
||||||
|
self._start_lat = start_lat
|
||||||
|
self._start_lon = start_lon
|
||||||
|
self._end_address = end_address
|
||||||
|
self._nice_end_address = nice_end_address
|
||||||
|
self._end_lat = end_lat
|
||||||
|
self._end_lon = end_lon
|
||||||
|
self._start_time = start_time
|
||||||
|
self._end_time = end_time
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def trip_id(self):
|
||||||
|
"""trip_id """
|
||||||
|
return self._trip_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tracker_id(self):
|
||||||
|
""" tracker_id """
|
||||||
|
return self._tracker_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def average_speed(self):
|
||||||
|
""" average_speed """
|
||||||
|
return self._average_speed
|
||||||
|
|
||||||
|
@property
|
||||||
|
def max_speed(self):
|
||||||
|
""" max_speed """
|
||||||
|
return self._max_speed
|
||||||
|
|
||||||
|
@property
|
||||||
|
def distance(self):
|
||||||
|
""" distance """
|
||||||
|
return self._distance
|
||||||
|
|
||||||
|
@property
|
||||||
|
def duration(self):
|
||||||
|
""" duration """
|
||||||
|
return self._duration
|
||||||
|
|
||||||
|
@property
|
||||||
|
def start_address(self):
|
||||||
|
""" start_address """
|
||||||
|
return self._start_address
|
||||||
|
|
||||||
|
@property
|
||||||
|
def nice_start_address(self):
|
||||||
|
""" nice_start_address """
|
||||||
|
return self._nice_start_address
|
||||||
|
|
||||||
|
@property
|
||||||
|
def start_lat(self):
|
||||||
|
""" start_lat """
|
||||||
|
return self._start_lat
|
||||||
|
|
||||||
|
@property
|
||||||
|
def start_lon(self):
|
||||||
|
""" start_lon """
|
||||||
|
return self._start_lon
|
||||||
|
|
||||||
|
@property
|
||||||
|
def end_address(self):
|
||||||
|
""" end_address """
|
||||||
|
return self._end_address
|
||||||
|
|
||||||
|
@property
|
||||||
|
def nice_end_address(self):
|
||||||
|
""" nice_end_address """
|
||||||
|
return self._nice_end_address
|
||||||
|
|
||||||
|
@property
|
||||||
|
def end_lat(self):
|
||||||
|
"""end_lat """
|
||||||
|
return self._end_lat
|
||||||
|
|
||||||
|
@property
|
||||||
|
def end_lon(self):
|
||||||
|
"""end_lon """
|
||||||
|
return self._end_lon
|
||||||
|
|
||||||
|
@property
|
||||||
|
def start_time(self):
|
||||||
|
""" start_time """
|
||||||
|
return self._start_time
|
||||||
|
|
||||||
|
@property
|
||||||
|
def end_time(self):
|
||||||
|
""" end_time """
|
||||||
|
return self._end_time
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_json(json):
|
||||||
|
"""return new object from json"""
|
||||||
|
return GeoRideTrackerTrip(
|
||||||
|
json['id'],
|
||||||
|
json['trackerId'],
|
||||||
|
json['averageSpeed'],
|
||||||
|
json['maxSpeed'],
|
||||||
|
json['distance'],
|
||||||
|
json['duration'],
|
||||||
|
json['startAddress'],
|
||||||
|
json['niceStartAddress'],
|
||||||
|
json['startLat'],
|
||||||
|
json['startLon'],
|
||||||
|
json['endAddress'],
|
||||||
|
json['niceEndAddress'],
|
||||||
|
json['endLat'],
|
||||||
|
json['endLon'],
|
||||||
|
json['startTime'],
|
||||||
|
json['endTime']
|
||||||
|
)
|
||||||
75
georideapilib/objects/GeoRideUser.py
Normal file
75
georideapilib/objects/GeoRideUser.py
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
"""
|
||||||
|
Georide objects implementation
|
||||||
|
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
||||||
|
"""
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
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):
|
||||||
|
self._user_id = user_id
|
||||||
|
self._email = email
|
||||||
|
self._first_name = first_name
|
||||||
|
self._created_at = created_at
|
||||||
|
self._phone_number = phone_number
|
||||||
|
self._push_user_token = push_user_token
|
||||||
|
self._legal = legal
|
||||||
|
self._date_of_birth = date_of_birth
|
||||||
|
|
||||||
|
@property
|
||||||
|
def user_id(self):
|
||||||
|
""" user_id """
|
||||||
|
return self._user_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def email(self):
|
||||||
|
""" email """
|
||||||
|
return self._email
|
||||||
|
|
||||||
|
@property
|
||||||
|
def first_name(self):
|
||||||
|
""" first_name """
|
||||||
|
return self._first_name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def created_at(self):
|
||||||
|
""" created_at """
|
||||||
|
return self._created_at
|
||||||
|
|
||||||
|
@property
|
||||||
|
def phone_number(self):
|
||||||
|
""" phone_number """
|
||||||
|
return self._phone_number
|
||||||
|
|
||||||
|
@property
|
||||||
|
def push_user_token(self):
|
||||||
|
""" push_user_token """
|
||||||
|
return self._push_user_token
|
||||||
|
|
||||||
|
@property
|
||||||
|
def legal(self):
|
||||||
|
""" legal """
|
||||||
|
return self._legal
|
||||||
|
|
||||||
|
@property
|
||||||
|
def date_of_birth(self):
|
||||||
|
""" date_ofo_birth """
|
||||||
|
return self._date_of_birth
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_json(json):
|
||||||
|
"""return new object fromjson"""
|
||||||
|
return GeoRideUser(
|
||||||
|
json['id'],
|
||||||
|
json['email'],
|
||||||
|
json['firstName'],
|
||||||
|
json['createdAt'],
|
||||||
|
json['phoneNumber'],
|
||||||
|
json['pushUserToken'],
|
||||||
|
json['legal'],
|
||||||
|
json['dateOfBirth']
|
||||||
|
)
|
||||||
13
georideapilib/objects/JsonMgtMetaClass.py
Normal file
13
georideapilib/objects/JsonMgtMetaClass.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
"""
|
||||||
|
Georide objects implementation
|
||||||
|
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
||||||
|
"""
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class JsonMgtMetaClass(type):
|
||||||
|
@staticmethod
|
||||||
|
def json_field_protect(json, field_name, default_value = None):
|
||||||
|
return json[field_name] if field_name in json.keys() else default_value
|
||||||
11
georideapilib/objects/__init__.py
Normal file
11
georideapilib/objects/__init__.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from .JsonMgtMetaClass import *
|
||||||
|
from .GeoRideAccount import *
|
||||||
|
from .GeoRideSharedTrip import *
|
||||||
|
from .GeoRideSubscription_CardInfo import *
|
||||||
|
from .GeoRideSubscription import *
|
||||||
|
from .GeoRideTracker import *
|
||||||
|
from .GeoRideTrackerBeacon import *
|
||||||
|
from .GeoRideTrackerPosition import *
|
||||||
|
from .GeoRideTrackerTrip import *
|
||||||
|
from .GeoRideUser import *
|
||||||
|
|
||||||
114
georideapilib/socket.py
Normal file
114
georideapilib/socket.py
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
""" GeoRide socket-io implementation """
|
||||||
|
import logging
|
||||||
|
import socketio
|
||||||
|
|
||||||
|
from georideapilib.api import GEORIDE_API_HOST
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
sio = socketio.Client(reconnection=True) # pylint: disable=C0103
|
||||||
|
|
||||||
|
@sio.on('connect')
|
||||||
|
def on_connect():
|
||||||
|
""" event: connected """
|
||||||
|
_LOGGER.debug('GeoRide socket connected')
|
||||||
|
|
||||||
|
@sio.on('disconnect')
|
||||||
|
def on_disconnect():
|
||||||
|
""" event: disconnected """
|
||||||
|
_LOGGER.debug('GeoRide socket disconnected')
|
||||||
|
|
||||||
|
|
||||||
|
class GeoRideSocket():
|
||||||
|
"""docstring for GeoRideSocket"""
|
||||||
|
def __init__(self):
|
||||||
|
self._on_message_callback = None
|
||||||
|
self._on_device_callback = None
|
||||||
|
self._on_position_callback = None
|
||||||
|
self._on_alarm_callback = None
|
||||||
|
self._on_refresh_tracker_callback = None
|
||||||
|
self._on_locked_callback = None
|
||||||
|
self._initialised = False
|
||||||
|
|
||||||
|
|
||||||
|
def subscribe_on_message(self, callback_function):
|
||||||
|
"""event: tells you authentication informations."""
|
||||||
|
self._on_message_callback = callback_function
|
||||||
|
|
||||||
|
def subscribe_device(self, callback_function):
|
||||||
|
"""event: tells you when a device is added to the account."""
|
||||||
|
self._on_device_callback = callback_function
|
||||||
|
|
||||||
|
def subscribe_position(self, callback_function):
|
||||||
|
"""event: tells you when a device sent a position."""
|
||||||
|
self._on_position_callback = callback_function
|
||||||
|
|
||||||
|
def subscribe_alarm(self, callback_function):
|
||||||
|
"""event: tells you when a device trigger an alarm."""
|
||||||
|
self._on_alarm_callback = callback_function
|
||||||
|
|
||||||
|
def subscribe_refresh_tracker(self, callback_function):
|
||||||
|
"""event: tells you when you need to refresh your list of trackers"""
|
||||||
|
self._on_refresh_tracker_callback = callback_function
|
||||||
|
|
||||||
|
def subscribe_locked(self, callback_function):
|
||||||
|
"""event: tells you when a device has been locked or unlocked."""
|
||||||
|
self._on_locked_callback = callback_function
|
||||||
|
|
||||||
|
|
||||||
|
def init(self):
|
||||||
|
"""init the context"""
|
||||||
|
@sio.on('message')
|
||||||
|
def on_message(data):
|
||||||
|
""" on_message """
|
||||||
|
_LOGGER.debug('Message received: %s', data)
|
||||||
|
if self._on_message_callback is not None:
|
||||||
|
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(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(data)
|
||||||
|
|
||||||
|
@sio.on('alarm')
|
||||||
|
def on_alarm(data):
|
||||||
|
""" on_alarm """
|
||||||
|
_LOGGER.debug('Alarm received: %s', data)
|
||||||
|
if self._on_alarm_callback is not None:
|
||||||
|
self._on_alarm_callback(data)
|
||||||
|
|
||||||
|
@sio.on('refreshTrackersInstruction')
|
||||||
|
def on_refresh_tracker():
|
||||||
|
""" on_refresh_tracker """
|
||||||
|
_LOGGER.debug('Refresh tracker received')
|
||||||
|
if self._on_refresh_tracker_callback is not None:
|
||||||
|
self._on_refresh_tracker_callback()
|
||||||
|
|
||||||
|
@sio.on('lockedPosition')
|
||||||
|
def on_locked(data):
|
||||||
|
""" on_locked """
|
||||||
|
_LOGGER.debug('Locked received: %s', data)
|
||||||
|
if self._on_locked_callback is not None:
|
||||||
|
self._on_locked_callback(data)
|
||||||
|
self._initialised = True
|
||||||
|
|
||||||
|
def connect(self, auth_token):
|
||||||
|
""" connect to the georide socket"""
|
||||||
|
if self._initialised is not False:
|
||||||
|
sio.connect(GEORIDE_API_HOST, headers={'token': auth_token})
|
||||||
|
sio.wait()
|
||||||
|
else:
|
||||||
|
_LOGGER.error("Please call init() before")
|
||||||
|
|
||||||
|
def disconnect(self):
|
||||||
|
"""disconnect from the georide socket"""
|
||||||
|
sio.disconnect()
|
||||||
34
logging.conf
Normal file
34
logging.conf
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[loggers]
|
||||||
|
keys=root,example
|
||||||
|
|
||||||
|
[handlers]
|
||||||
|
keys=consoleHandler
|
||||||
|
|
||||||
|
[formatters]
|
||||||
|
keys=simpleFormatter
|
||||||
|
|
||||||
|
[logger_root]
|
||||||
|
level=DEBUG
|
||||||
|
handlers=consoleHandler
|
||||||
|
|
||||||
|
[logger_example]
|
||||||
|
level=DEBUG
|
||||||
|
handlers=consoleHandler
|
||||||
|
qualname=simpleExample
|
||||||
|
propagate=0
|
||||||
|
|
||||||
|
[logger_engine_io]
|
||||||
|
level=ERROR
|
||||||
|
handlers=consoleHandler
|
||||||
|
qualname=engineio.client
|
||||||
|
propagate=0
|
||||||
|
|
||||||
|
[handler_consoleHandler]
|
||||||
|
class=StreamHandler
|
||||||
|
level=DEBUG
|
||||||
|
formatter=simpleFormatter
|
||||||
|
args=(sys.stdout,)
|
||||||
|
|
||||||
|
[formatter_simpleFormatter]
|
||||||
|
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
|
||||||
|
datefmt=
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"domain": "georide",
|
|
||||||
"name": "Georide",
|
|
||||||
"config_flow": true,
|
|
||||||
"documentation": "https://georide.fr",
|
|
||||||
"dependencies": [
|
|
||||||
"urllib3"
|
|
||||||
],
|
|
||||||
"codeowners": []
|
|
||||||
}
|
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
description-file = README.md
|
description_file = README.md
|
||||||
14
setup.py
14
setup.py
@@ -18,17 +18,17 @@ CURRENT_DIR = os.path.dirname(__file__)
|
|||||||
# "python setup.py register sdist upload -r pypitest"
|
# "python setup.py register sdist upload -r pypitest"
|
||||||
setup(
|
setup(
|
||||||
name='georideapilib',
|
name='georideapilib',
|
||||||
packages=['georideapilib'], # this must be the same as the name above
|
packages=['georideapilib', 'georideapilib.objects'], # this must be the same as the name above
|
||||||
version='0.1.0',
|
version='0.9.0',
|
||||||
description='Lib to control georide tracker devices with their 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/ptimatth/pyGeoride',
|
url='https://github.com/hacf/georide-api',
|
||||||
download_url='https://codeload.github.com/ptimatth/pyGeoride/tar.gz/0.1.0',
|
download_url='https://codeload.github.com/hacf/georide-api/tar.gz/0.8.1',
|
||||||
keywords=['rest', 'georide', 'api', 'grutier'], # arbitrary keywords
|
keywords=['rest', 'georide', 'api', 'grutier', 'GeoRide'], # arbitrary keywords
|
||||||
classifiers=[],
|
classifiers=[],
|
||||||
install_requires=[],
|
install_requires=["python-socketio[client]==4.6.1"],
|
||||||
tests_require=[
|
tests_require=[
|
||||||
'pytest>=3.7',
|
'pytest>=3.7',
|
||||||
'pytest-pep8',
|
'pytest-pep8',
|
||||||
|
|||||||
Reference in New Issue
Block a user