snews_pt.snews_sub ================== .. py:module:: snews_pt.snews_sub Classes ------- .. autoapisummary:: snews_pt.snews_sub.Subscriber Functions --------- .. autoapisummary:: snews_pt.snews_sub.make_file snews_pt.snews_sub.save_message snews_pt.snews_sub.display Module Contents --------------- .. py:function:: make_file(outputfolder) 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 .. py:function:: save_message(message, outputfolder, return_file=False) 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 .. py:function:: display(message) Display the incoming alert message on screen .. py:class:: Subscriber(env_path=None, firedrill_mode=True) Class to subscribe ALERT message stream :param env_path: path for the environment file. Use default settings if not given :type env_path: str :param firedrill_mode: tell Subscriber to get messages from the firedrill hop broker, defaults to False :type firedrill_mode: bool .. py:attribute:: alert_topic .. py:attribute:: connection_test_topic .. py:attribute:: snews_time .. py:attribute:: default_output .. py:method:: subscribe(outputfolder=None, auth=True, is_test=False) Subscribe and listen to a given topic :param outputfolder: where to save the alert messages, if None, creates a file based on env file :type outputfolder: str :param auth: loading from :meth:`auth.load_auth ` if set to True. To disable authentication, set to False. :type auth: A `bool` or :class:`Auth ` instance. Defaults to :param is_test: :type is_test: bool if True overwrites the subscribed topic with CONNECTION_TEST_TOPIC .. py:method:: subscribe_and_redirect_alert(outputfolder=None, auth=True, _display=True, _return='file', is_test=False) subscribe generator