Use requests module for upstream version check
The requests module uses urllib3 internally.
This commit is contained in:
parent
0b819944b8
commit
fabdc773b6
15
buku.py
15
buku.py
@ -1612,18 +1612,13 @@ def open_in_browser(url):
|
|||||||
def check_upstream_release():
|
def check_upstream_release():
|
||||||
'''Check and report the latest upstream release version'''
|
'''Check and report the latest upstream release version'''
|
||||||
|
|
||||||
import urllib.request
|
import requests
|
||||||
|
|
||||||
request = urllib.request.Request(
|
r = requests.get('https://api.github.com/repos/jarun/buku/tags?per_page=1')
|
||||||
'https://api.github.com/repos/jarun/buku/tags?per_page=1',
|
if r.status_code != 200:
|
||||||
headers={'Accept': 'application/vnd.github.v3+json'})
|
logger.error('[%s] %s', r.status_code, r.reason)
|
||||||
|
|
||||||
response = urllib.request.urlopen(request)
|
|
||||||
if response.status != 200:
|
|
||||||
logger.error('Failed to fetch release information. Received %s'
|
|
||||||
% response.status)
|
|
||||||
else:
|
else:
|
||||||
latest = json.loads(response.read().decode('utf-8'))[0]['name']
|
latest = r.json()[0]['name']
|
||||||
if latest == 'v' + __version__:
|
if latest == 'v' + __version__:
|
||||||
print('This is the latest release')
|
print('This is the latest release')
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user