From a61ae3be85eeb000018b69aa2ce8428a79b5b190 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Tue, 21 Aug 2018 07:16:55 +1000 Subject: [PATCH] Show warning if some files failed to download --- major_projects_grabber/major_projects_grabber.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/major_projects_grabber/major_projects_grabber.py b/major_projects_grabber/major_projects_grabber.py index f6c12e0..21e62ef 100644 --- a/major_projects_grabber/major_projects_grabber.py +++ b/major_projects_grabber/major_projects_grabber.py @@ -17,6 +17,7 @@ import shutil import logging import requests import argparse +import warnings from lxml import html from tqdm import tqdm from requests.exceptions import ConnectionError, InvalidURL @@ -206,6 +207,15 @@ def main(): # Tidy up console after tqdm print('\n') + # Check contents of log file + with open(log_name, 'r') as f: + log_data = f.read() + + if log_data: + warnings.warn( + 'Some files failed to download. See log for details.', + stacklevel=2) + if __name__ == '__main__': main()