MCPcopy Index your code
hub / github.com/sshuttle/sshuttle / _notify

Function _notify

sshuttle/sdnotify.py:17–41  ·  view source on GitHub ↗

Send a notification message to systemd.

(message)

Source from the content-addressed store, hash-verified

15
16
17def _notify(message):
18 """Send a notification message to systemd."""
19 addr = os.environ.get("NOTIFY_SOCKET", None)
20
21 if not addr or len(addr) == 1 or addr[0] not in ('/', '@'):
22 return False
23
24 addr = '\0' + addr[1:] if addr[0] == '@' else addr
25
26 try:
27 sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
28 except (OSError, IOError) as e:
29 debug1("Error creating socket to notify systemd: %s" % e)
30 return False
31
32 if not message:
33 return False
34
35 assert isinstance(message, bytes)
36
37 try:
38 return (sock.sendto(message, addr) > 0)
39 except (OSError, IOError) as e:
40 debug1("Error notifying systemd: %s" % e)
41 return False
42
43
44def send(*messages):

Callers 1

sendFunction · 0.85

Calls 2

debug1Function · 0.90
getMethod · 0.80

Tested by

no test coverage detected