Added progstats and environ commands.

This commit is contained in:
Jeremy Fincher 2005-02-12 07:18:59 +00:00
parent e8c6e6f978
commit dd1c287655

View File

@ -37,6 +37,8 @@ committed, remove it immediately. It must not be released with Supybot.
import supybot.plugins as plugins import supybot.plugins as plugins
import gc import gc
import os
import pwd
import sys import sys
import exceptions import exceptions
@ -53,6 +55,16 @@ def getTracer(fd):
print >>fd, '%s: %s' % (code.co_filename, code.co_name) print >>fd, '%s: %s' % (code.co_filename, code.co_name)
return tracer 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): class Debug(callbacks.Privmsg):
capability = 'owner' capability = 'owner'
def __init__(self, irc): def __init__(self, irc):
@ -172,6 +184,22 @@ class Debug(callbacks.Privmsg):
irc.reply(format('%L', map(str, L))) irc.reply(format('%L', map(str, L)))
collect = wrap(collect, [additional('positiveInt', 1)]) 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 Class = Debug