Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ WORK_VOL=/opt/docker_auv-python_vols/data
HOST_NAME=example.shore.mbari.org
GMT_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/

# SMTP relay host and port for email notifications (STARTTLS)
SMTP_HOST=localhost
SMTP_PORT=587

# SSDS API endpoint (set to your dev server as needed)
SSDS_API_BASE=https://mooring-ssds.shore.mbari.org/api

Expand Down
16 changes: 15 additions & 1 deletion src/data/lrauv_deployment_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
from resample import FREQ, LRAUV_OPENDAP_BASE

ENV_LRAUV_NOTIFY = "LRAUV_NOTIFY"
ENV_SMTP_HOST = "SMTP_HOST"
ENV_SMTP_PORT = "SMTP_PORT"


class DeploymentPlotter:
Expand Down Expand Up @@ -427,8 +429,18 @@ def _notify(
msg["From"] = "auv-python@mbari.org"
msg["To"] = resolved
msg.set_content(body)
for p in html_paths:
if p.exists():
msg.add_attachment(
p.read_text(encoding="utf-8"),
subtype="html",
filename=p.name,
)
try:
with smtplib.SMTP("localhost") as s:
smtp_host = os.environ.get(ENV_SMTP_HOST, "localhost")
smtp_port = int(os.environ.get(ENV_SMTP_PORT, "587"))
with smtplib.SMTP(smtp_host, smtp_port) as s:
s.starttls()
s.send_message(msg)
self.logger.info("Email notification sent to %s", resolved)
except Exception as exc: # noqa: BLE001
Expand Down Expand Up @@ -742,6 +754,8 @@ def process_command_line(self) -> None:
"-v",
"--verbose",
type=int,
nargs="?",
const=1,
default=0,
choices=[0, 1, 2],
help="Verbosity level (0=warn, 1=info, 2=debug)",
Expand Down
Loading