Improve the error raised when the new dependency is missing
authorAlexander Cecile <redacted>
Fri, 28 Aug 2020 01:37:54 +0000 (21:37 -0400)
committerAlexander Cecile <redacted>
Fri, 28 Aug 2020 04:17:50 +0000 (00:17 -0400)
updateHostsFile.py

index 60fd80d7a2a9d697f7e22ed835f4ae8eb52770c2..2c50b4c370742cb53c131607d0d096672b58e24b 100644 (file)
@@ -21,14 +21,20 @@ import tempfile
 import time
 from glob import glob
 
-import requests
-
 # Detecting Python 3 for version-dependent implementations
 PY3 = sys.version_info >= (3, 0)
 
 if not PY3:
     raise Exception("We do not support Python 2 anymore.")
 
+
+try:
+    import requests
+except ModuleNotFoundError:  # noqa: F821
+    raise ModuleNotFoundError("This project's dependencies have changed. The Requests library ("  # noqa: F821
+                              "https://requests.readthedocs.io/en/master/) is now required.")
+
+
 # Syntactic sugar for "sudo" command in UNIX / Linux
 if platform.system() == "OpenBSD":
     SUDO = ["/usr/bin/doas"]
git clone https://git.99rst.org/PROJECT