fixed cleanup script

This commit is contained in:
Devaev Maxim
2018-07-03 01:12:53 +03:00
parent 9bd99aa223
commit 3466da9467

View File

@@ -15,15 +15,17 @@ def main() -> None:
logger.info("Cleaning up ...") logger.info("Cleaning up ...")
with gpio.bcm(): with gpio.bcm():
for (key, pin) in [ for (name, pin) in [
*config["atx"]["switches"]["pinout"].items(), ("atx_power_switch", config["atx"]["pinout"]["power_switch"]),
*config["video"]["pinout"].items(), ("atx_reset_switch", config["atx"]["pinout"]["reset_switch"]),
("streamer_cap", config["streamer"]["pinout"]["cap"]),
("streamer_conv", config["streamer"]["pinout"]["conv"]),
]: ]:
if pin > 0: if pin > 0:
logger.info("Writing value=0 to pin=%d (%s)", pin, key) logger.info("Writing value=0 to pin=%d (%s)", pin, name)
gpio.set_output(pin, initial=False) gpio.set_output(pin, initial=False)
streamer = os.path.basename(config["video"]["cmd"][0]) streamer = os.path.basename(config["streamer"]["cmd"][0])
logger.info("Trying to find and kill %r ...", streamer) logger.info("Trying to find and kill %r ...", streamer)
try: try:
subprocess.check_output(["killall", streamer], stderr=subprocess.STDOUT) subprocess.check_output(["killall", streamer], stderr=subprocess.STDOUT)