snews_pt.snews_sub

Classes

Subscriber

Class to subscribe ALERT message stream

Functions

make_file(outputfolder)

Get a proper json file name at a given folder

save_message(message, outputfolder[, return_file])

Save messages to a json file.

display(message)

Display the incoming alert message on screen

Module Contents

snews_pt.snews_sub.make_file(outputfolder)[source]

Get a proper json file name at a given folder It applies an increment to the file name at a given folder to avoid overwrite

snews_pt.snews_sub.save_message(message, outputfolder, return_file=False)[source]

Save messages to a json file. :param message: The incoming alert message :type message: dict :param outputfolder: The path where to save the incoming alerts :type outputfolder: str :param return_file: Whether to return file name as a string :type return_file: bool

snews_pt.snews_sub.display(message)[source]

Display the incoming alert message on screen

class snews_pt.snews_sub.Subscriber(env_path=None, firedrill_mode=True)[source]

Class to subscribe ALERT message stream

Parameters:
  • env_path (str) – path for the environment file. Use default settings if not given

  • firedrill_mode (bool) – tell Subscriber to get messages from the firedrill hop broker, defaults to False

alert_topic[source]
connection_test_topic[source]
snews_time[source]
default_output[source]
subscribe(outputfolder=None, auth=True, is_test=False)[source]

Subscribe and listen to a given topic

Parameters:
  • outputfolder (str) – where to save the alert messages, if None, creates a file based on env file

  • auth (A bool or Auth instance. Defaults to) – loading from auth.load_auth if set to True. To disable authentication, set to False.

  • is_test (bool if True overwrites the subscribed topic with CONNECTION_TEST_TOPIC)

subscribe_and_redirect_alert(outputfolder=None, auth=True, _display=True, _return='file', is_test=False)[source]

subscribe generator