Commit 58dd3a51 authored by Rafael Monnerat's avatar Rafael Monnerat

Rename and refactore getSystemSignatureDict to _getSystemVersionDict

Now it uses pkg_resources to collect much more versions.
parent f9dddeb1
...@@ -318,16 +318,10 @@ class IntrospectionTool(LogMixin, BaseTool): ...@@ -318,16 +318,10 @@ class IntrospectionTool(LogMixin, BaseTool):
""" """
return getConfiguration().products return getConfiguration().products
security.declareProtected(Permissions.ManagePortal, '_getSystemVersionDict')
# def _getSystemVersionDict(self):
# Library signature
#
# XXX this function can be cached to prevent disk access.
security.declareProtected(Permissions.ManagePortal, 'getSystemSignatureDict')
def getSystemSignatureDict(self):
""" """
Returns a dictionnary with all versions of installed libraries Returns a dictionnary with all versions of installed libraries
{ {
'python': '2.4.3' 'python': '2.4.3'
, 'pysvn': '1.2.3' , 'pysvn': '1.2.3'
...@@ -335,8 +329,15 @@ class IntrospectionTool(LogMixin, BaseTool): ...@@ -335,8 +329,15 @@ class IntrospectionTool(LogMixin, BaseTool):
} }
NOTE: consider using autoconf / automake tools ? NOTE: consider using autoconf / automake tools ?
""" """
def cached_getSystemVersionDict():
import pkg_resources
def tuple_to_format_str(t): def tuple_to_format_str(t):
return '.'.join([str(i) for i in t]) return '.'.join([str(i) for i in t])
version_dict = {}
for dist in pkg_resources.working_set:
version_dict[dist.key] = dist.version
from Products import ERP5 as erp5_product from Products import ERP5 as erp5_product
erp5_product_path = erp5_product.__file__.split("/")[:-1] erp5_product_path = erp5_product.__file__.split("/")[:-1]
try: try:
...@@ -345,22 +346,16 @@ class IntrospectionTool(LogMixin, BaseTool): ...@@ -345,22 +346,16 @@ class IntrospectionTool(LogMixin, BaseTool):
except: except:
erp5_version = None erp5_version = None
from App import version_txt version_dict["ProductS.ERP5"] = erp5_version
zope_version = tuple_to_format_str(version_txt.getZopeVersion()[:3]) return version_dict
from sys import version_info get_system_version_dict = CachingMethod(
# Get only x.x.x numbers. cached_getSystemVersionDict,
py_version = tuple_to_format_str(version_info[:3]) id='IntrospectionTool__getSystemVersionDict',
try: cache_factory='erp5_content_long')
import pysvn
# Convert tuple to x.x.x format return get_system_version_dict()
pysvn_version = tuple_to_format_str(pysvn.version)
except:
pysvn_version = None
return { "python" : py_version , "pysvn" : pysvn_version ,
"erp5" : erp5_version, "zope" : zope_version
}
security.declareProtected(Permissions.ManagePortal, security.declareProtected(Permissions.ManagePortal,
'_getActivityDict') '_getActivityDict')
def _getActivityDict(self): def _getActivityDict(self):
......
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