From 52500bfbf5da40e2c9ba7d47588dba9384271b38 Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Mon, 9 Jan 2017 12:02:48 -0500 Subject: [PATCH] use latest release for getting lbryum version, add a timeout when requesting lbrynet/lbryum version --- lbrynet/lbrynet_daemon/Daemon.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index c9b316c23..d3004150b 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -10,7 +10,6 @@ import base58 import requests import urllib import simplejson as json -from urllib2 import urlopen from decimal import Decimal from twisted.web import server @@ -2328,17 +2327,16 @@ class Daemon(AuthJSONRPCServer): def get_lbryum_version_from_github(): - r = urlopen( - "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 + return get_version_from_github('https://api.github.com/repos/lbryio/lbryum/releases/latest') 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.""" - response = requests.get('https://api.github.com/repos/lbryio/lbry/releases/latest') + response = requests.get(url, timeout=20) release = response.json() tag = release['tag_name'] # githubs documentation claims this should never happen, but we'll check just in case