Commit 559e24e0 authored by Shane Hathaway's avatar Shane Hathaway

Merged hotfix registry branch.

parent 5ad990a4
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
......@@ -87,13 +87,62 @@ import os,sys,string,re
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)
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()
s = re.sub("\(.*?\)\?","",s)
s= '(%s, python %d.%d.%d, %s)' % (s,v[0],v[1],v[2],sys.platform)
return s
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:
return '(unreleased version, python %d.%d.%d, %s)' % (v[0],v[1],v[2],sys.platform)
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment