"""Small dependency-free systemd notification helper.""" import os import socket def notify(message): address = os.environ.get("NOTIFY_SOCKET") if not address: return if address.startswith("@"): address = "\0" + address[1:] with socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) as sock: sock.connect(address) sock.sendall(message.encode())