System class documentation¶
System class¶
- class apreshttp.System(api_obj)¶
System wraps system-related API methods
System provides a wrapper for the system-related functions exposed by the ApRES HTTP API. This includes
system/reset
system/housekeeping/config
system/housekeeping/status
- __init__(api_obj)¶
Assign instance of the
APIclassAPIChild should inherently be a child of an
APIobject hence the constructor requires an instance ofAPIto meet this conditions.- Parameters
api_obj (apreshttp.API) – instance of
API
- class ResetMessage(msg, time)¶
Utility class to contain message and time from reset action
- message¶
Reset message, including timestamp.
- time¶
Datetime object representing time of reset
- reset()¶
Reset the ApRES
Requires a valid API key to be assigned to the API object to perform the reset operation.
No guarantee of a reset can be made, but upon successful reception of the request a
apreshttp.System.ResetMessageobject is returned.- Raises
BadResponseException – If the response is malformed or unexpected.
System.Housekeeping class¶
- class apreshttp.System.Housekeeping(api_obj)¶
Housekeeping encapsulates system config and status methods
The Housekeeping object should be a child of the System object and exposes methods to download the configuration file, upload and new configuration file or retrieve the radar system status, packaged in a :py:class:apreshttp.System.Housekeeping` object.
- __init__(api_obj)¶
Assign instance of the
APIclassAPIChild should inherently be a child of an
APIobject hence the constructor requires an instance ofAPIto meet this conditions.- Parameters
api_obj (apreshttp.API) – instance of
API
- class Config(api_obj)¶
Config class facilitates up/download of the system config
The Config class allows for the remote config.ini file to be downloaded onto the local filesystem, or a replacement config file to be uploaded.
NOTE: The ApRES must be restarted before a newly uploaded config.ini file will take effect.
- download(fileLocation=None, overwrite=False)¶
Download ApRES config.ini to the local filesystem
If a directory is specified for the file location then the function will look for an existing config.ini file. If an existing config.ini file exists in that directory then it will be overwritten if the overwrite option is enabled.
If a file is specified for the file location then if it does not exist, it will be created. If it does exist and overwrite is enabled it will be overwritten, otherwise a FilExistsError is raised.
- Parameters
fileLocation (str) – file system path to where the config.ini file should be downloaded
overwrite (boolean) – if the file exists, then overwrite
- Raises
FileExistsError – Raised if the file exists and overwrite is not enabled.
- upload(fileLocation=None)¶
Upload new ApRES config.ini file from the filesystem
If a directory is specified for the file location then the function will look for a config.ini file within that directory. Otherwise, if a file is specified then that is uploaded.
If the file does not exist (or a file named config.ini within the directory) then a FileNotFoundError is raised.
The files are renamed to config.ini by the ApRES radar when they are uploaded.
- Parameters
fileLocation (str) – file system path to where the config.ini file should be uploaded from.
- Raises
FileNotFoundError – Raised if the file at fileLocation, or a “config.ini” file within that directory, is not found.
NoFileUploadedError – Raised if the request was malformed and no file was uploaded.
BadResponseException – The response was malformed or the response was not a HTTP 201 status code.
- class Status(batVoltage, timeGPS, timeVAB, lat, long)¶
Utility class for representing the ApRES system status.
- batteryVoltage¶
Reported ApRES battery voltage (may be 0 if not enabled or connected)
- latitude¶
Reported latitude from GPS
- longitude¶
Reported longitude from GPS
- timeGPS¶
GPS timestamp as a
datetime.datetimeobject, if available.
- timeVAB¶
VAB timestamp as a
datetime.datetimeobject
- status()¶
Request an update on the ApRES battery, tiem, GPS, etc.
Perform a GET request to system/housekeeping/status and wrap the response as a
apreshttp.System.Housekeeping.Statusobject.- Raises
BadResponseException – if the response is malformed or missing information.
- Returns
If valid a
apreshttp.System.Housekeeping.Statusobject is returned