Skip to content
Snippets Groups Projects
Commit 8e1e8ce2 authored by ale's avatar ale
Browse files

add version check on every run of the client

parent d386158c
Branches
No related tags found
No related merge requests found
......@@ -124,6 +124,10 @@ def main():
if args:
parser.error('Too many arguments')
# Perform a version check.
if utils.check_version():
print >>sys.stderr, 'A new release is available! Please update.'
# Reading from the configuration file will set this variable to
# a string, convert it back into boolean.
do_realtime = not opts.no_realtime_watch
......
import hashlib
import os
import urllib2
from djrandom_client import version
NESTING = 2
VERSION_PY_URL = 'https://git.autistici.org/djrandom/plain/client/djrandom_client/version.py'
def generate_path(base_dir, sha1):
......@@ -48,3 +51,31 @@ def read_config_defaults(parser, path):
path, 1 + linenum))
var, value = map(lambda x: x.strip(), line.split('=', 1))
parser.set_default(var, _unquote(value))
def _split_version_string(s):
def _toint(x):
try:
return int(x)
except:
return x
return tuple(map(_toint, s.split('.')))
def check_version():
"""Returns True if we need to upgrade."""
try:
last_version_str = urllib2.urlopen(VERSION_PY_URL).read()
except:
return False
match = re.match(r'VERSION\s*=\s*[\'"]([0-9a-z.]+)[\'"]',
last_version_str.strip())
if not match:
return False
last_version_t = _split_version_string(match.group(1))
cur_version_t = _split_version_string(version.VERSION)
return cur_version_t <= last_version_t
VERSION = '0.2'
#!/usr/bin/python
# Read version from version.py.
import sys, os
sys.path.insert(0, os.path.dirname(__file__))
from djrandom_client import version
from setuptools import setup, find_packages
import platform
if platform.system() == 'Darwin':
......@@ -9,7 +14,7 @@ else:
setup(
name="djrandom-client",
version="0.1",
version=version.VERSION,
description="DJ:Random client",
author="ale",
author_email="ale@incal.net",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment