tweaks to .sys

This commit is contained in:
neersighted 2012-03-29 18:22:22 -07:00
parent 9398190a5d
commit 0849e3f09b

View file

@ -4,6 +4,7 @@ import platform
from util import hook from util import hook
@hook.command("memory", autohelp=False)
@hook.command(autohelp=False) @hook.command(autohelp=False)
def mem(inp): def mem(inp):
".mem -- Display the bot's current memory usage." ".mem -- Display the bot's current memory usage."
@ -12,8 +13,8 @@ def mem(inp):
status_file = open("/proc/%d/status" % os.getpid()).read() status_file = open("/proc/%d/status" % os.getpid()).read()
line_pairs = re.findall(r"^(\w+):\s*(.*)\s*$", status_file, re.M) line_pairs = re.findall(r"^(\w+):\s*(.*)\s*$", status_file, re.M)
status = dict(line_pairs) status = dict(line_pairs)
keys = 'VmSize VmLib VmData VmExe VmRSS VmStk'.split() keys = 'VmSize VmRSS VmStk'.split()
return '\x02, '.join(key + ':\x02' + status[key] for key in keys) return '\x02, '.join(key + ': \x02' + status[key] for key in keys)
elif os.name == 'nt': elif os.name == 'nt':
cmd = "tasklist /FI \"PID eq %s\" /FO CSV /NH" % os.getpid() cmd = "tasklist /FI \"PID eq %s\" /FO CSV /NH" % os.getpid()
@ -23,10 +24,11 @@ def mem(inp):
for amount in re.findall(r'([,0-9]+) K', out): for amount in re.findall(r'([,0-9]+) K', out):
total += int(amount.replace(',', '')) total += int(amount.replace(',', ''))
return 'Memory usage: \x02%d kB\x02' % total return '\x02Memory Usage: %s kB\x02' % total
return mem.__doc__ return mem.__doc__
@hook.command("system", autohelp=False)
@hook.command(autohelp=False) @hook.command(autohelp=False)
def sys(inp): def sys(inp):
".sys -- Retrieves information about the host system." ".sys -- Retrieves information about the host system."