snews_pt.snews_sub¶
Classes¶
Class to subscribe ALERT message stream |
Functions¶
|
Get a proper json file name at a given folder |
|
Save messages to a json file. |
|
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
- 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
- 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
Authinstance. Defaults to) – loading fromauth.load_authif set to True. To disable authentication, set to False.is_test (bool if True overwrites the subscribed topic with CONNECTION_TEST_TOPIC)