mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-14 22:49:23 +01:00
Added a channeldb command for testing channeldb.
This commit is contained in:
parent
9f0b593854
commit
0abd472dd1
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/python
|
||||||
|
|
||||||
###
|
###
|
||||||
# Copyright (c) 2002-2004, Jeremiah Fincher
|
# Copyright (c) 2002, Jeremiah Fincher
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -30,8 +30,8 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This is for debugging only. If this somehow gets added and
|
This is for jemfinch's debugging only. If this somehow gets added and
|
||||||
committed, remove it immediately. It should not be released.
|
committed, remove it immediately. It must not be released.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
@ -43,6 +43,7 @@ import exceptions
|
|||||||
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
|
from supybot.commands import *
|
||||||
import supybot.privmsgs as privmsgs
|
import supybot.privmsgs as privmsgs
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
@ -55,50 +56,57 @@ def configure(advanced):
|
|||||||
from questions import expect, anything, something, yn
|
from questions import expect, anything, something, yn
|
||||||
conf.registerPlugin('Debug', True)
|
conf.registerPlugin('Debug', True)
|
||||||
|
|
||||||
|
def getTracer(fd):
|
||||||
|
def tracer(frame, event, _):
|
||||||
|
if event == 'call':
|
||||||
|
code = frame.f_code
|
||||||
|
print >>fd, '%s: %s' % (code.co_filename, code.co_name)
|
||||||
|
return tracer
|
||||||
|
|
||||||
class Debug(privmsgs.CapabilityCheckingPrivmsg):
|
class Debug(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
capability = 'owner'
|
capability = 'owner'
|
||||||
def eval(self, irc, msg, args):
|
def eval(self, irc, msg, args, text):
|
||||||
"""<expression>
|
"""<expression>
|
||||||
|
|
||||||
Evaluates the given expression.
|
Evaluates the given expression.
|
||||||
"""
|
"""
|
||||||
s = privmsgs.getArgs(args)
|
|
||||||
try:
|
try:
|
||||||
irc.reply(repr(eval(s)))
|
irc.reply(repr(eval(text)))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
irc.reply(utils.exnToString(e))
|
irc.reply(utils.exnToString(e))
|
||||||
|
eval = wrap(eval, ['text'])
|
||||||
|
|
||||||
def exn(self, irc, msg, args):
|
def exn(self, irc, msg, args, name):
|
||||||
"""<exception name>
|
"""<exception name>
|
||||||
|
|
||||||
Raises the exception matching <exception name>.
|
Raises the exception matching <exception name>.
|
||||||
"""
|
"""
|
||||||
name = privmsgs.getArgs(args)
|
|
||||||
exn = getattr(exceptions, name)
|
exn = getattr(exceptions, name)
|
||||||
raise exn, msg.prefix
|
raise exn, msg.prefix
|
||||||
|
exn = wrap(exn, ['text'])
|
||||||
|
|
||||||
def sendquote(self, irc, msg, args):
|
def sendquote(self, irc, msg, args, text):
|
||||||
"""<raw IRC message>
|
"""<raw IRC message>
|
||||||
|
|
||||||
Sends (not queues) the raw IRC message given.
|
Sends (not queues) the raw IRC message given.
|
||||||
"""
|
"""
|
||||||
msg = ircmsgs.IrcMsg(privmsgs.getArgs(args))
|
msg = ircmsgs.IrcMsg(text)
|
||||||
irc.sendMsg(msg)
|
irc.sendMsg(msg)
|
||||||
|
sendquote = wrap(sendquote, ['text'])
|
||||||
|
|
||||||
def settrace(self, irc, msg, args):
|
def settrace(self, irc, msg, args, filename):
|
||||||
"""[<filename>]
|
"""[<filename>]
|
||||||
|
|
||||||
Starts tracing function calls to <filename>. If <filename> is not
|
Starts tracing function calls to <filename>. If <filename> is not
|
||||||
given, sys.stdout is used. This causes much output.
|
given, sys.stdout is used. This causes much output.
|
||||||
"""
|
"""
|
||||||
filename = privmsgs.getArgs(args, optional=1, required=0)
|
|
||||||
if filename:
|
if filename:
|
||||||
fd = file(filename, 'a')
|
fd = file(filename, 'a')
|
||||||
else:
|
else:
|
||||||
fd = sys.stdout
|
fd = sys.stdout
|
||||||
sys.settrace(utils.callTracer(fd))
|
sys.settrace(getTracer(fd))
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
settrace = wrap(settrace, [additional('filename')])
|
||||||
|
|
||||||
def unsettrace(self, irc, msg, args):
|
def unsettrace(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
@ -107,6 +115,15 @@ class Debug(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
"""
|
"""
|
||||||
sys.settrace(None)
|
sys.settrace(None)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
unsettrace = wrap(unsettrace)
|
||||||
|
|
||||||
|
def channeldb(self, irc, msg, args, channel):
|
||||||
|
"""[<channel>]
|
||||||
|
|
||||||
|
Returns the result of the channeldb converter.
|
||||||
|
"""
|
||||||
|
irc.reply(channel)
|
||||||
|
channeldb = wrap(channeldb, ['channeldb'])
|
||||||
|
|
||||||
|
|
||||||
Class = Debug
|
Class = Debug
|
||||||
|
Loading…
Reference in New Issue
Block a user