Added notification for cpu/cpuclock/temp

+ notification carcass
This commit is contained in:
arcan1s
2013-10-08 00:49:55 +04:00
parent 3994652562
commit d5a91f566e
4 changed files with 127 additions and 28 deletions

View File

@ -27,14 +27,113 @@ class PTMNotify:
notification.sendEvent();
def initText(self, sender):
def createText(self, type):
"""function to create text"""
content = []
if (sender == self.parent.parent.label_uptime):
if (type == "system"):
content.append("system")
text = "Kernel: " + commands.getoutput("uname -rsm") + "\n"
text = text + "Hostname: " + commands.getoutput("uname -n") + "\n"
text = text + "Whoami: " + commands.getoutput("whoami") + "\n"
text = text + "Uptime: " + commands.getoutput("uptime")
text = ""
try:
text = text + "Kernel: " + commands.getoutput("uname -rsm") + "\n"
text = text + "Hostname: " + commands.getoutput("uname -n") + "\n"
text = text + "Whoami: " + commands.getoutput("whoami") + "\n"
text = text + "Uptime: " + commands.getoutput("uptime")
except:
pass
content.append(text)
elif (type == "processor"):
content.append("processor")
text = ""
try:
output = commands.getoutput("grep 'model name' /proc/cpuinfo | head -1")
text = text + "Model: " + ' '.join(output.split()[3:]) + "\n"
output = commands.getoutput("sar -u | tail -1")
text = text + "CPU Usage: " + str(100-float(output[-1])) + "%\n"
output = commands.getoutput("grep MHz /proc/cpuinfo | head -1")
text = text + "CPU Freq: " + str(int(float(output.split()[-1]))) + " MHz\n"
output = commands.getoutput("sensors -u")
text = text + "Temps:"
for line in output.split("\n"):
if (line.find("_input") > -1):
text = text + " " + str(round(float(line.split()[-1]), 0)) + "\xb0C"
except:
pass
content.append(text)
return content
def initText(self, sender):
"""function to send text"""
try:
if (sender == self.parent.parent.label_uptime):
content = self.createText("system")
return content
except:
pass
try:
if (sender == self.parent.parent.label_cpu):
content = self.createText("processor")
return content
except:
pass
try:
if (sender == self.parent.parent.label_cpuclock):
content = self.createText("processor")
return content
except:
pass
try:
if (sender == self.parent.parent.label_temp):
content = self.createText("processor")
return content
except:
pass
try:
if (sender == self.parent.parent.label_gpu):
content = self.createText("graphical")
return content
except:
pass
try:
if (sender == self.parent.parent.label_gputemp):
content = self.createText("graphical")
return content
except:
pass
try:
if (sender == self.parent.parent.label_mem):
content = self.createText("memory")
return content
except:
pass
try:
if (sender == self.parent.parent.label_swap):
content = self.createText("memory")
return content
except:
pass
try:
if (sender == self.parent.parent.label_hdd0):
content = self.createText("hdd")
return content
except:
pass
try:
if (sender == self.parent.parent.label_hddtemp):
content = self.createText("hdd")
return content
except:
pass
try:
if (sender == self.parent.parent.label_netDown):
content = self.createText("network")
return content
except:
pass
try:
if (sender == self.parent.parent.label_bat):
content = self.createText("acpi")
return content
except:
pass