Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.macro.SystemInfo.SystemInfo Class Reference

List of all members.

Public Member Functions

def __init__
def formatInReadableUnits
def getDirectorySize
def render
def getInfo

Public Attributes

 macro
 request
 formatter

Detailed Description

Definition at line 22 of file SystemInfo.py.


Constructor & Destructor Documentation

def MoinMoin.macro.SystemInfo.SystemInfo.__init__ (   self,
  macro 
)

Definition at line 23 of file SystemInfo.py.

00023 
00024     def __init__(self, macro):
00025         self.macro = macro
00026         self.request = macro.request
00027         self.formatter = macro.formatter


Member Function Documentation

Definition at line 28 of file SystemInfo.py.

00028 
00029     def formatInReadableUnits(self, size):
00030         size = float(size)
00031         unit = u' Byte'
00032         if size > 9999:
00033             unit = u' KiB'
00034             size /= 1024
00035         if size > 9999:
00036             unit = u' MiB'
00037             size /= 1024
00038         if size > 9999:
00039             unit = u' GiB'
00040             size /= 1024
00041         return u"%.1f %s" % (size, unit)

Here is the caller graph for this function:

Definition at line 42 of file SystemInfo.py.

00042 
00043     def getDirectorySize(self, path):
00044         try:
00045             dirsize = 0
00046             for root, dummy, files in os.walk(path):
00047                 dirsize += sum([os.path.getsize(os.path.join(root, name)) for name in files])
00048         except EnvironmentError:
00049             dirsize = -1
00050         return dirsize

Here is the caller graph for this function:

Definition at line 55 of file SystemInfo.py.

00055 
00056     def getInfo(self):
00057         _ = self.request.getText
00058         request = self.request
00059 
00060         buf = StringIO()
00061 
00062         row = lambda label, value, buf=buf: buf.write(u'<dt>%s</dt><dd>%s</dd>' % (label, value))
00063 
00064         buf.write(u'<dl>')
00065         row(_('Python Version'), sys.version)
00066         row(_('MoinMoin Version'), _('Release %s [Revision %s]') % (version.release, version.revision))
00067 
00068         if not request.user.valid:
00069             # for an anonymous user it ends here.
00070             buf.write(u'</dl>')
00071             return buf.getvalue()
00072 
00073         if request.user.isSuperUser():
00074             # superuser gets all page dependent stuff only
00075             try:
00076                 import Ft
00077                 ftversion = Ft.__version__
00078             except ImportError:
00079                 ftversion = None
00080             except AttributeError:
00081                 ftversion = 'N/A'
00082 
00083             if ftversion:
00084                 row(_('4Suite Version'), ftversion)
00085 
00086             # TODO add python-xml check and display it
00087 
00088             # Get the full pagelist of the wiki
00089             pagelist = request.rootpage.getPageList(user='')
00090             systemPages = []
00091             totalsize = 0
00092             for page in pagelist:
00093                 if wikiutil.isSystemPage(request, page):
00094                     systemPages.append(page)
00095                 totalsize += Page(request, page).size()
00096 
00097             row(_('Number of pages'), str(len(pagelist)-len(systemPages)))
00098             row(_('Number of system pages'), str(len(systemPages)))
00099 
00100             row(_('Accumulated page sizes'), self.formatInReadableUnits(totalsize))
00101             data_dir = request.cfg.data_dir
00102             row(_('Disk usage of %(data_dir)s/pages/') % {'data_dir': data_dir},
00103                 self.formatInReadableUnits(self.getDirectorySize(os.path.join(data_dir, 'pages'))))
00104             row(_('Disk usage of %(data_dir)s/') % {'data_dir': data_dir},
00105             self.formatInReadableUnits(self.getDirectorySize(data_dir)))
00106 
00107             edlog = editlog.EditLog(request)
00108             row(_('Entries in edit log'), "%s (%s)" % (edlog.lines(), self.formatInReadableUnits(edlog.size())))
00109 
00110             # This puts a heavy load on the server when the log is large
00111             eventlogger = eventlog.EventLog(request)
00112             row('Event log', self.formatInReadableUnits(eventlogger.size()))
00113 
00114         nonestr = _("NONE")
00115         # a valid user gets info about all installed extensions
00116         row(_('Global extension macros'), ', '.join(macro.modules) or nonestr)
00117         row(_('Local extension macros'),
00118             ', '.join(wikiutil.wikiPlugins('macro', self.macro.cfg)) or nonestr)
00119 
00120         glob_actions = [x for x in action.modules
00121                         if not x in request.cfg.actions_excluded]
00122         row(_('Global extension actions'), ', '.join(glob_actions) or nonestr)
00123         loc_actions = [x for x in wikiutil.wikiPlugins('action', self.macro.cfg)
00124                        if not x in request.cfg.actions_excluded]
00125         row(_('Local extension actions'), ', '.join(loc_actions) or nonestr)
00126 
00127         row(_('Global parsers'), ', '.join(parser.modules) or nonestr)
00128         row(_('Local extension parsers'),
00129             ', '.join(wikiutil.wikiPlugins('parser', self.macro.cfg)) or nonestr)
00130 
00131         try:
00132             import xapian
00133             xapVersion = 'Xapian %s' % xapian.version_string()
00134         except ImportError:
00135             xapian = None
00136             xapVersion = _('Xapian and/or Python Xapian bindings not installed')
00137 
00138         xapian_enabled = request.cfg.xapian_search
00139         xapState = (_('Disabled'), _('Enabled'))
00140         xapRow = '%s, %s' % (xapState[xapian_enabled], xapVersion)
00141 
00142         if xapian and xapian_enabled:
00143             from MoinMoin.search.Xapian.indexing import XapianIndex
00144             idx = XapianIndex(request)
00145             idxState = (_('index unavailable'), _('index available'))
00146             idx_exists = idx.exists()
00147             xapRow += ', %s' % idxState[idx_exists]
00148             if idx_exists:
00149                 xapRow += ', %s' % (_('last modified: %s') %
00150                     request.user.getFormattedDateTime(idx.mtime()))
00151 
00152         row(_('Xapian search'), xapRow)
00153 
00154         if xapian and xapian_enabled:
00155             stems = xapian.Stem.get_available_languages()
00156             row(_('Stemming for Xapian'), xapState[request.cfg.xapian_stemming] +
00157                 " (%s)" % (stems or nonestr))
00158 
00159         try:
00160             from threading import activeCount
00161             t_count = activeCount()
00162         except ImportError:
00163             t_count = None
00164 
00165         row(_('Active threads'), t_count or _('N/A'))
00166         buf.write(u'</dl>')
00167 
00168         return buf.getvalue()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 51 of file SystemInfo.py.

00051 
00052     def render(self):
00053         _ = self.request.getText
00054         return self.formatter.rawHTML(self.getInfo())

Here is the call graph for this function:


Member Data Documentation

Definition at line 26 of file SystemInfo.py.

Definition at line 24 of file SystemInfo.py.

Definition at line 25 of file SystemInfo.py.


The documentation for this class was generated from the following file: