From c5da9d59181eca2bf6a9f9882d4e6e651789076d Mon Sep 17 00:00:00 2001 From: Craig Date: Sun, 5 Jan 2020 19:45:45 +0000 Subject: [PATCH] add keyboard interrup exception. --- cli_meter.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cli_meter.py b/cli_meter.py index aa185ae..b967760 100644 --- a/cli_meter.py +++ b/cli_meter.py @@ -77,11 +77,13 @@ def main(): while True: #pdb.set_trace() update_reading() + except KeyboardInterrupt: + print("Keyboard Interrupt: quitting program.") except: - print("Error updating light reading.") + print("Error updating light reading...") finally: - print("clean up") - GPIO.cleanup() # cleanup all GPIO + print("Cleaning up GPIO before closing...") + GPIO.cleanup() if __name__ == "__main__": main()