From dd1c287655a0c7090ccaedbec8f10b45fefb5015 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sat, 12 Feb 2005 07:18:59 +0000 Subject: [PATCH] Added progstats and environ commands. --- sandbox/Debug/plugin.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sandbox/Debug/plugin.py b/sandbox/Debug/plugin.py index 636bfef66..ad09dc6e8 100644 --- a/sandbox/Debug/plugin.py +++ b/sandbox/Debug/plugin.py @@ -37,6 +37,8 @@ committed, remove it immediately. It must not be released with Supybot. import supybot.plugins as plugins import gc +import os +import pwd import sys import exceptions @@ -53,6 +55,16 @@ def getTracer(fd): print >>fd, '%s: %s' % (code.co_filename, code.co_name) return tracer +def progstats(): + pw = pwd.getpwuid(os.getuid()) + response = 'Process ID %s running as user "%s" and as group "%s" ' \ + 'from directory "%s" with the command line "%s". ' \ + 'Running on Python %s.' % \ + (os.getpid(), pw[0], pw[3], + os.getcwd(), ' '.join(sys.argv), + sys.version.translate(string.ascii, '\r\n')) + return response + class Debug(callbacks.Privmsg): capability = 'owner' def __init__(self, irc): @@ -172,6 +184,22 @@ class Debug(callbacks.Privmsg): irc.reply(format('%L', map(str, L))) collect = wrap(collect, [additional('positiveInt', 1)]) + def progstats(self, irc, msg, args): + """takes no arguments + + Returns various unix-y information on the running supybot process. + """ + irc.reply(progstats()) + progstats = wrap(progstats) + + def environ(self, irc, msg, args): + """takes no arguments + + Returns the environment of the supybot process. + """ + irc.reply(repr(os.environ)) + environ = wrap(environ) + Class = Debug