Use StopIteration instead of sys.exit() to end image capture

hightide
Dan Howe 5 years ago
parent a65de58d14
commit b4867a2629

@ -4,7 +4,6 @@ Open an automated selenium webdriver, and download images from Live View mode.
""" """
import os import os
import sys
import glob import glob
import time import time
import pytz import pytz
@ -175,7 +174,7 @@ def get_next_image(driver, cookies):
# Check if recording has completed # Check if recording has completed
if t[-1] - t[0] > RECORDING_DURATION: if t[-1] - t[0] > RECORDING_DURATION:
sys.exit() raise(StopIteration)
# Count images collected # Count images collected
n = len(t) n = len(t)
@ -211,6 +210,9 @@ def main():
# Attempt to re-login if server goes down # Attempt to re-login if server goes down
time.sleep(5) time.sleep(5)
cookies = login(driver) cookies = login(driver)
except StopIteration:
# Stop when recording has completed
break
# Create counter # Create counter

Loading…
Cancel
Save