SNEWS2 / SNEWS_Publishing_Tools

Publishing Tool for SNEWS
BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

Plug in scripts #34

Closed KaraMelih closed 2 years ago

KaraMelih commented 2 years ago

This PR adds the functionality to use a script as a plug in; any script that contains the following lines can be plugged in;

import sys, json
saved_json = sys.argv[1]
this_plugin = sys.argv[0]
data = json.load(open(saved_json))

There is a simple example that can be used to test; user can run the following To start coincidence system,

The snews_pt subscribe command subscribes to the alert topic, and saves the data as soon as it comes, and the -p (--plugin) option in the passes the path of this content to the given script. The first lines in the custom made plug-ins allows to read.

Since these plugins are called anytime there is a new alert, there is no time loss.

Storreslara commented 2 years ago

On the README can you add the python code needed to run the plug in

KaraMelih commented 2 years ago

Thanks for noticing! I added those, and also updated the subscription section. Now, we allow for defining the output directory. By default, it is fetched from the env file