comparison MoinMoin/wikitest.py @ 0:77665d8e2254

tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0 (automatically generated log message) imported from: moin--main--1.5--base-0
author Thomas Waldmann <tw-public@gmx.de>
date Thu, 22 Sep 2005 15:09:50 +0000
parents
children df348d27f1fc
comparison
equal deleted inserted replaced
-1:000000000000 0:77665d8e2254
1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - Installation tests
4
5 Note that this module tests a wiki instance for errors, and
6 does not unit-test the code or something.
7
8 @copyright: 2000-2004 by Jürgen Hermann <jh@web.de>
9 @license: GNU GPL, see COPYING for details.
10 """
11
12 def runTest(request):
13 """ This is used by moin.cgi to test the configuration, after MoinMoin
14 is successfully imported. It should request.write(a plain text diagnosis
15 to stdout.
16 """
17 # Note that importing here makes a difference, namely the request
18 # object is already created
19 import os, sys
20 from MoinMoin import version, config
21 from MoinMoin.logfile import editlog, eventlog
22
23 request.write('Release %s\n' % version.release)
24 request.write('Revision %s\n' % version.revision)
25 request.write('Python version %s\n' % sys.version)
26 request.write('Python installed to %s\n' % sys.exec_prefix)
27
28 # Try xml
29 try:
30 import xml
31 request.write('PyXML is %sinstalled\n' %
32 ('NOT ', '')[xml.__file__.find('_xmlplus') != -1])
33 except ImportError:
34 request.write('xml is missing\n')
35
36 request.write('Python Path:\n')
37 for dir in sys.path:
38 request.write(' %s\n' % dir)
39
40 # check if the request is a local one
41 import socket
42 local_request = (socket.getfqdn(request.server_name) == socket.getfqdn(request.remote_addr))
43
44 # check directories
45 request.write("Checking directories...\n")
46 dirs = [('data', request.cfg.data_dir),
47 ('user', request.cfg.user_dir),
48 ]
49 for name, path in dirs:
50 if not os.path.isdir(path):
51 request.write("*** %s directory NOT FOUND (set to '%s')\n" % (name, path))
52 elif not os.access(path, os.R_OK | os.W_OK | os.X_OK):
53 request.write("*** %s directory NOT ACCESSIBLE (set to '%s')\n" % (name, path))
54 else:
55 path = os.path.abspath(path)
56 request.write(" %s directory tests OK (set to '%s')\n" % (name, path))
57
58 # check eventlog access
59 log = eventlog.EventLog(request)
60 msg = log.sanityCheck()
61 if msg: request.write("*** %s\n" % msg)
62
63 # check editlog access
64 log = editlog.EditLog(request)
65 msg = log.sanityCheck()
66 if msg: request.write("*** %s\n" % msg)
67
68 # keep some values to ourselves
69 request.write("\nServer Environment:\n")
70 if local_request:
71 # print the environment, in case people use exotic servers with broken
72 # CGI APIs (say, M$ IIS), to help debugging those
73 keys = os.environ.keys()
74 keys.sort()
75 for key in keys:
76 request.write(" %s = %s" % (key, repr(os.environ[key])))
77 else:
78 request.write(" ONLY AVAILABLE FOR LOCAL REQUESTS ON THIS HOST!")
79
80 # run unit tests
81 request.write("\n\nUnit Tests:\n")
82
83 # The unit tests are diabled on servers using threads, beause they
84 # change request.cfg, which is now shared between threads.
85 # TODO: check if we can enable them back in a safe way
86 if config.use_threads:
87 request.write(" *** The unit tests are disabled when using multi "
88 "threading ***")
89 else:
90 try:
91 from MoinMoin import _tests
92 _tests.run(request)
93 except ImportError:
94 request.write(" *** The unit tests are not available ***")
95