From 8914c8b06b03d654fdb9e2a5a5d719df6a290aad Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Fri, 22 Feb 2019 15:05:23 +1100 Subject: [PATCH] Move TimeoutException handler to telemetered_bore_downloader() function --- waternsw_grabber/waternsw_grabber.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/waternsw_grabber/waternsw_grabber.py b/waternsw_grabber/waternsw_grabber.py index ac4fb44..fd0742a 100644 --- a/waternsw_grabber/waternsw_grabber.py +++ b/waternsw_grabber/waternsw_grabber.py @@ -51,12 +51,8 @@ def wait_for_element(driver, by, x, timeout=180): Raises TimeoutException if element does not load within timeout period """ - try: - element_present = EC.presence_of_element_located((by, x)) - WebDriverWait(driver, timeout).until(element_present) - except TimeoutError: - raise TimeoutError( - 'Request timed out on {}. Try again later?'.format(bore_id)) + element_present = EC.presence_of_element_located((by, x)) + WebDriverWait(driver, timeout).until(element_present) def get_telemetered_bore(driver, bore_id, start_date, end_date): @@ -221,7 +217,10 @@ def telemetered_bore_downloader(bore_ids, start_date, end_date, download_dir): pbar.set_description(bore_id) try: get_telemetered_bore(driver, bore_id, start_date, end_date) - except (ValueError, TimeoutError) as e: + except ValueError as e: + logging.error(e) + except TimeoutException: + e = 'Request timed out on {}. Try again later?'.format(bore_id) logging.error(e) # Tidy up console after tqdm