cleaned code, added more detail into .sys
This commit is contained in:
parent
17ab4e436d
commit
3c67274d5d
1 changed files with 11 additions and 11 deletions
|
@ -14,8 +14,8 @@ def replace(text, wordDic):
|
||||||
return rc.sub(translate, text)
|
return rc.sub(translate, text)
|
||||||
|
|
||||||
def checkProc(checked_stats):
|
def checkProc(checked_stats):
|
||||||
status_file = open("/proc/%d/status" % os.getpid()).read()
|
status_file = open('/proc/self/status').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)
|
||||||
checked_stats = checked_stats.split()
|
checked_stats = checked_stats.split()
|
||||||
stats = '\x02, '.join(key + ': \x02' + status[key] for key in checked_stats)
|
stats = '\x02, '.join(key + ': \x02' + status[key] for key in checked_stats)
|
||||||
|
@ -26,10 +26,12 @@ def checkProc(checked_stats):
|
||||||
@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."
|
||||||
python_version = platform.python_version()
|
name = platform.node()
|
||||||
os = platform.platform(aliased=True)
|
os = platform.platform()
|
||||||
|
python_version = platform.python_implementation() + ' ' + platform.python_version()
|
||||||
|
arch = '-'.join(platform.architecture())
|
||||||
cpu = platform.machine()
|
cpu = platform.machine()
|
||||||
return "Platform: \x02%s\x02, Python Version: \x02%s\x02, CPU: \x02%s\x02" % (os, python_version, cpu)
|
return 'Name: \x02%s\x02, Operating System: \x02%s\x02, Python Version: \x02%s\x02, Architecture: \x02%s\x02, CPU: \x02%s\x02' % (name, os, python_version, arch, cpu)
|
||||||
|
|
||||||
|
|
||||||
@hook.command("memory", autohelp=False)
|
@hook.command("memory", autohelp=False)
|
||||||
|
@ -51,14 +53,12 @@ def mem(inp):
|
||||||
memory = '\x02'.join(memory)
|
memory = '\x02'.join(memory)
|
||||||
|
|
||||||
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()
|
||||||
out = os.popen(cmd).read()
|
out = os.popen(cmd).read()
|
||||||
memory = 0
|
memory = 0
|
||||||
for amount in re.findall(r'([,0-9]+) K', out):
|
for amount in re.findall(r'([,0-9]+) K', out):
|
||||||
memory += int(amount.replace(',', ''))
|
memory += int(amount.replace(',', ''))
|
||||||
memory = float(memory)
|
memory = str(round(float(memory) / 1024, 2))
|
||||||
memory = memory / 1024
|
|
||||||
memory = round(memory, 2)
|
|
||||||
memory = 'Memory Usage: \x02%s MB\x02' % memory
|
memory = 'Memory Usage: \x02%s MB\x02' % memory
|
||||||
else:
|
else:
|
||||||
memory = 'error: operating system not currently supported'
|
memory = 'error: operating system not currently supported'
|
||||||
|
@ -69,8 +69,8 @@ def mem(inp):
|
||||||
@hook.command(autohelp=False)
|
@hook.command(autohelp=False)
|
||||||
def up(inp):
|
def up(inp):
|
||||||
".up -- Shows the bot's uptime."
|
".up -- Shows the bot's uptime."
|
||||||
up_time = subprocess.check_output("ps -eo pid,etime | grep %s | awk '{print $2}'" % os.getpid(), shell=True)
|
up_time = subprocess.check_output('ps -eo pid,etime | grep %s | awk \'{print $2}\'' % os.getpid(), shell=True)
|
||||||
up_time = "Uptime: " + up_time
|
up_time = 'Uptime: \x02' + up_time + '\x02'
|
||||||
return up_time
|
return up_time
|
||||||
|
|
||||||
@hook.command("proc", autohelp=False)
|
@hook.command("proc", autohelp=False)
|
||||||
|
|
Reference in a new issue