From b4867a2629f5b79181f8b3b991aa4a69307e6940 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Thu, 28 Nov 2019 13:39:42 +1100 Subject: [PATCH] Use StopIteration instead of sys.exit() to end image capture --- spectur_live_view.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spectur_live_view.py b/spectur_live_view.py index e81812a..caab3ea 100644 --- a/spectur_live_view.py +++ b/spectur_live_view.py @@ -4,7 +4,6 @@ Open an automated selenium webdriver, and download images from Live View mode. """ import os -import sys import glob import time import pytz @@ -175,7 +174,7 @@ def get_next_image(driver, cookies): # Check if recording has completed if t[-1] - t[0] > RECORDING_DURATION: - sys.exit() + raise(StopIteration) # Count images collected n = len(t) @@ -211,6 +210,9 @@ def main(): # Attempt to re-login if server goes down time.sleep(5) cookies = login(driver) + except StopIteration: + # Stop when recording has completed + break # Create counter