diff --git a/update_plugins.py b/update_plugins.py index 47b33c3d..82d23845 100644 --- a/update_plugins.py +++ b/update_plugins.py @@ -2,15 +2,20 @@ try: import concurrent.futures as futures except ImportError: try: - import futures + import futures # type: ignore except ImportError: - futures = None + futures = None # type: ignore + +try: + from urllib.request import urlopen +except ImportError: + from urllib2 import urlopen # type: ignore import re import shutil import tempfile -import urllib.request import zipfile +from contextlib import closing from io import BytesIO from os import listdir, path @@ -73,7 +78,7 @@ SOURCE_DIR = path.join(path.dirname(__file__), "sources_non_forked_cache") def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir): # Download and extract file in temp dir - with urllib.request.urlopen(zip_path) as req: + with closing(urlopen(zip_path)) as req: zip_f = zipfile.ZipFile(BytesIO(req.read())) zip_f.extractall(temp_dir) content_disp = req.headers.get("Content-Disposition")