annotate MoinMoin/macro/SystemInfo.py @ 3123:5cb80bd604b4

refactored _() getText calls to match new api
author Radomir Dopieralski <moindev@sheep.art.pl>
date Wed, 27 Feb 2008 00:28:28 +0100
parents 01f05e74aa9c
children 924a9abe5689
rev   line source
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - SystemInfo Macro
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 This macro shows some info about your wiki, wiki software and your system.
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1902
diff changeset
7 @copyright: 2006 MoinMoin:ThomasWaldmann,
1993
93877b7d87b9 fixing copyright headers:unified my name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1920
diff changeset
8 2007 MoinMoin:ReimarBauer
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9 @license: GNU GPL, see COPYING for details.
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10 """
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12 Dependencies = ['pages']
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13
1902
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
14 import sys, os
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15 from StringIO import StringIO
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17 from MoinMoin import wikiutil, version
639
a80a6c629bc3 remove processor support, use a parser now
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 636
diff changeset
18 from MoinMoin import action, macro, parser
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19 from MoinMoin.logfile import editlog, eventlog
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20 from MoinMoin.Page import Page
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
22 class SystemInfo:
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
23 def __init__(self, macro, args):
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
24 self.macro = macro
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
25 self.request = macro.request
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
26 self.formatter = macro.formatter
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
27 self.args = args
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
28
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
29 def formatInReadableUnits(self, size):
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30 size = float(size)
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31 unit = u' Byte'
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 if size > 9999:
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 unit = u' KiB'
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 size /= 1024
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 if size > 9999:
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 unit = u' MiB'
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37 size /= 1024
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 if size > 9999:
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 unit = u' GiB'
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40 size /= 1024
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41 return u"%.1f %s" % (size, unit)
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
43 def getDirectorySize(self, path):
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44 try:
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
45 dirsize = 0
1805
ebcebba1afb3 removed some unused attributes, used 'dummy' for dummies
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1532
diff changeset
46 for root, dummy, files in os.walk(path):
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
47 dirsize += sum([os.path.getsize(os.path.join(root, name)) for name in files])
1805
ebcebba1afb3 removed some unused attributes, used 'dummy' for dummies
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1532
diff changeset
48 except EnvironmentError:
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
49 dirsize = -1
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
50 return dirsize
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
51
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
52 def render(self):
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
53 _ = self.request.getText
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
54 return self.formatter.rawHTML(self.getInfo())
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
55
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
56 def getInfo(self):
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
57 _ = self.request.getText
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
58 request = self.request
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 800
diff changeset
59
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
60 buf = StringIO()
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
61
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
62 row = lambda label, value, buf=buf: buf.write(u'<dt>%s</dt><dd>%s</dd>' % (label, value))
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
63
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
64 buf.write(u'<dl>')
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
65 row(_('Python Version'), sys.version)
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
66 row(_('MoinMoin Version'), _('Release %s [Revision %s]') % (version.release, version.revision))
1902
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
67
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
68 if not request.user.valid:
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
69 # for an anonymous user it ends here.
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
70 buf.write(u'</dl>')
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
71 return buf.getvalue()
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
72
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
73 if request.user.isSuperUser():
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
74 # superuser gets all page dependent stuff only
1902
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
75 try:
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
76 import Ft
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
77 ftversion = Ft.__version__
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
78 except ImportError:
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
79 ftversion = None
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
80 except AttributeError:
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
81 ftversion = 'N/A'
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2232
diff changeset
82
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
83 if ftversion:
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
84 row(_('4Suite Version'), ftversion)
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
85
1902
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
86 # TODO add python-xml check and display it
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
87
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
88 # Get the full pagelist of the wiki
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
89 pagelist = request.rootpage.getPageList(user='')
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
90 systemPages = []
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
91 totalsize = 0
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
92 for page in pagelist:
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
93 if wikiutil.isSystemPage(request, page):
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
94 systemPages.append(page)
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
95 totalsize += Page(request, page).size()
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
96
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
97 row(_('Number of pages'), str(len(pagelist)-len(systemPages)))
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
98 row(_('Number of system pages'), str(len(systemPages)))
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
99
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
100 row(_('Accumulated page sizes'), self.formatInReadableUnits(totalsize))
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
101 data_dir = request.cfg.data_dir
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
102 row(_('Disk usage of %(data_dir)s/pages/') % {'data_dir': data_dir},
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
103 self.formatInReadableUnits(self.getDirectorySize(os.path.join(data_dir, 'pages'))))
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
104 row(_('Disk usage of %(data_dir)s/') % {'data_dir': data_dir},
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
105 self.formatInReadableUnits(self.getDirectorySize(data_dir)))
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
106
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
107 edlog = editlog.EditLog(request)
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
108 row(_('Entries in edit log'), "%s (%s)" % (edlog.lines(), self.formatInReadableUnits(edlog.size())))
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
109
1902
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
110 # This puts a heavy load on the server when the log is large
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
111 eventlogger = eventlog.EventLog(request)
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
112 row('Event log', self.formatInReadableUnits(eventlogger.size()))
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
113
1859
327b23c27532 SystemInfo:fixed indenting for nonestr
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1840
diff changeset
114 nonestr = _("NONE")
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
115 # a valid user gets info about all installed extensions
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
116 row(_('Global extension macros'), ', '.join(macro.modules) or nonestr)
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
117 row(_('Local extension macros'),
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
118 ', '.join(wikiutil.wikiPlugins('macro', self.macro.cfg)) or nonestr)
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
119
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
120 glob_actions = [x for x in action.modules
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
121 if not x in request.cfg.actions_excluded]
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
122 row(_('Global extension actions'), ', '.join(glob_actions) or nonestr)
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
123 loc_actions = [x for x in wikiutil.wikiPlugins('action', self.macro.cfg)
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
124 if not x in request.cfg.actions_excluded]
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
125 row(_('Local extension actions'), ', '.join(loc_actions) or nonestr)
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
126
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
127 row(_('Global parsers'), ', '.join(parser.modules) or nonestr)
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
128 row(_('Local extension parsers'),
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
129 ', '.join(wikiutil.wikiPlugins('parser', self.macro.cfg)) or nonestr)
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
130
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
131 from MoinMoin.search.builtin import Search
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
132 xapState = (_('Disabled'), _('Enabled'))
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
133 idxState = (_('index available'), _('index unavailable'))
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
134 xapRow = xapState[request.cfg.xapian_search]
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
135
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
136 if request.cfg.xapian_search:
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
137 idx = Search._xapianIndex(request)
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
138 available = idx and idxState[0] or idxState[1]
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
139 mtime = _('last modified: %s') % (idx and
1279
835c392be95d improvements for SystemInfo macro
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1236
diff changeset
140 request.user.getFormattedDateTime(
835c392be95d improvements for SystemInfo macro
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1236
diff changeset
141 wikiutil.version2timestamp(idx.mtime())) or
835c392be95d improvements for SystemInfo macro
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1236
diff changeset
142 _('N/A'))
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
143 xapRow += ', %s, %s' % (available, mtime)
1498
2807382fec1f fix xapian version if xapian is not installed
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1476
diff changeset
144
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
145 try:
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
146 import xapian
2221
f5b9f51e67a9 fix xapian version check, use non-deprecated functions for it with fallback to depracated functions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2212
diff changeset
147 try:
f5b9f51e67a9 fix xapian version check, use non-deprecated functions for it with fallback to depracated functions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2212
diff changeset
148 xapVersion = xapian.version_string()
f5b9f51e67a9 fix xapian version check, use non-deprecated functions for it with fallback to depracated functions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2212
diff changeset
149 except AttributeError:
f5b9f51e67a9 fix xapian version check, use non-deprecated functions for it with fallback to depracated functions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2212
diff changeset
150 xapVersion = xapian.xapian_version_string() # deprecated since xapian 0.9.6, removal in 1.1.0
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
151 except ImportError:
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
152 xapVersion = _('Xapian and/or Python Xapian bindings not installed')
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 800
diff changeset
153
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
154 row(_('Xapian search'), xapRow)
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
155 row(_('Xapian Version'), xapVersion)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2232
diff changeset
156
2230
48af49661497 SystemInfo: info for stemmer snowball added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2221
diff changeset
157 stems = [nonestr]
48af49661497 SystemInfo: info for stemmer snowball added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2221
diff changeset
158 try:
48af49661497 SystemInfo: info for stemmer snowball added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2221
diff changeset
159 import Stemmer
48af49661497 SystemInfo: info for stemmer snowball added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2221
diff changeset
160 try:
48af49661497 SystemInfo: info for stemmer snowball added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2221
diff changeset
161 stems = Stemmer.algorithms()
48af49661497 SystemInfo: info for stemmer snowball added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2221
diff changeset
162 stemVersion = Stemmer.version()
48af49661497 SystemInfo: info for stemmer snowball added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2221
diff changeset
163 except:
3123
5cb80bd604b4 refactored _() getText calls to match new api
Radomir Dopieralski <moindev@sheep.art.pl>
parents: 2286
diff changeset
164 stemVersion = _('PyStemmer not installed')
2230
48af49661497 SystemInfo: info for stemmer snowball added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2221
diff changeset
165 except ImportError:
3123
5cb80bd604b4 refactored _() getText calls to match new api
Radomir Dopieralski <moindev@sheep.art.pl>
parents: 2286
diff changeset
166 stemVersion = _('PyStemmer not installed')
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2232
diff changeset
167
2231
ba51622d8283 SystemInfo: labels for stemming renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2230
diff changeset
168 row(_('Stemming for Xapian'), xapState[request.cfg.xapian_stemming])
3123
5cb80bd604b4 refactored _() getText calls to match new api
Radomir Dopieralski <moindev@sheep.art.pl>
parents: 2286
diff changeset
169 row(_('PyStemmer Version'), stemVersion)
5cb80bd604b4 refactored _() getText calls to match new api
Radomir Dopieralski <moindev@sheep.art.pl>
parents: 2286
diff changeset
170 row(_('PyStemmer stems'), ', '.join(stems) or nonestr)
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
171
1902
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
172 try:
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
173 from threading import activeCount
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
174 t_count = activeCount()
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
175 except ImportError:
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
176 t_count = None
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
177
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
178 row(_('Active threads'), t_count or _('N/A'))
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
179 buf.write(u'</dl>')
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
180
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
181 return buf.getvalue()
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
182
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
183 def execute(macro, args):
2212
1e0582fc064c SystemInfo: fixed isSpiderAgent
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2207
diff changeset
184 if macro.request.isSpiderAgent: # reduce bot cpu usage
2207
7ae581d79352 updated bot useragents list, reduce bot cpu usage of some macros (ported from 1.5 repo)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1993
diff changeset
185 return ''
7ae581d79352 updated bot useragents list, reduce bot cpu usage of some macros (ported from 1.5 repo)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1993
diff changeset
186 return SystemInfo(macro, args).render()
7ae581d79352 updated bot useragents list, reduce bot cpu usage of some macros (ported from 1.5 repo)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1993
diff changeset
187