fix broken version check
This commit is contained in:
parent
e4b77a4a0a
commit
ff5980dfca
2 changed files with 15 additions and 10 deletions
|
@ -124,6 +124,7 @@ class CheckInternetConnection(object):
|
|||
|
||||
|
||||
class CheckRemoteVersion(object):
|
||||
URL = 'https://api.github.com/repos/lbryio/lbry-electron/releases/latest'
|
||||
def __init__(self):
|
||||
self.version = None
|
||||
|
||||
|
@ -163,14 +164,7 @@ class CheckRemoteVersion(object):
|
|||
def _get_version_from_release(self, release):
|
||||
"""Return the latest released version from github."""
|
||||
tag = release['tag_name']
|
||||
return self._get_version_from_tag(tag)
|
||||
|
||||
def _get_version_from_tag(self, tag):
|
||||
match = re.match('v([\d.]+)', tag)
|
||||
if match:
|
||||
return match.group(1)
|
||||
else:
|
||||
raise Exception('Failed to parse version from tag {}'.format(tag))
|
||||
return get_version_from_tag(tag)
|
||||
|
||||
def is_update_available(self):
|
||||
try:
|
||||
|
@ -2828,3 +2822,11 @@ def get_blob_payment_rate_manager(session, payment_rate_manager=None):
|
|||
payment_rate_manager = rate_managers[payment_rate_manager]
|
||||
log.info("Downloading blob with rate manager: %s", payment_rate_manager)
|
||||
return payment_rate_manager or session.payment_rate_manager
|
||||
|
||||
|
||||
def get_version_from_tag(tag):
|
||||
match = re.match('v([\d.]+)', tag)
|
||||
if match:
|
||||
return match.group(1)
|
||||
else:
|
||||
raise Exception('Failed to parse version from tag {}'.format(tag))
|
||||
|
|
|
@ -28,7 +28,9 @@ class MiscTests(unittest.TestCase):
|
|||
}
|
||||
with mock.patch('lbrynet.lbrynet_daemon.Daemon.requests') as req:
|
||||
req.get.return_value = response
|
||||
self.assertEqual('0.3.8', Daemon.get_lbry_electron_client_version_from_github())
|
||||
rv = Daemon.CheckRemoteVersion()
|
||||
rv._get_lbry_electron_client_version()
|
||||
self.assertEqual('0.3.8', rv.version)
|
||||
|
||||
def test_error_is_thrown_if_prerelease(self):
|
||||
response = mock.create_autospec(requests.Response)
|
||||
|
@ -38,8 +40,9 @@ class MiscTests(unittest.TestCase):
|
|||
}
|
||||
with mock.patch('lbrynet.lbrynet_daemon.Daemon.requests') as req:
|
||||
req.get.return_value = response
|
||||
rv = Daemon.CheckRemoteVersion()
|
||||
with self.assertRaises(Exception):
|
||||
Daemon.get_lbrynet_version_from_github()
|
||||
rv._get_lbry_electron_client_version()
|
||||
|
||||
def test_error_is_thrown_when_version_cant_be_parsed(self):
|
||||
with self.assertRaises(Exception):
|
||||
|
|
Loading…
Reference in a new issue