From 12dab7ee19d4da52d5ea1839643443dbf29ce0c2 Mon Sep 17 00:00:00 2001 From: mandlm Date: Fri, 8 Jan 2016 11:05:49 +0100 Subject: [PATCH] switch all leds off when exiting --- mopidy-switcher/mopidy-switcher.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mopidy-switcher/mopidy-switcher.py b/mopidy-switcher/mopidy-switcher.py index 465ff73..08fbebe 100755 --- a/mopidy-switcher/mopidy-switcher.py +++ b/mopidy-switcher/mopidy-switcher.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python import glob import os @@ -96,7 +96,10 @@ if __name__ == '__main__': setConfiguredLedColor() try: - while True: - GPIO.wait_for_edge(dummyPin, GPIO.RISING) + while True: + GPIO.wait_for_edge(dummyPin, GPIO.RISING) + except KeyboardInterrupt: + print 'exiting' finally: - GPIO.cleanup() + setLeds(0, 0, 0) + GPIO.cleanup()