Extension Point : ISystemInfoProvider
The ISystemInfoProvider allows reporting system and version information displayed on the About Trac page and in internal error reports.
Trac requires some mandatory dependencies and can leverage various optional dependencies. Further, plugins can add their own dependencies. For administration and debugging purposes these dependencies and the respective version information is gathered and shown in the appropriate places.
Plugins can add additional such information by implementing ISystemInfoProvider. Note that the plugins themselves and their respective versions are already listed automatically, so plugins should only implement this interface to report additional version information of external dependencies.
A class implementing ISystemInfoProvider simply implements the
get_system_info() method to yield name and version tuples of any used external packages.
The following example reports platform information (i.e. the operating system and its version):
import platform from trac.core import * from trac.env import ISystemInfoProvider class PlatformInfoProvider(Component): """Provides platform (Operating System) information.""" implements(ISystemInfoProvider) def get_system_info(self): yield platform.system(), platform.version()
To automatically extract the version of a Python library package, use the
trac.util.get_pkginfo utility method. For example an imaginary
pony library could be reported as follows:
from trac.core import * from trac.env import ISystemInfoProvider from trac.util import get_pkginfo class PonyFarm(Component): """Provides ponies.""" implements(ISystemInfoProvider) def get_system_info(self): import pony yield 'Pony', get_pkginfo(pony).get('version') # ...
- trac.env.Environment: Trac, Python, SetupTools and PyTz versions
- trac.web.chrome.Chrome: Genshi and Babel versions
- trac.versioncontrol.svn_fs.SubversionConnector: Subversion version
- trac.mimeview.rst.ReStructuredTextRenderer: Docutils version
- trac.mimeview.pygments.PygmentsRenderer: Pygments version
Additional Information and References
Before 0.12 introduced the ISystemInfoProvider interface, it was customary to add version information by calling
(While this is still possible, it is usually preferrable to implement the interface to ensure that the version is shown even if the respective component has not otherwise been used yet.)
This approach is still used by:
- The database backends (so that only the database backend actually used is shown):
- trac.web.main.dispatch_request for the Web front-end type and version
- the about.html template, or
- a combination of the trac.web.main.send_internal_error() method (adds a
#JQUERY#marker) and the error.html template. (See #9341)