From 55a53a6df98019d01d4f18c19882e25f157f8698 Mon Sep 17 00:00:00 2001 From: tp7309 Date: Wed, 12 Jun 2024 23:33:17 +0800 Subject: [PATCH] fix code issues --- updater.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/updater.py b/updater.py index c1558ee..2014913 100644 --- a/updater.py +++ b/updater.py @@ -109,7 +109,8 @@ def reporthook(a, b, c): print("\rdownloading: %5.1f%%" % (a * b * 100.0 / c), end="") try: if url.lower().startswith('http'): - urllib.request.urlretrieve(url, store_path, reporthook=reporthook) + req = urllib.request.Request(url) + urllib.request.urlretrieve(req, store_path, reporthook=reporthook) else: raise ValueError from None if not os.path.exists(store_path): @@ -129,7 +130,8 @@ def download_release(repo_owner, repo_name, last_update_time, refile, destpath): % (repo_owner, repo_name, last_update_time, destpath)) response = '' if url.lower().startswith('http'): - with urllib.request.urlopen(url) as f: + req = urllib.request.Request(url) + with urllib.request.urlopen(req) as f: response = json.loads(f.read().decode('utf-8')) else: raise ValueError from None