You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/libs/ffsubsync/version.py

35 lines
899 B

# -*- coding: utf-8 -*-
from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
def make_version_tuple(vstr=None):
if vstr is None:
vstr = __version__
if vstr[0] == 'v':
vstr = vstr[1:]
components = []
for component in vstr.split('+')[0].split('.'):
try:
components.append(int(component))
except ValueError:
break
return tuple(components)
def update_available():
import requests
from requests.exceptions import Timeout
from .constants import API_RELEASE_URL
try:
resp = requests.get(API_RELEASE_URL, timeout=1)
latest_vstr = resp.json()['tag_name']
except Timeout:
return False
except KeyError:
return False
if not resp.ok:
return False
return make_version_tuple(__version__) < make_version_tuple(latest_vstr)