Skip to content

Commit 5c3eaf8

Browse files
committed
Log command to be executed to stderr
1 parent a3460a8 commit 5c3eaf8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

systemd_gpio.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
import os
66
import shlex
77
import signal
8+
import sys
9+
10+
11+
def run(message, args):
12+
print(message, file=sys.stderr)
13+
os.spawnvp(os.P_NOWAIT, args[0], args)
814

915

1016
@click.command(context_settings=dict(auto_envvar_prefix="GPIO"))
@@ -39,7 +45,7 @@ def main(**kwargs):
3945
button = gpiozero.Button(**kwargs)
4046
for key, command in handlers.items():
4147
if command and (args := shlex.split(command)):
42-
handler = functools.partial(os.spawnvp, os.P_NOWAIT, args[0], args)
48+
handler = functools.partial(run, f"{key}: {command}", args)
4349
setattr(button, key, handler)
4450
signal.pause()
4551

0 commit comments

Comments
 (0)