updater.py and bug fixes
This commit is contained in:
parent
337601f2a1
commit
97ce2b9ceb
4 changed files with 41 additions and 8 deletions
25
toxygen/updater.py
Normal file
25
toxygen/updater.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import util
|
||||
import requests
|
||||
|
||||
|
||||
def check_for_updates():
|
||||
current_version = util.program_version
|
||||
major, minor, patch = list(map(lambda x: int(x), current_version.split('.')))
|
||||
versions = generate_versions(major, minor, patch)
|
||||
for version in versions:
|
||||
if send_request(version):
|
||||
return version
|
||||
return None
|
||||
|
||||
|
||||
def send_request(version):
|
||||
# TODO: proxy support
|
||||
request = requests.get('https://github.com/toxygen-project/toxygen/releases/tag/v' + version)
|
||||
return request.status_code == 200
|
||||
|
||||
|
||||
def generate_versions(major, minor, patch):
|
||||
new_major = '.'.join([str(major + 1), '0', '0'])
|
||||
new_minor = '.'.join([str(major), str(minor + 1), '0'])
|
||||
new_patch = '.'.join([str(major), str(minor), str(patch + 1)])
|
||||
return new_major, new_minor, new_patch
|
||||
Loading…
Add table
Add a link
Reference in a new issue