From 81c30977d50883da3d91b82b9ce32f9bf9d005b9 Mon Sep 17 00:00:00 2001 From: Wansen Dong Date: Thu, 23 Apr 2020 20:43:38 +1000 Subject: [PATCH] Create urllib3.py --- urllib3.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 urllib3.py diff --git a/urllib3.py b/urllib3.py new file mode 100644 index 0000000..27026e6 --- /dev/null +++ b/urllib3.py @@ -0,0 +1,22 @@ +try: + import wget +execept: + import os + result = os.system("pip install wget") + try: + import wget + except ModuleNotFoundError: + if result == 0: + raise ImportError("Pip succeded, but wget was not found. Check PATH") + raise ImportError("Pip failed, unable to install wget") + except ImportError: + print("Unknown error whilst trying to import wget, pip code is %s"%result) + try: + download=wget.download + except Exception: + print("wget can't download, pip code is %s"%result) + raise ImportError("wget cannot download, perhaps you have another file wget.py?") + if result != 0: + print("Strange behaviour detected, pip failed but wget was imported correctly.") + def get(link): + wget.download(link)