From 3d4d81beb114bceeff186a3fc172db0c4116240f Mon Sep 17 00:00:00 2001 From: Mike McCann Date: Mon, 13 Apr 2026 13:50:32 -0700 Subject: [PATCH 1/4] Use -v without an option and have it default to 1. --- src/data/lrauv_deployment_plots.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data/lrauv_deployment_plots.py b/src/data/lrauv_deployment_plots.py index f1f6d96..9bac9db 100755 --- a/src/data/lrauv_deployment_plots.py +++ b/src/data/lrauv_deployment_plots.py @@ -742,6 +742,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)", From e1220cc8a676c0d4b3a1ea480a548daea6a71ba9 Mon Sep 17 00:00:00 2001 From: Mike McCann Date: Mon, 13 Apr 2026 14:29:20 -0700 Subject: [PATCH 2/4] Use SMTP_HOST from .env for internal email relay. --- .env.example | 4 ++++ src/data/lrauv_deployment_plots.py | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index e5aa97a..f06282e 100644 --- a/.env.example +++ b/.env.example @@ -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 diff --git a/src/data/lrauv_deployment_plots.py b/src/data/lrauv_deployment_plots.py index 9bac9db..d0cb9e3 100755 --- a/src/data/lrauv_deployment_plots.py +++ b/src/data/lrauv_deployment_plots.py @@ -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: @@ -428,7 +430,10 @@ def _notify( msg["To"] = resolved msg.set_content(body) 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 From 28c25d0bf6326ce0ab195d8b1978f38ca8afdaa1 Mon Sep 17 00:00:00 2001 From: Mike McCann Date: Mon, 13 Apr 2026 14:38:34 -0700 Subject: [PATCH 3/4] Attach .html files to the email message. --- src/data/lrauv_deployment_plots.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/data/lrauv_deployment_plots.py b/src/data/lrauv_deployment_plots.py index d0cb9e3..8d817d1 100755 --- a/src/data/lrauv_deployment_plots.py +++ b/src/data/lrauv_deployment_plots.py @@ -429,6 +429,14 @@ 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"), + maintype="text", + subtype="html", + filename=p.name, + ) try: smtp_host = os.environ.get(ENV_SMTP_HOST, "localhost") smtp_port = int(os.environ.get(ENV_SMTP_PORT, "587")) From a01ca92a58c09a2f48d2dc4101f1cd4a101b8257 Mon Sep 17 00:00:00 2001 From: Mike McCann Date: Mon, 13 Apr 2026 14:46:12 -0700 Subject: [PATCH 4/4] Remove ' maintype="text",' from add_attachement() so that tests pass. --- src/data/lrauv_deployment_plots.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/data/lrauv_deployment_plots.py b/src/data/lrauv_deployment_plots.py index 8d817d1..2e5b952 100755 --- a/src/data/lrauv_deployment_plots.py +++ b/src/data/lrauv_deployment_plots.py @@ -433,7 +433,6 @@ def _notify( if p.exists(): msg.add_attachment( p.read_text(encoding="utf-8"), - maintype="text", subtype="html", filename=p.name, )