Shortend down on load.py and made it logically faster.

This commit is contained in:
2017-02-15 10:24:44 +01:00
parent 602ce3f2d0
commit 4192d739fd

20
status/load.py Normal file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env python3
from subprocess import check_output
from re import findall
from platform import system
def load():
sysName = system()
if sysName == 'Linux':
arpOutput = check_output("cat /proc/loadavg", shell=True)
elif sysName == 'Darwin':
arpOutput = check_output("uptime", shell=True)
else:
return {"Error": "Running OS does not supported load."}
arpOutput = arpOutput.decode()
return findall('[0-9]{1,2}[\.][0-9]{2}', arpOutput)
if __name__ == '__main__':
print(load())