File: version.py

package info (click to toggle)
cyclograph 1.7.1-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,136 kB
  • ctags: 705
  • sloc: python: 9,682; makefile: 5
file content (58 lines) | stat: -rw-r--r-- 1,806 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""version.py """

# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Federico Brega, Pierluigi Villani

# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
from __future__ import print_function
import urllib2
import threading

# Version of this software
VERSION = '1.7.1'

# This url is used to fetch the latest version number directely from 
# the website
LAST_VERSION_URL = 'http://cyclograph.sourceforge.net/latestcg'

# This parameter enables or disables the check if the user is running
# the latest version.
# It is intended for environments where the installable software is controlled
# as are distribution.
VERSION_CHECK_ENABLED = False

class LastVersionQuery(threading.Thread):
    lastversion = ''
    def query(self):
        if not VERSION_CHECK_ENABLED:
            return
        try:
            page = urllib2.urlopen(LAST_VERSION_URL)
            self.lastversion = page.read().strip()
            page.close()
        except urllib2.URLError:
            self.lastversion = ''

    def islast(self):
        if not self.lastversion:
            return True
        return version_list(VERSION) >= version_list(self.lastversion)

    def run(self):
        self.query()

def version_list(version_string):
    return map(int, version_string.split('.'))

if __name__ == "__main__":
    print(VERSION)