aurorawatchuk¶
-
class
aurorawatchuk.AuroraWatchUK(base_url='http://aurorawatch-api.lancs.ac.uk/0.2/', lang='en', raise_=True, unknown_status_color='#777777', preemptive=False)¶ Class from which the current and recent AuroraWatch UK status, activity and descriptions can be obtained.
The
AuroraWatchUKclass handles all network traffic with the AuroraWatch UK web service and automatically updates as information fetched expires. For time-critical applications where network delays are undesirable (for example thecameraloggermodule) preemptive updates can be requested; if enabled a background thread will initiate an update shortly before the expiry time is reached.Be aware that updates can occur at any time, and may occur between calls for related information. Consider using the snapshot version of this class,
snapshot.AuroraWatchUK_SSwhich also features lazy evaluation and will make network calls only if required.When the object is constructed
base_urlmay be used to adjust the base URL of the AuroraWatch UK API, for instance to select between HTTP and HTTPS transport. The language used for descriptions, messages etc. can be selected with thelangparameter; onlylang='en'is supported at present.By default exceptions are raised when the status, activity or descriptions cannot be fetched from AuroraWatch UK. In some limited cases unknown values can be returned instead of exceptions (primarily when such information may be included in formatted strings). Call the constructor with
raise_=Falseto avoid exceptions, note the trailing underscore to avoid collision with theraisekeyword. When the status is unknown the value retrieved fromstatus_colorreturned can be set with theunknown_status_colorkeyword.-
activity¶ The current activity object. Type
Activity.If the current activity cannot be obtained accessing this property will generate an exception, regardless of the constructor parameter
raise_.
-
descriptions¶ Descriptions and meanings used in the AuroraWatch UK API. Type
collections.OrderedDict.If the current activity cannot be obtained accessing this property will generate an exception, regardless of the constructor parameter
raise_.
-
status¶ Retrieves the current status object. Type
Status.If the current status cannot be obtained accessing this property will generate an exception, regardless of the constructor parameter
raise_.
-
status_color¶ Retrieves the current status color as a RGB string. Type
str.If the
AuroraWatchUKobject was created withraise_=Truethen accessing this property will generate an exception if the current status cannot be obtained. However if it was created withraise_=Falsethenunknown_status_colorwill be returned if the current status cannot be determined.
-
status_description¶ Retrieves the description for the current alert status. Type
str.If the
AuroraWatchUKobject was created withraise_=Truethen accessing this property will generate an exception if the current description cannot be obtained. However if it was created withraise_=Falsethen'Unknown'will be returned.Status descriptions are not terminated with a full stop.
-
status_level¶ Retrieves the current status level. Type
str.- If the
AuroraWatchUKobject was created withraise=Truethen accessing this property will - generate an exception if the current status cannot be obtained. However if it was created with
raise_=Falsethen the status level will be returned as unknown if the current status cannot be determined.
- If the
-
status_meaning¶ The meaning of the current alert status. Type
str.If the
AuroraWatchUKobject was created withraise_=Truethen accessing this property will generate an exception if the current description cannot be obtained. However if it was created withraise_=Falsethen'Unknown.'will be returned.The status meanings are terminated with a full stop.
-
-
class
aurorawatchuk.snapshot.AuroraWatchUK_SS(*args, **kwargs)¶ Take a snapshot of the AuroraWatch UK status.
This class mimics the behaviour of the
aurorawatchuk.AuroraWatchUKclass but its fields are evaluated just once and cached, at the time first requested. Thus the values it returns are snapshots of thestatus,activityanddescriptionfields. This is useful when the information may be required multiple times as it avoids the possibility that the value could change between uses. If the information is not required then no network traffic is generated.For documentation see
aurorawatchuk.AuroraWatchUK.
-
class
aurorawatchuk.Activity(expires, thresholds, updated, activity_values, messages)¶ Current and recent AuroraWatch UK activity values.
If only a minimal set of information is required (current status level and messages) then the
Statusclass should be preferred over this class as the network transfers are smaller.-
all¶ Retrieves all activity values. Type
listofActivityValueobjects.
-
latest¶ Retrieves the latest activity value available. Type
ActivityValue.
-
messages¶ Retrieves a list of currently active messages. Type
MessageorNone.The list of messages may be empty.
-
thresholds¶ Retrieves the lower thresholds for each activity level. Type
collections.OrderedDict.The lower thresholds are given in units of nanotesla (nT). The activity must equal or exceed the lower threshold, and not equal or exceed the lower threshold of the next status level.
-
updated¶ Retrieves the time the status was last updated. Type
datetime.datetime.
-
-
class
aurorawatchuk.ActivityValue(level, datetime, value)¶ A single AuroraWatch UK activity value.
-
datetime¶ Retrieves the start time for the hourly activity value. Type
datetime.datetime.
-
-
class
aurorawatchuk.Message(id_, priority, description, url, expires)¶ An AuroraWatch UK message.
-
expires¶ Retrieves the date and time the message expires. Type
datetime.datetime.After the expiry time the message should not be displayed and any saved references (for instance recording that the message has been shown to the user) can be discarded.
-
id¶ Retrieves a unique identifier for the message. Type
str.The identifier can be used to record which messages have been presented to a user and to hide any which have been seen previously.
-
priority¶ Retrieves the priority level for a message. Type
str.The priority indicates what action, if any, may be appropriate. A
'high'priority suggests that an alerting notification may be appropriate while a'low'priority suggests a silent notification may be more appropriate. Test messages are indicated with the priority'test'. Messages with unknown priorities should be ignored.
-
-
class
aurorawatchuk.Status(expires, level, updated, messages)¶ AuroraWatch UK current status.
If only a minimal set of information is required (status level and messages) this class should be preferred over the
Activityclass as the network transfers are smaller.-
messages¶ Retrieves a list of currently active messages. Type
MessageorNone.The list of messages may be empty.
-
updated¶ Retrieves the time status was last updated. Type
datetime.datetime.
-