~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/action/thread_monitor.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
    Shows the current traceback of all threads.
6
6
 
7
 
    @copyright: 2006 by MoinMoin:AlexanderSchremmer
 
7
    @copyright: 2006 MoinMoin:AlexanderSchremmer
8
8
    @license: GNU GPL, see COPYING for details.
9
9
"""
10
 
 
11
10
import os, time
12
11
from StringIO import StringIO
13
12
 
14
 
from MoinMoin import wikiutil, util
 
13
from MoinMoin import Page, wikiutil
15
14
from MoinMoin.util import thread_monitor
16
15
 
17
16
def execute_fs(pagename, request):
18
 
    if thread_monitor.hook_enabled:
 
17
    _ = request.getText
 
18
    # check for superuser
 
19
    if not request.user.isSuperUser():
 
20
        request.theme.add_msg(_('You are not allowed to use this action.'), "error")
 
21
        return Page.Page(request, pagename).send_page()
 
22
 
 
23
    if thread_monitor.hook_enabled():
19
24
        s = StringIO()
20
25
        thread_monitor.trigger_dump(s)
21
26
        time.sleep(5) # allow for all threads to dump to request
28
33
    else:
29
34
        dump_fname = "nowhere"
30
35
 
31
 
    request.http_headers()
 
36
    request.emit_http_headers()
32
37
    request.write('<html><body>A dump has been saved to %s.</body></html>' % dump_fname)
33
 
    raise util.MoinMoinNoFooter
34
38
 
35
39
def execute_wiki(pagename, request):
36
 
    request.http_headers()
37
 
 
38
 
    wikiutil.send_title(request, "Thread monitor")
 
40
    _ = request.getText
 
41
    # be extra paranoid in dangerous actions
 
42
    actname = __name__.split('.')[-1]
 
43
    if not request.user.isSuperUser():
 
44
        request.theme.add_msg(_('You are not allowed to use this action.'), "error")
 
45
        return Page.Page(request, pagename).send_page()
 
46
 
 
47
    request.emit_http_headers()
 
48
 
 
49
    request.theme.send_title("Thread monitor")
39
50
    request.write('<pre>')
40
51
 
41
 
    if not thread_monitor.hook_enabled:
 
52
    if not thread_monitor.hook_enabled():
42
53
        request.write("Hook is not enabled.")
43
54
    else:
44
55
        s = StringIO()
45
56
        thread_monitor.trigger_dump(s)
46
57
        time.sleep(5) # allow for all threads to dump to request
47
58
        request.write(wikiutil.escape(s.getvalue()))
48
 
        
 
59
 
49
60
    request.write('</pre>')
50
 
    wikiutil.send_footer(request, pagename)
 
61
    request.theme.send_footer(pagename)
 
62
    request.theme.send_closing_html()
51
63
 
52
64
execute = execute_fs
53
65