Skip to content

Commit

Permalink
Check the env var is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienPeloton committed May 27, 2024
1 parent a7ee90e commit bd9a045
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions fink_filters/filter_early_kn_candidates/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def early_kn_candidates(
the message has not been sent to Slack
"""
for url_name in ['KNWEBHOOK', 'KNWEBHOOK_FINK']:
if (url_name in os.environ):
if (url_name in os.environ) and os.environ[url_name] != '':
requests.post(
os.environ[url_name],
json={
Expand All @@ -421,7 +421,7 @@ def early_kn_candidates(
log.warning(error_message.format(url_name))

# Grandma amateur channel
ama_in_env = ('KNWEBHOOK_AMA_GALAXIES' in os.environ)
ama_in_env = ('KNWEBHOOK_AMA_GALAXIES' in os.environ) and os.environ['KNWEBHOOK_AMA_GALAXIES'] != ''

# Send alerts to amateurs only on Friday
now = datetime.datetime.utcnow()
Expand All @@ -444,7 +444,7 @@ def early_kn_candidates(

# DWF channel and requirements
dwf_ztf_fields = [1525, 530, 482, 1476, 388, 1433]
dwf_in_env = ('KNWEBHOOK_DWF' in os.environ)
dwf_in_env = ('KNWEBHOOK_DWF' in os.environ) and (os.environ['KNWEBHOOK_DWF'] != '')
if (int(field[i]) in dwf_ztf_fields) and dwf_in_env:
requests.post(
os.environ['KNWEBHOOK_DWF'],
Expand Down
2 changes: 1 addition & 1 deletion fink_filters/filter_early_sn_candidates/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def early_sn_candidates(
)

# Loop over matches
if "FINK_TG_TOKEN" in os.environ:
if ("FINK_TG_TOKEN" in os.environ) and os.environ["FINK_TG_TOKEN"] != "":
payloads = []
for _, alert in pdf[series.values].iterrows():
curve_png = get_curve(
Expand Down
4 changes: 2 additions & 2 deletions fink_filters/filter_kn_candidates/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def kn_candidates(
the message has not been sent to Slack
"""
for url_name in ['KNWEBHOOK', 'KNWEBHOOK_FINK']:
if (url_name in os.environ):
if (url_name in os.environ) and (os.environ[url_name] != ""):
requests.post(
os.environ[url_name],
json={
Expand All @@ -337,7 +337,7 @@ def kn_candidates(
log = logging.Logger('Kilonova filter')
log.warning(error_message.format(url_name))

ama_in_env = ('KNWEBHOOK_AMA_CL' in os.environ)
ama_in_env = ('KNWEBHOOK_AMA_CL' in os.environ) and (os.environ["KNWEBHOOK_AMA_CL"])

# Send alerts to amateurs only on Friday
now = datetime.datetime.utcnow()
Expand Down
2 changes: 1 addition & 1 deletion fink_filters/filter_yso_spicy_candidates/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def yso_spicy_candidates(
)

# Loop over matches
if "FINK_TG_TOKEN" in os.environ:
if ("FINK_TG_TOKEN" in os.environ) and os.environ["FINK_TG_TOKEN"] != "":
payloads = []
for _, alert in pdf[mask].iterrows():
curve_png = get_curve(
Expand Down

0 comments on commit bd9a045

Please sign in to comment.