| 123456789101112131415161718192021222324 |
- import os
- import subprocess
- import sys
- def run_notify(cmd, domain, status, error=""):
- """Run notification command with stdout/stderr redirected to stderr and timeout protection."""
- if not cmd:
- return
- env = os.environ.copy()
- env["AUTODOMAIN"] = str(domain or "")
- env["AUTODOMAIN_STATUS"] = str(status or "")
- env["AUTODOMAIN_ERROR"] = str(error or "")
- try:
- subprocess.run(
- ["/bin/sh", "-c", cmd],
- env=env,
- stdout=sys.stderr,
- stderr=sys.stderr,
- timeout=15,
- check=False,
- )
- except Exception as exc:
- print(f"WARN: notify command execution failed: {exc}", file=sys.stderr)
|