[Zope-Checkins] CVS: Zope/lib/python/App - Hotfixes.py:1.1.2.1 version_txt.py:1.4.10.1
Shane Hathaway
shane@digicool.com
Fri, 28 Sep 2001 17:44:48 -0400
Update of /cvs-repository/Zope/lib/python/App
In directory cvs.zope.org:/tmp/cvs-serv21252
Modified Files:
Tag: shane-hotfix-registry-branch
version_txt.py
Added Files:
Tag: shane-hotfix-registry-branch
Hotfixes.py
Log Message:
- Made a function that returns the parsed Zope version number.
- Added a hotfix registry.
=== Added File Zope/lib/python/App/Hotfixes.py ===
from version_txt import getZopeVersion
from zLOG import LOG, INFO, WARNING
merged_hotfixes = {
}
def isMerged(name):
return merged_hotfixes.get(name, 0)
def logHotfix(id, apply_hotfix):
if apply_hotfix > 0:
LOG('Hotfixes', INFO, 'Applying %s' % id)
elif apply_hotfix < 0:
LOG('Hotfixes', WARNING, 'Not applying %s. It is not designed for '
'this version of Zope. Please uninstall the hotfix product.'
% id)
else:
LOG('Hotfixes', WARNING, 'Not applying %s. The fix has already been '
'merged into Zope. Please uninstall the hotfix product.'
% id)
def beforeApplyHotfix(id, req_major, req_minor, req_micro):
apply_hotfix = 0
major, minor, micro = getZopeVersion()[:3]
if major > 0 and (
(major * 10000 + minor * 100 + micro) <
(req_major * 10000 + req_minor * 100 + req_micro)):
# The version of Zope is too old for this hotfix.
apply_hotfix = -1
elif not isMerged(id):
apply_hotfix = 1
logHotfix(id, apply_hotfix)
return apply_hotfix
=== Zope/lib/python/App/version_txt.py 1.4 => 1.4.10.1 ===
v=sys.version_info
-def version_txt():
+_version_string = None
+_zope_version = None
+
+
+def intval(dict, key):
+ v = dict.get(key, None)
+ if v is None:
+ return 0
+ else:
+ return int(v)
+
+def strval(dict, key):
+ v = dict.get(key, None)
+ if v is None:
+ return ''
+ else:
+ return str(v)
+
- try:
- s = open(os.path.join(SOFTWARE_HOME,'version.txt')).read()
- s = re.sub("\(.*?\)\?","",s)
- s= '(%s, python %d.%d.%d, %s)' % (s,v[0],v[1],v[2],sys.platform)
- return s
- except:
- return '(unreleased version, python %d.%d.%d, %s)' % (v[0],v[1],v[2],sys.platform)
+def _prep_version_data():
+ global _version_string, _zope_version
+ if _version_string is None:
+ try:
+ s = open(os.path.join(SOFTWARE_HOME,'version.txt')).read()
+ ss = re.sub("\(.*?\)\?","",s)
+ ss = '%s, python %d.%d.%d, %s' % (ss,v[0],v[1],v[2],sys.platform)
+ _version_string = ss
+
+ expr = re.compile(
+ r'(?P<product>[A-Za-z0-9]+) +(?P<major>[0-9]+)'
+ '\.(?P<minor>[0-9]+)\.(?P<micro>[0-9]+)'
+ '(?P<status>[A-Za-z]+)?(?P<release>[0-9]+)?')
+ dict = expr.match(s).groupdict()
+ _zope_version = (
+ intval(dict, 'major'),
+ intval(dict, 'minor'),
+ intval(dict, 'micro'),
+ strval(dict, 'status'),
+ intval(dict, 'release'))
+ except:
+ ss = 'unreleased version, python %d.%d.%d, %s' % (
+ v[0],v[1],v[2],sys.platform)
+ _version_string = ss
+ _zope_version = (-1, -1, -1, '', -1)
+
+def version_txt():
+ _prep_version_data()
+ return '(%s)' % _version_string
+
+def getZopeVersion():
+ """
+ Format of zope_version tuple:
+ (major <int>, minor <int>, micro <int>, status <string>, release <int>)
+ If unreleased, integers may be -1.
+ """
+ _prep_version_data()
+ return _zope_version
+