From 793ca0ade42f6293cab105b52c0911a18e0dd797 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Fri, 1 Mar 2019 17:06:42 +1100 Subject: [PATCH] Don't raise errors if log file is missing --- waternsw_grabber/waternsw_grabber.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/waternsw_grabber/waternsw_grabber.py b/waternsw_grabber/waternsw_grabber.py index 8f73f2d..c980b7f 100644 --- a/waternsw_grabber/waternsw_grabber.py +++ b/waternsw_grabber/waternsw_grabber.py @@ -229,17 +229,20 @@ def telemetered_bore_downloader(bore_ids, start_date, end_date, download_dir): # Stop logging logging.shutdown() - with open(log_name, 'r') as f: - log_data = f.read() - - # Check contents of log file - if log_data: - warnings.warn( - 'Some files failed to download. See log for details.', - stacklevel=2) - else: - os.remove(log_name) + if os.path.isfile(log_name) + with open(log_name, 'r') as f: + log_data = f.read() + + # Check contents of log file + if log_data: + warnings.warn( + 'Some files failed to download. See log for details.', + stacklevel=2) + else: + os.remove(log_name) + + # Close browser driver.quit()