Utilities
Functions
- terminusgps.wialon.utils.generate_wialon_password(length: int = 32) str [source]
Generates a Wialon compliant password between
8
and64
characters.The generated password will contain:
At least one uppercase letter.
At least one lowercase letter.
At least one special symbol.
At least three digits.
- Parameters:
length (
int
) – Length of the generated password. Default is32
.- Raises:
ValueError – If
length
is less than8
or greater than64
.- Returns:
A Wialon compliant password.
- Return type:
- terminusgps.wialon.utils.get_carrier_names(session: WialonSession) list[str] [source]
Returns a list of all telecommunication carrier company names present in Wialon.
- Parameters:
session (
WialonSession
) – A valid Wialon API session.- Returns:
A list of telecommunication carrier company names.
- Return type:
- terminusgps.wialon.utils.get_hw_type_id(name: str, session: WialonSession) int | None [source]
Takes a Wialon hardware type name and returns its id, if it exists.
- Parameters:
name (
str
) – The name of a Wialon hardware type.session (
WialonSession
) – A valid Wialon API session.
- Raises:
WialonError – If something goes wrong during a Wialon API call.
- Returns:
A Wialon hardware type id, if it was found.
- Return type:
- terminusgps.wialon.utils.get_resources(session: WialonSession) list[WialonResource] | None [source]
Returns a list of all resources in Wialon.
- Parameters:
session (
WialonSession
) – A valid Wialon API session.- Returns:
A list of resources, if found.
- Return type:
- terminusgps.wialon.utils.get_unit_by_iccid(iccid: str, session: WialonSession) WialonUnit | None [source]
Returns a unit by iccid (SIM card #).
- Parameters:
iccid (
str
) – A SIM card #.session (
WialonSession
) – A valid Wialon API session.
- Returns:
The unit, if it was found.
- Return type:
WialonUnit
|None
- terminusgps.wialon.utils.get_unit_by_imei(imei: str, session: WialonSession) WialonUnit | None [source]
Takes a Wialon unit’s IMEI # and returns its unit id.
- Parameters:
imei (
str
) – A Wialon unit’s IMEI #.session (
WialonSession
) – A valid Wialon API session.
- Raises:
ValueError – If
imei
contains non-digit characters.WialonError – If something goes wrong during a Wialon API call.
- Returns:
A Wialon object id, if it was found.
- Return type:
- terminusgps.wialon.utils.get_units_by_carrier(carrier_name: str, session: WialonSession) list[WialonUnit] | None [source]
Returns a list of all units by telecommunications carrier company name.
- Parameters:
carrier_name (
str
) – A telecommunications carrier company name, e.g."US Cell"
or"Conetixx"
.session (
WialonSession
) – A valid Wialon API session.
- Returns:
A list of units, if any were found.
- Return type:
- terminusgps.wialon.utils.get_user_by_name(name: str, session: WialonSession) WialonUnit | None [source]
Returns a Wialon user by name, if it exists.
- Parameters:
name (
str
) – A Wialon user name.session (
WialonSession
) – A valid Wialon API session.
- Returns:
A Wialon unit, if any.
- Return type:
- terminusgps.wialon.utils.get_vin_info(vin_number: str, session: WialonSession) dict [source]
Retrieves vehicle data from a VIN number.
- Parameters:
value (
str
) – A vehicle’s VIN number.session (
WialonSession
) – A valid Wialon API session.
- Returns:
A dictionary of vehicle information, if any was found.
- Return type:
- terminusgps.wialon.utils.is_unique(value: str, session: WialonSession, items_type: str = 'avl_unit') bool [source]
Determines if the value is unique among Wialon objects of type ‘items_type’.
- Parameters:
value (
str
) – A Wialon object name.session (
WialonSession
) – A valid Wialon API session.items_type (
str
) – Type of Wialon objects to validate the value against. Default is"avl_unit"
.
- Raises:
WialonError – If something goes wrong during a Wialon API call.
- Returns:
Whether or not the value is unique among ‘items_type’.
- Return type:
Usage
from terminusgps.wialon.session import WialonSession
from terminusgps.wialon.utils import get_id_from_iccid, generate_wialon_password
# Generate random Wialon compliant passwords
password_0 = generate_wialon_password(16)
password_1 = generate_wialon_password(32)
password_2 = generate_wialon_password(64)
# Retrieve unit id from IMEI #
with WialonSession() as session:
unit_id = get_id_from_imei("869084062183235", session=session)
print(f"{unit_id = }") # unit_id = 28006231