forked from LBRYCommunity/lbry-sdk
use latest release for getting lbryum version, add a timeout when requesting lbrynet/lbryum version
This commit is contained in:
parent
3c60b35e2e
commit
52500bfbf5
1 changed files with 6 additions and 8 deletions
|
@ -10,7 +10,6 @@ import base58
|
||||||
import requests
|
import requests
|
||||||
import urllib
|
import urllib
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
from urllib2 import urlopen
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from twisted.web import server
|
from twisted.web import server
|
||||||
|
@ -2328,17 +2327,16 @@ class Daemon(AuthJSONRPCServer):
|
||||||
|
|
||||||
|
|
||||||
def get_lbryum_version_from_github():
|
def get_lbryum_version_from_github():
|
||||||
r = urlopen(
|
return get_version_from_github('https://api.github.com/repos/lbryio/lbryum/releases/latest')
|
||||||
"https://raw.githubusercontent.com/lbryio/lbryum/master/lib/version.py").read().split('\n')
|
|
||||||
version = next(line.split("=")[1].split("#")[0].replace(" ", "")
|
|
||||||
for line in r if "LBRYUM_VERSION" in line)
|
|
||||||
version = version.replace("'", "")
|
|
||||||
return version
|
|
||||||
|
|
||||||
|
|
||||||
def get_lbrynet_version_from_github():
|
def get_lbrynet_version_from_github():
|
||||||
|
return get_version_from_github('https://api.github.com/repos/lbryio/lbry/releases/latest')
|
||||||
|
|
||||||
|
|
||||||
|
def get_version_from_github(url):
|
||||||
"""Return the latest released version from github."""
|
"""Return the latest released version from github."""
|
||||||
response = requests.get('https://api.github.com/repos/lbryio/lbry/releases/latest')
|
response = requests.get(url, timeout=20)
|
||||||
release = response.json()
|
release = response.json()
|
||||||
tag = release['tag_name']
|
tag = release['tag_name']
|
||||||
# githubs documentation claims this should never happen, but we'll check just in case
|
# githubs documentation claims this should never happen, but we'll check just in case
|
||||||
|
|
Loading…
Reference in a new issue