/[thuban]/branches/thuban-1-0-branch/thuban/Thuban/version.py
ViewVC logotype

Annotation of /branches/thuban-1-0-branch/thuban/Thuban/version.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1306 - (hide annotations)
Thu Jun 26 17:00:01 2003 UTC (21 years, 8 months ago) by jonathan
Original Path: trunk/thuban/Thuban/version.py
File MIME type: text/x-python
File size: 4332 byte(s)
Added new 'versions' dictionary which
        contains the verions of various libraries which are checked
        when the module loads.
(verify_versions): Check all version numbers and returns a list of errors.

1 frank 922 #!/usr/bin/env python
2     #
3     # Copyright (C) 2002, 2003 by Intevation GmbH
4     # Authors:
5     # Thomas Koester <[email protected]>
6     # Frank Koormann <[email protected]>
7     #
8     # This program is free software under the GPL (>=v2)
9     # Read the file COPYING coming with the software for details.
10    
11     """
12     Thuban version information
13     """
14    
15     __version__ = "$Revision$"
16     # $Source$
17     # $Id$
18    
19    
20     version = 'cvs'
21     append_date = 1
22    
23    
24 jonathan 1306 import sys, os, os.path
25 frank 922 import time
26 jonathan 1306 from string import split
27 frank 922
28 jonathan 1306 from Thuban import _
29    
30    
31 frank 922 if __name__ == "__main__":
32     import sys
33     __file__ = sys.argv[0]
34    
35     def is_relevant_file(file):
36     """check if a file is relevant for determining the current version"""
37     extensions = ['.py', '.xpm', '.c', '.h']
38     return os.path.isfile(file) and os.path.splitext(file)[1] in extensions
39    
40     def visit(args, dirname, names):
41     """helper for os.path.walk; save mtime of newest file for this directory"""
42     files = filter(is_relevant_file,
43     [os.path.join(dirname, file) for file in names])
44     args['max'] = max([args['max']] + map(os.path.getmtime, files))
45    
46     def get_date(format):
47     """strftime formatted mtime of the newest relevant file"""
48     dir = os.path.dirname(os.path.abspath(__file__))
49     args = {'max': 0}
50     os.path.walk(dir, visit, args)
51     return time.strftime(format, time.localtime(args['max']))
52    
53     def get_changelog_date():
54     changelog = os.path.join(os.path.dirname(__file__), os.pardir, "ChangeLog")
55 frank 925 try:
56     file = open(changelog, "r")
57     line = file.readline()
58     file.close()
59     except:
60     return ""
61 jonathan 1306 return 'ChangeLog %s' % line.split(" ")[0]
62 frank 922
63 jonathan 1306
64     #
65     # Fill in versions with the different versions of the libraries
66     # that Thuban is using or requires (only if those libraries are
67     # available.
68     #
69    
70     versions = {}
71    
72 frank 922 if append_date:
73     version = '%s-%s' % (version, get_date('%Y%m%d'))
74 jonathan 1306 versions['thuban'] = version
75 frank 922
76 jonathan 1306 longversion = '%s\n%s' % (version, get_changelog_date())
77     #longversion = 'Release Version 0.8'
78     versions['thuban-long'] = longversion
79    
80     # wxPython
81     from wxPython.wx import __version__ as wxPython_version
82     versions['wxPython'] = wxPython_version
83     versions['wxPython-tuple'] = tuple(map(int, split(wxPython_version, ".")))
84    
85     # Python
86     versions['python'] = "%d.%d.%d" % sys.version_info[:3]
87     versions['python-tuple'] = sys.version_info[:3]
88    
89     # PySQLite
90     from sqlite import version as pysqlite_version
91     versions['pysqlite'] = pysqlite_version
92     versions['pysqlite-tuple'] = tuple(map(int, split(pysqlite_version, ".")))
93    
94     # SQLite
95     from _sqlite import sqlite_version
96     versions['sqlite'] = sqlite_version()
97     versions['sqlite-tuple'] = tuple(map(int, split(sqlite_version(), ".")))
98    
99     # GDAL
100     from Thuban.Model.resource import has_gdal_support
101     if has_gdal_support():
102     from gdalwarp import get_gdal_version
103     versions['gdal'] = get_gdal_version()
104     versions['gdal-tuple'] = tuple(map(int, split(get_gdal_version(), ".")))
105    
106     from wxproj import get_proj_version, get_gtk_version
107    
108     # GTK
109     gtk_ver = get_gtk_version()
110     if gtk_ver:
111     versions['gtk'] = ".".join(map(str, gtk_ver))
112     versions['gtk-tuple'] = gtk_ver
113    
114     # PROJ
115     proj_ver = get_proj_version()
116     if proj_ver:
117     versions['proj'] = ".".join(map(str, proj_ver))
118     versions['proj-tuple'] = proj_ver
119    
120     def verify_versions():
121     """Verifies that the versions of the libraries Thuban requires
122     are correct.
123    
124     Returns a non-empty list of strings indicating which libraries
125     are wrong, or the empty list if everthing is ok.
126     """
127    
128     #
129     # The 'name' below must correspong to an mapping in 'versions'.
130     # There must also exist a 'name'-tuple mapping.
131     #
132     # title name version
133     list = [["Python", "python", (2, 2, 1)],
134     ["wxPython", "wxPython", (2, 4, 0, 0)],
135     ["SQLite", "sqlite", (2, 8, 3)],
136     ["PySQLite", "pysqlite", (0, 4, 3)],
137     ["PROJ", "proj", (4, 4, 5)],
138     ["GTK", "gtk", (1, 2, 3)],
139     ["GDAL", "gdal", (1, 1, 8, 0)]]
140    
141     errors = []
142     for title, name, version in list:
143     tup = versions.get("%s-tuple" % name, None)
144     if tup and tup < version:
145     errors.append(_("%s %s < %s") % \
146     (title, versions[name], ".".join(map(str, version))))
147    
148     return errors
149    
150 frank 922 if __name__ == "__main__":
151     print longversion
152 jonathan 1306

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26