From a4bb12a436856705c91cb6789f6f70c0f23edf1e Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 23 Aug 2004 23:03:18 +0000 Subject: [PATCH] Added settraces. --- sandbox/Debug.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/sandbox/Debug.py b/sandbox/Debug.py index f69cf000a..1ff5ca914 100644 --- a/sandbox/Debug.py +++ b/sandbox/Debug.py @@ -34,14 +34,15 @@ This is for jemfinch's debugging only. If this somehow gets added and committed, remove it immediately. It must not be released. """ -import plugins +import supybot.plugins as plugins +import sys import exceptions -import conf -import utils -import privmsgs -import callbacks +import supybot.conf as conf +import supybot.utils as utils +import supybot.privmsgs as privmsgs +import supybot.callbacks as callbacks def configure(advanced): @@ -52,6 +53,10 @@ def configure(advanced): from questions import expect, anything, something, yn conf.registerPlugin('Debug', True) +def tracer(frame, event, _): + if event == 'call': + print '%s: %s\n' % (frame.f_code.co_filename, frame.f_code.co_name) + class Debug(privmsgs.CapabilityCheckingPrivmsg): capability = 'owner' @@ -83,6 +88,22 @@ class Debug(privmsgs.CapabilityCheckingPrivmsg): msg = ircmsgs.IrcMsg(privmsgs.getArgs(args)) irc.sendMsg(msg) + def settrace(self, irc, msg, args): + """takes no arguments + + Starts tracing function calls on stdout. This causes much output. + """ + sys.settrace(tracer) + irc.replySuccess() + + def unsettrace(self, irc, msg, args): + """takes no arguments + + Stops tracing function calls on stdout. + """ + sys.settrace(None) + irc.replySuccess() + Class = Debug