From ecb8c1f8156049ba38c0a73300ef63a7cdf30c3c Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 10 Mar 2021 17:47:04 -0700 Subject: [PATCH] Detect when the system isn't connected --- server/main.py | 17 ++++++++++++----- server/settings.py | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/server/main.py b/server/main.py index 68913bf..38aa551 100644 --- a/server/main.py +++ b/server/main.py @@ -99,11 +99,18 @@ def session_post(cid): # go through the photo taking process status = 'Warming up' - # warmup - power.lights_on() - time.sleep(4) - power.lights_off() - time.sleep(0.5) + try: + # warmup + power.lights_on() + time.sleep(4) + power.lights_off() + time.sleep(0.5) + except BaseException as e: + print('Problem with lights: {} - {}'.format(e.__class__.__name__, str(e))) + print() + print('Are you sure the system is connected?') + print() + abort(500) status = 'Capturing' diff --git a/server/settings.py b/server/settings.py index 3372a69..fa558fc 100644 --- a/server/settings.py +++ b/server/settings.py @@ -1,5 +1,5 @@ import os -DEBUG = os.environ['FLASK_ENV'] == 'development' +DEBUG = os.environ.get('FLASK_ENV', None) == 'development' LIGHT_IP = '192.168.99.25' LIGHT_USER = 'admin'