-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from AMONCode/dev
Adding hop-client to master
- Loading branch information
Showing
5 changed files
with
50 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
from amonpy.tools.IC_FPRD import * | ||
from amonpy.tools.angularsep import spcang | ||
from amonpy.tools.config import AMON_CONFIG | ||
from amonpy.tools.postAlerts import postAlertGCN, postAlertHop | ||
|
||
from amonpy.ops.server.celery import app | ||
from amonpy.ops.server.buffer import EventBuffer | ||
|
@@ -576,7 +577,6 @@ def ic_hawc(new_event=None): | |
|
||
f1.write(xmlForm) | ||
f1.close() | ||
MOVEFILE=True | ||
|
||
content = 'Times: ' | ||
print(content) | ||
|
@@ -597,43 +597,36 @@ def ic_hawc(new_event=None): | |
emails2=['[email protected]','[email protected]','[email protected]','[email protected]','[email protected]','[email protected]','[email protected]','[email protected]','[email protected]','[email protected]','[email protected]','[email protected]','[email protected]','[email protected]','[email protected]','[email protected]','[email protected]'] | ||
|
||
title='AMON IC-HAWC alert' | ||
# TEMPORAL UNITL GCN IS ON | ||
if far<=4.0: | ||
if far<=365.0 and prodMachine == False: | ||
email_alerts.alert_email_content([new_alert],content,title) | ||
email_alerts.alert_email_content_emails(content2,title,emails2) | ||
slack_message(title+"\n"+content+"\n"+filen,channel,prodMachine,token=token) | ||
slack_message(title+"\n"+content+"\n"+filen,channel,False,token=token) | ||
postAlertHop(filen,channel='amon.test') | ||
|
||
if far<=4.0 and far>0.01: | ||
if far<=4.0 and far>0.1: | ||
print("ID: %d"%new_alert.id) | ||
print("Alert Stream: %s"%inv_alert_streams[new_alert.stream]) | ||
#fname.write(alert_to_voevent(new_alert)) | ||
if (prodMachine == True and send == True): | ||
try: | ||
cmd = ['/home/ubuntu/Software/miniconda3/bin/comet-sendvo','-f',filen] | ||
#cmd.append('--file=' + filen) | ||
# just for dev to prevent sending hese both from dev and pro machine | ||
#print "uncoment this if used on production" | ||
subprocess.check_call(cmd) | ||
#shutil.move(filen, os.path.join(AlertDir,"archive/",fname)) | ||
postAlertGCN(filen) | ||
postAlertHop(filen,channel='amon.nuem') | ||
|
||
except subprocess.CalledProcessError as e: | ||
print("Send alert failed") | ||
logger.error("send_voevent failed") | ||
logger.error("File: {}".format(fname)) | ||
MOVEFILE=False | ||
slack_message(title+" FAILED TO SEND <!channel>\n"+"File: {}\n".format(filen)+content,channel,prodMachine,token=token) | ||
raise e | ||
#else: | ||
#shutil.move(filen, os.path.join(AlertDir,"archive/",fname)) | ||
#else: | ||
email_alerts.alert_email_content_emails(content2,title,emails) | ||
slack_message(title+"\n"+content+"\n"+filen,"test-alerts",False,token=token) | ||
else: | ||
shutil.move(filen, os.path.join(AlertDir,"archive/",fname)) | ||
slack_message(title+" <!channel>\n"+content+"\n"+filen,channel,prodMachine,token=token) | ||
email_alerts.alert_email_content_emails(content2,title,emails2) | ||
elif far<0.1: | ||
email_alerts.alert_email_content_emails(content2,title+" LOWFAR",emails) | ||
slack_message(title+"\n"+content2+"\n"+fname,channel,prodMachine,token=token) | ||
|
||
if MOVEFILE: | ||
slack_message(title+" <!channel>\n"+content2+"\n"+fname,channel,prodMachine,token=token) | ||
#shutil.move(filen, os.path.join(AlertDir,"archive/",fname)) | ||
else: | ||
shutil.move(filen, os.path.join(AlertDir,"archive/",fname)) | ||
|
||
|
||
#alertLine for HAWC | ||
al = AlertLine(new_alert.stream,new_alert.id,new_alert.rev,streams['HAWC-DM'],phEvent[-2],phEvent[-1]) | ||
alertline_lst.append(al) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import subprocess | ||
import shutil | ||
|
||
from hop import stream as hop_publisher | ||
from hop.models import VOEvent | ||
|
||
|
||
def postAlertGCN(filename): | ||
cmd = ['/home/ubuntu/Software/miniconda3/bin/comet-sendvo','-f',filename] | ||
subprocess.check_call(cmd) | ||
|
||
def postAlertHop(filename,channel='amon.test'): | ||
voevent = VOEvent(filename) | ||
with hop_publisher.open("kafka://kafka.scimma.org/{}".format(channel),"w") as s: | ||
s.write(voevent) |