Kill geckodriver when finished

hightide
Dan Howe 5 years ago
parent a417c3f7d5
commit 58e4e5a6f7

@ -1,9 +1,11 @@
#!/home/cronbot/anaconda3/bin/python
"""spectur_live_view
Open an automated selenium webdriver, and download images from Live View mode.
"""
import os
import sys
import glob
import time
import pytz
@ -26,7 +28,7 @@ URL = 'https://camera.uwatchit.com.au/UWatchitWebV2/User/LiveView#'
OUTPUT_DIR = 'images'
TIMEZONE = 'Australia/Sydney'
WAIT_TIME = 0.1
RECORDING_DURATION = 120
RECORDING_DURATION = 5
SILENT = True
IMAGE_MASK = 'mask/overtopping-mask.png'
username = ''
@ -41,7 +43,8 @@ height = next_high_tide.rsplit('_', 1)[-1]
now = datetime.now()
year = now.strftime('%Y')
timestamp = now.strftime('%Y-%m-%d_%H-%M')
current_hightide_dir = os.path.join(pwd, OUTPUT_DIR, year, f'{timestamp}_{height}')
current_hightide_dir = os.path.join(pwd, OUTPUT_DIR, year,
f'{timestamp}_{height}')
def start_session():
@ -54,7 +57,8 @@ def start_session():
options = Options()
options.headless = True
executable_path = os.path.join(pwd, 'geckodriver')
driver = webdriver.Firefox(executable_path=executable_path, options=options)
driver = webdriver.Firefox(executable_path=executable_path,
options=options)
return driver
@ -257,10 +261,12 @@ def get_brightness(jpg_name, mask):
# Create counter
t = []
# Open browser
get_images()
# Force browser process to end (bug with selenium)
subprocess.run(['killall', 'firefox'])
# Create video
create_video()

Loading…
Cancel
Save