Skip to content

Commit 8fec088

Browse files
committed
posts slack message when injections are detected
1 parent 899b710 commit 8fec088

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

T2/cluster_heimdall.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@
3131

3232
from event import names # TODO: add event to get DSAEvent class
3333

34+
35+
# set up slack client
36+
slack_file = '{0}/.config/slack_api'.format(os.path.expanduser("~"))
37+
if not os.path.exists(slack_file):
38+
raise RuntimeError("Could not find file with slack api token at {0}".format(slack_file))
39+
with open(slack_file) as sf_handler:
40+
slack_token = sf_handler.read()
41+
slack_client = slack.WebClient(token=slack_token)
42+
3443
# half second at heimdall time resolution (after march 18)
3544
offset = 1907
3645
downsample = 4
@@ -676,6 +685,7 @@ def send_trigger(output_dict=None, outputfile=None):
676685
) # tells look_after_dumps.py to manage data
677686
else:
678687
print(f"Candidate {candname} was detected as an injection. Not triggering voltage recording.")
688+
slack_client.chat_postMessage(channel='candidates', text=f'Injection detected as {candname} with DM={val["dm"]} and SNR={val["snr"]}.')
679689

680690

681691
def dump_cluster_results_heimdall(

0 commit comments

Comments
 (0)