Skip to content

Commit

Permalink
Email improvements
Browse files Browse the repository at this point in the history
Relates to #6
  • Loading branch information
eddienko committed Sep 24, 2021
1 parent 0cf2300 commit 6bc79d2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions owl_server/daemon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

import aiosmtplib

email_txt = """
Your pipeline {jobid} has finished with status: {status}.
{result}
"""


def safe_loop():
"""Run coroutine in a safe loop.
Expand Down Expand Up @@ -72,9 +78,6 @@ def slurm_configure(info, **kwargs):


async def send_email(config, pipeline):
import sys

print(">>>>>>>>>>>>>>", config, pipeline["userinfo"], file=sys.stderr)
if not config["enabled"]:
return

Expand All @@ -89,11 +92,12 @@ async def send_email(config, pipeline):

jobid = pipeline["uid"]
status = pipeline["status"]
result = pipeline.get("heartbeat", {}).get("result", "")

message = EmailMessage()
message["From"] = config.get("from_address", "owl@localhost")
message["To"] = to_address
message["Subject"] = f"Pipeline {jobid}: {status}"
message.set_content("Sent via aiosmtplib")
message.set_content(email_txt.format(jobid=jobid, status=status, result=result))

await aiosmtplib.send(message, hostname=config["host"], port=config["port"])

0 comments on commit 6bc79d2

Please sign in to comment.