From a31bd52e032b95f793bf3783a142abaab5c66e4e Mon Sep 17 00:00:00 2001 From: j3rome Date: Mon, 28 Jun 2021 11:50:21 -0400 Subject: [PATCH] * Error handling --- utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index 96e4d98..dd299b2 100644 --- a/utils.py +++ b/utils.py @@ -63,8 +63,13 @@ def get_mapping_files_from_pipreqs(tmp_path="/tmp/.py-req-guesser"): mapping_url = "https://raw.githubusercontent.com/bndr/pipreqs/90102acdbb23c09574d27df8bd1f568d34e0cfd3/pipreqs/mapping" stdlib_url = "https://raw.githubusercontent.com/bndr/pipreqs/90102acdbb23c09574d27df8bd1f568d34e0cfd3/pipreqs/stdlib" - urlretrieve(mapping_url, mapping_filepath) - urlretrieve(stdlib_url, stdlib_filepath) + try: + urlretrieve(mapping_url, mapping_filepath) + urlretrieve(stdlib_url, stdlib_filepath) + except: + print("[ERROR] Internet access is required to fetch mapping files from https://github.com/bndr/pipreqs") + exit(1) + from_import_to_package_mapping = {} from_package_to_import_mapping = {}