Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace python-requests with urllib.request #717

Merged
merged 2 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ Just do a git rebase!
git pull --rebase
python update_plugins.py # use python3 if python is unavailable

NOTE: If you get `ModuleNotFoundError: No module named 'requests'`, you must first install the `requests` python module using `pip`, `pip3`, or `easy_install`.

pip install requests

## Some screenshots

Colors when editing a Python file:
Expand Down
18 changes: 7 additions & 11 deletions update_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
futures = None

import re
import zipfile
import shutil
import tempfile
import requests

import urllib.request
import zipfile
from io import BytesIO
from os import path

# --- Globals ----------------------------------------------
Expand Down Expand Up @@ -71,16 +71,12 @@


def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir):
temp_zip_path = path.join(temp_dir, plugin_name)

# Download and extract file in temp dir
req = requests.get(zip_path)
open(temp_zip_path, "wb").write(req.content)

zip_f = zipfile.ZipFile(temp_zip_path)
zip_f.extractall(temp_dir)
with urllib.request.urlopen(zip_path) as req:
zip_f = zipfile.ZipFile(BytesIO(req.read()))
zip_f.extractall(temp_dir)
content_disp = req.headers.get("Content-Disposition")

content_disp = req.headers.get("Content-Disposition")
filename = re.findall("filename=(.+).zip", content_disp)[0]
plugin_temp_path = path.join(temp_dir, path.join(temp_dir, filename))

Expand Down