Mercury2 Hardware Manager  1.0dev
The hardware manager component of the Mercury2 ground station suite.
 All Classes Namespaces Functions Variables Pages
hwm.sessions.schedule.ScheduleManager Class Reference

Represents a reservation access schedule. More...

Public Member Functions

def __init__
 Initializes the schedule instance. More...
 
def update_schedule
 Downloads the most recent version of the schedule from the active source. More...
 
def get_active_reservations
 Returns a list of the currently active reservations (by timestamp). More...
 

Public Attributes

 config
 
 use_network_schedule
 
 schedule_location
 
 schedule
 
 last_updated
 

Private Member Functions

def _validate_schedule
 Validates the newly loaded schedule JSON. More...
 
def _save_schedule
 Saves the provided schedule to this schedule instance. More...
 
def _download_remote_schedule
 Loads the schedule from the schedule's URL. More...
 
def _download_local_schedule
 Loads the schedule from the local disk. More...
 

Detailed Description

Represents a reservation access schedule.

This class provides access to a copy of the reservation schedule. That hardware manager can use ScheduleManager to:

  • Download new copies of the reservation schedule from the user interface
  • Query for specific reservations
  • Access newly active reservations

Constructor & Destructor Documentation

def hwm.sessions.schedule.ScheduleManager.__init__ (   self,
  schedule_endpoint 
)

Initializes the schedule instance.

Parameters
schedule_endpointWhere to load the reservation schedule from. This can either be a local file or a network address (such as the mercury2 user interface API). If it begins with 'http', it will be treated as a network address.

Member Function Documentation

def hwm.sessions.schedule.ScheduleManager._download_local_schedule (   self)
private

Loads the schedule from the local disk.

 This method loads the local schedule from the disk and returns it.
Exceptions
ThrowsScheduleError if an error occurs while loading or parsing the schedule.
Note
The schedule file is passed to the constructor and specified by self.schedule_location.
This method is intended to be called with threads.deferToThread. The returned schedule will be passed to the resulting deferred's callback chain.
Returns
Returns a python object representing the schedule if successful.
def hwm.sessions.schedule.ScheduleManager._download_remote_schedule (   self)
private

Loads the schedule from the schedule's URL.

 This method loads the the schedule from a URL (e.g. the mercury2 user interface) and returns it.
Exceptions
ThrowsScheduleError if an error occurs while downloading or parsing the schedule.
Note
This method is intended to be called with threads.deferToThread. The returned schedule will be passed to the resulting deferred's callback chain.
Returns
Returns a python object representing the downloaded schedule.
def hwm.sessions.schedule.ScheduleManager._save_schedule (   self,
  schedule_load_result 
)
private

Saves the provided schedule to this schedule instance.

Note
This method is intended to be used as a callback for the deferred returned by the various schedule download methods.
Parameters
schedule_load_resultThe result of the attempted schedule download.
Returns
Returns a python object representing the new schedule. Note this returned schedule represents the raw JSON object before any filters or modifications have been applied.
def hwm.sessions.schedule.ScheduleManager._validate_schedule (   self,
  schedule_load_result 
)
private

Validates the newly loaded schedule JSON.

 This callback validates the format of the new schedule against the JSON schedule schema.
Exceptions
ThrowsScheduleError if the schedule represented by schedule_load_result isn't valid.
Parameters
schedule_load_resultThe result of the attempted schedule download. Returns a python object representing the new schedule.
def hwm.sessions.schedule.ScheduleManager.get_active_reservations (   self)

Returns a list of the currently active reservations (by timestamp).

Note
This method will return all active reservations whether or not the session coordinator is already responding to them. It is the responsibility of the coordinator to handle duplicates.
Returns
Returns a list of the reservations that are currently active. If no reservations are active, an empty list will be returned.
def hwm.sessions.schedule.ScheduleManager.update_schedule (   self)

Downloads the most recent version of the schedule from the active source.

Note
This method loads the schedule from the active source (either a local file or network address) and updates the local copy using callbacks. If use_local_schedule is true, the schedule will be loaded from a local file (specified in the configuration files). If it is false, it will be loaded from the user interface API.
Returns
Returns a deferred that will be called with the result of the file access (the schedule object or a Failure).

The documentation for this class was generated from the following file: