Handle errors for sites with no data

master
Dan Howe 6 years ago
parent c081c9f69d
commit 53345e3787

@ -89,8 +89,10 @@ def get_telemetered_bore(driver, bore_id, start_date, end_date):
time.sleep(0.5) time.sleep(0.5)
# Detect if bore record does not exist # Detect if bore record does not exist
if body_text.startswith('No SITE record found for site'): if 'No SITE record found for site' in body_text:
raise ValueError('No SITE record found for site {}'.format(bore_id)) raise ValueError('No SITE record found for site {}'.format(bore_id))
elif 'No variables data found for this site.' in body_text:
raise ValueError('No variables data found for site {}'.format(bore_id))
# Wait for navigation tabs # Wait for navigation tabs
wait_for_element(driver, By.XPATH, '//*[@id="tabstext"]') wait_for_element(driver, By.XPATH, '//*[@id="tabstext"]')
@ -212,8 +214,8 @@ def telemetered_bore_downloader(bore_ids, start_date, end_date, download_dir):
pbar.set_description(bore_id) pbar.set_description(bore_id)
try: try:
get_telemetered_bore(driver, bore_id, start_date, end_date) get_telemetered_bore(driver, bore_id, start_date, end_date)
except ValueError: except ValueError as e:
logging.error('Failed to download {}\n'.format(bore_id)) logging.error(e)
# Tidy up console after tqdm # Tidy up console after tqdm
print('\n') print('\n')

Loading…
Cancel
Save