From 1019c6ae00cedb2db4b59063aae4d23cfa1e8044 Mon Sep 17 00:00:00 2001 From: Alexander Cecile <35971201+AlexanderCecile@users.noreply.github.com> Date: Thu, 27 Aug 2020 21:37:54 -0400 Subject: [PATCH] Improve the error raised when the new dependency is missing --- updateHostsFile.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/updateHostsFile.py b/updateHostsFile.py index 60fd80d7a..2c50b4c37 100644 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -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"]