[update_plugins] Replace 'requests' with 'urlopen'
Signed-off-by: weiyang <weiyang.ones@gmail.com>
This commit is contained in:
parent
6f6d50967c
commit
6b55c5d498
|
@ -10,7 +10,12 @@ except ImportError:
|
||||||
import zipfile
|
import zipfile
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import requests
|
try:
|
||||||
|
# For Python 3.0 and later
|
||||||
|
from urllib.request import urlopen
|
||||||
|
except ImportError:
|
||||||
|
# Fall back to Python 2's urllib2
|
||||||
|
from urllib2 import urlopen
|
||||||
|
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
|
@ -64,8 +69,8 @@ def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir):
|
||||||
temp_zip_path = path.join(temp_dir, plugin_name)
|
temp_zip_path = path.join(temp_dir, plugin_name)
|
||||||
|
|
||||||
# Download and extract file in temp dir
|
# Download and extract file in temp dir
|
||||||
req = requests.get(zip_path)
|
resp = urlopen(zip_path)
|
||||||
open(temp_zip_path, 'wb').write(req.content)
|
open(temp_zip_path, 'wb').write(resp.read())
|
||||||
|
|
||||||
zip_f = zipfile.ZipFile(temp_zip_path)
|
zip_f = zipfile.ZipFile(temp_zip_path)
|
||||||
zip_f.extractall(temp_dir)
|
zip_f.extractall(temp_dir)
|
||||||
|
|
Loading…
Reference in a new issue