Skip to content

Commit

Permalink
fix code issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tp7309 committed Jun 12, 2024
1 parent d4c2db8 commit 55a53a6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit 55a53a6

Please # to comment.