From db922938cc5e9a8c0b94195305ab249d5d7d6cfc Mon Sep 17 00:00:00 2001 From: Balthasar Reuter Date: Thu, 4 Jun 2015 16:13:58 +0200 Subject: [PATCH] teardown cleaned up --- photobooth.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/photobooth.py b/photobooth.py index 5c41d34..58e9a0f 100755 --- a/photobooth.py +++ b/photobooth.py @@ -382,10 +382,10 @@ def handle_gpio_event(channel): elif channel == gpio_shutdown_channel: display.clear() print("Shutting down!") - display.show_message("Shutting down!") + display.show_message("\n\nShutting down!") display.apply() sleep(1) - os.system("shutdown -h now") + teardown(0, True) def handle_exception(msg): """Displays an error message and returns""" @@ -413,14 +413,15 @@ def setup_gpio(): def handle_gpio(channel): """Interrupt handler for GPIO events""" - print("Channel " + str(channel) + " triggered") display.trigger_event(gpio_pygame_event, channel) -def teardown(exit_code=0): +def teardown(exit_code=0, shutdown=False): display.teardown() if gpio_enabled: GPIO.cleanup() exit(exit_code) + if shutdown: + os.system("shutdown -h now") def main(): setup_gpio() @@ -429,7 +430,7 @@ def main(): display.mainloop(image_idle) except CameraException as e: handle_exception(e.message) - display.teardown() + teardown() return 0 ########################