annotate MoinMoin/macro/SystemInfo.py @ 6125:07782b362ef7

bump version in moin.spec
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 31 Oct 2016 20:52:05 +0100
parents 14863ba96c46
children
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
3242
924a9abe5689 macros: refactored for 1.7 arg parser
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3123
diff changeset
7 @copyright: 2006-2008 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:
3242
924a9abe5689 macros: refactored for 1.7 arg parser
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3123
diff changeset
23 def __init__(self, macro):
1839
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
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
28 def formatInReadableUnits(self, size):
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29 size = float(size)
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30 unit = u' Byte'
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31 if size > 9999:
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 unit = u' KiB'
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 size /= 1024
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 if size > 9999:
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 unit = u' MiB'
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 size /= 1024
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37 if size > 9999:
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 unit = u' GiB'
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 size /= 1024
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40 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
41
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
42 def getDirectorySize(self, path):
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
43 try:
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44 dirsize = 0
1805
ebcebba1afb3 removed some unused attributes, used 'dummy' for dummies
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1532
diff changeset
45 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
46 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
47 except EnvironmentError:
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
48 dirsize = -1
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
49 return dirsize
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
50
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
51 def render(self):
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
52 _ = self.request.getText
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
53 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
54
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
55 def getInfo(self):
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
56 _ = self.request.getText
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
57 request = self.request
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 800
diff changeset
58
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
59 buf = StringIO()
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
60
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
61 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
62
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
63 buf.write(u'<dl>')
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
64 row(_('Python Version'), sys.version)
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
65 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
66
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
67 if not request.user.valid:
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
68 # for an anonymous user it ends here.
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
69 buf.write(u'</dl>')
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
70 return buf.getvalue()
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
71
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
72 if request.user.isSuperUser():
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
73 # superuser gets all page dependent stuff only
1902
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
74 try:
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
75 import Ft
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
76 ftversion = Ft.__version__
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
77 except ImportError:
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
78 ftversion = None
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
79 except AttributeError:
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
80 ftversion = 'N/A'
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2232
diff changeset
81
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
82 if ftversion:
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
83 row(_('4Suite Version'), ftversion)
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
84
1902
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
85 # TODO add python-xml check and display it
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
86
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
87 # 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
88 pagelist = request.rootpage.getPageList(user='')
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
89 systemPages = []
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
90 totalsize = 0
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
91 for page in pagelist:
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
92 if wikiutil.isSystemPage(request, page):
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
93 systemPages.append(page)
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
94 totalsize += Page(request, page).size()
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
95
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
96 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
97 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
98
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
99 row(_('Accumulated page sizes'), self.formatInReadableUnits(totalsize))
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
100 data_dir = request.cfg.data_dir
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
101 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
102 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
103 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
104 self.formatInReadableUnits(self.getDirectorySize(data_dir)))
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
105
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
106 edlog = editlog.EditLog(request)
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
107 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
108
1902
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
109 # 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
110 eventlogger = eventlog.EventLog(request)
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
111 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
112
1859
327b23c27532 SystemInfo:fixed indenting for nonestr
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1840
diff changeset
113 nonestr = _("NONE")
1840
7f4f997c7e6e SystemInfo: access limitiations added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1839
diff changeset
114 # 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
115 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
116 row(_('Local extension macros'),
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
117 ', '.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
118
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
119 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
120 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
121 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
122 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
123 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
124 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
125
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
126 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
127 row(_('Local extension parsers'),
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
128 ', '.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
129
3676
8dc2c2fc64ef removed PyStemmer dependency by just using xapian.Stem and requiring xapian >= 1.0.0, also remove code handling older xapian versions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3242
diff changeset
130 try:
8dc2c2fc64ef removed PyStemmer dependency by just using xapian.Stem and requiring xapian >= 1.0.0, also remove code handling older xapian versions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3242
diff changeset
131 import xapian
8dc2c2fc64ef removed PyStemmer dependency by just using xapian.Stem and requiring xapian >= 1.0.0, also remove code handling older xapian versions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3242
diff changeset
132 xapVersion = 'Xapian %s' % xapian.version_string()
8dc2c2fc64ef removed PyStemmer dependency by just using xapian.Stem and requiring xapian >= 1.0.0, also remove code handling older xapian versions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3242
diff changeset
133 except ImportError:
8dc2c2fc64ef removed PyStemmer dependency by just using xapian.Stem and requiring xapian >= 1.0.0, also remove code handling older xapian versions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3242
diff changeset
134 xapian = None
8dc2c2fc64ef removed PyStemmer dependency by just using xapian.Stem and requiring xapian >= 1.0.0, also remove code handling older xapian versions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3242
diff changeset
135 xapVersion = _('Xapian and/or Python Xapian bindings not installed')
5293
14863ba96c46 SystemInfo macro: fix failure if xapian/xapian-bindings are not installed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5078
diff changeset
136
14863ba96c46 SystemInfo macro: fix failure if xapian/xapian-bindings are not installed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5078
diff changeset
137 xapian_enabled = request.cfg.xapian_search
14863ba96c46 SystemInfo macro: fix failure if xapian/xapian-bindings are not installed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5078
diff changeset
138 xapState = (_('Disabled'), _('Enabled'))
14863ba96c46 SystemInfo macro: fix failure if xapian/xapian-bindings are not installed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5078
diff changeset
139 xapRow = '%s, %s' % (xapState[xapian_enabled], xapVersion)
3676
8dc2c2fc64ef removed PyStemmer dependency by just using xapian.Stem and requiring xapian >= 1.0.0, also remove code handling older xapian versions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3242
diff changeset
140
8dc2c2fc64ef removed PyStemmer dependency by just using xapian.Stem and requiring xapian >= 1.0.0, also remove code handling older xapian versions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3242
diff changeset
141 if xapian and xapian_enabled:
5293
14863ba96c46 SystemInfo macro: fix failure if xapian/xapian-bindings are not installed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5078
diff changeset
142 from MoinMoin.search.Xapian.indexing import XapianIndex
5078
37a4d53c56d1 SystemInfo: fix xapian index infos
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5077
diff changeset
143 idx = XapianIndex(request)
5293
14863ba96c46 SystemInfo macro: fix failure if xapian/xapian-bindings are not installed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5078
diff changeset
144 idxState = (_('index unavailable'), _('index available'))
14863ba96c46 SystemInfo macro: fix failure if xapian/xapian-bindings are not installed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5078
diff changeset
145 idx_exists = idx.exists()
14863ba96c46 SystemInfo macro: fix failure if xapian/xapian-bindings are not installed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5078
diff changeset
146 xapRow += ', %s' % idxState[idx_exists]
14863ba96c46 SystemInfo macro: fix failure if xapian/xapian-bindings are not installed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5078
diff changeset
147 if idx_exists:
14863ba96c46 SystemInfo macro: fix failure if xapian/xapian-bindings are not installed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5078
diff changeset
148 xapRow += ', %s' % (_('last modified: %s') %
14863ba96c46 SystemInfo macro: fix failure if xapian/xapian-bindings are not installed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5078
diff changeset
149 request.user.getFormattedDateTime(idx.mtime()))
1498
2807382fec1f fix xapian version if xapian is not installed
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1476
diff changeset
150
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
151 row(_('Xapian search'), xapRow)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2232
diff changeset
152
3676
8dc2c2fc64ef removed PyStemmer dependency by just using xapian.Stem and requiring xapian >= 1.0.0, also remove code handling older xapian versions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3242
diff changeset
153 if xapian and xapian_enabled:
8dc2c2fc64ef removed PyStemmer dependency by just using xapian.Stem and requiring xapian >= 1.0.0, also remove code handling older xapian versions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3242
diff changeset
154 stems = xapian.Stem.get_available_languages()
8dc2c2fc64ef removed PyStemmer dependency by just using xapian.Stem and requiring xapian >= 1.0.0, also remove code handling older xapian versions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3242
diff changeset
155 row(_('Stemming for Xapian'), xapState[request.cfg.xapian_stemming] +
8dc2c2fc64ef removed PyStemmer dependency by just using xapian.Stem and requiring xapian >= 1.0.0, also remove code handling older xapian versions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3242
diff changeset
156 " (%s)" % (stems or nonestr))
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
157
1902
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
158 try:
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
159 from threading import activeCount
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
160 t_count = activeCount()
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
161 except ImportError:
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
162 t_count = None
6628902acfe7 SystemInfo: minor refactoring
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1859
diff changeset
163
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
164 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
165 buf.write(u'</dl>')
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
166
1839
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
167 return buf.getvalue()
28d6a093016c SystemInfo:refactored into class SystemInfo
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1805
diff changeset
168
3242
924a9abe5689 macros: refactored for 1.7 arg parser
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3123
diff changeset
169 def macro_SystemInfo(macro):
2212
1e0582fc064c SystemInfo: fixed isSpiderAgent
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2207
diff changeset
170 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
171 return ''
3242
924a9abe5689 macros: refactored for 1.7 arg parser
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3123
diff changeset
172 return SystemInfo(macro).render()
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
173