mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
New release 1.3.2:
* optimization and refactoring * gpu* and hddtemp now read from ext-sysmon DataEngine Extended SystemMonitor DataEngine: initial release 1.0: + add gpu source + add gputemp source + add hddtemp source + add install script
This commit is contained in:
parent
9243220505
commit
4c59e7e892
1
README
1
README
@ -26,3 +26,4 @@ For edited output you must open Settings window and setup output format in lines
|
||||
|
||||
Label order will changed if you change slider position. HTML tags in label work normally.
|
||||
Attention: you don't may set to show $cpu in swap label for example. $cpu will work only in cpu label.
|
||||
Attention: gpu, gputemp and hddtemp labels require extsysmon dataengine!
|
||||
|
BIN
extsysmon-1.0.zip
Normal file
BIN
extsysmon-1.0.zip
Normal file
Binary file not shown.
95
extsysmon/contents/code/main.py
Normal file
95
extsysmon/contents/code/main.py
Normal file
@ -0,0 +1,95 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyKDE4.kdecore import *
|
||||
from PyKDE4 import plasmascript
|
||||
import commands
|
||||
|
||||
|
||||
|
||||
class ExtendedSysMon(plasmascript.DataEngine):
|
||||
def __init__(self, parent, args=None):
|
||||
"""dataengine definition"""
|
||||
plasmascript.DataEngine.__init__(self, parent)
|
||||
|
||||
|
||||
def init(self):
|
||||
"""initialization"""
|
||||
self.setMinimumPollingInterval(333)
|
||||
|
||||
# setup gpu device
|
||||
self.gpudev = ''
|
||||
commandOut = commands.getoutput("lspci")
|
||||
if (commandOut.lower().find('nvidia') > -1):
|
||||
self.gpudev = 'nvidia'
|
||||
elif (commandOut.lower().find('radeon') > -1):
|
||||
self.gpudev = 'ati'
|
||||
|
||||
# setup hdd devices
|
||||
self.hdddev = []
|
||||
commandOut = commands.getoutput("ls -1 /dev/sd[a-z] && ls -1 /dev/hd[a-z]")
|
||||
for device in commandOut.split('\n'):
|
||||
if (device[:3] != "ls:"):
|
||||
self.hdddev.append(device)
|
||||
|
||||
|
||||
def sources(self):
|
||||
"""create sources"""
|
||||
sources = ["gpu", "gputemp", "hddtemp"]
|
||||
return sources
|
||||
|
||||
|
||||
def sourceRequestEvent(self, name):
|
||||
return self.updateSourceEvent(name)
|
||||
|
||||
|
||||
def updateSourceEvent(self, source):
|
||||
"""update sources and setup values"""
|
||||
if (source == "gpu"):
|
||||
key = "GPU"
|
||||
if (self.gpudev == 'nvidia'):
|
||||
commandOut = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1")
|
||||
try:
|
||||
value = "%5s" % (str(round(float(commandOut.split()[2][:-1]), 1)))
|
||||
except:
|
||||
value = " N\A"
|
||||
elif (self.gpudev == 'ati'):
|
||||
commandOut = commands.getoutput("aticonfig --od-getclocks | grep load | tail -n1")
|
||||
try:
|
||||
value = "%5s" % (str(round(float(commandOut.split()[3][:-1]), 1)))
|
||||
except:
|
||||
value = " N\A"
|
||||
else:
|
||||
value = " N\A"
|
||||
self.setData(source, "GPU", QString(value))
|
||||
elif (source == "gputemp"):
|
||||
if (self.gpudev == 'nvidia'):
|
||||
commandOut = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1")
|
||||
try:
|
||||
value = "%4s" % (str(round(float(commandOut.split()[2]), 1)))
|
||||
except:
|
||||
value = " N\A"
|
||||
elif (self.gpudev == 'ati'):
|
||||
commandOut = commands.getoutput("aticonfig --od-gettemperature | grep Temperature | tail -n1")
|
||||
try:
|
||||
value = "%4s" % (str(round(float(commandOut.split()[4]), 1)))
|
||||
except:
|
||||
value = " N\A"
|
||||
else:
|
||||
value = " N\A"
|
||||
self.setData(source, "GPUTemp", QString(value))
|
||||
elif (source == "hddtemp"):
|
||||
for device in self.hdddev:
|
||||
commandOut = commands.getoutput("hddtemp " + device)
|
||||
try:
|
||||
value = "%4s" % (str(round(float(commandOut.split(':')[2][:-3]), 1)))
|
||||
except:
|
||||
value = " N\A"
|
||||
self.setData(source, device, QString(value))
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
def CreateDataEngine(parent):
|
||||
return ExtendedSysMon(parent)
|
20
extsysmon/metadata.desktop
Normal file
20
extsysmon/metadata.desktop
Normal file
@ -0,0 +1,20 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Extended SystemMonitor DataEngine
|
||||
Comment=Adds gpu, gputemp and hddtemp to DataEngine
|
||||
ServiceTypes=Plasma/DataEngine
|
||||
Type=Service
|
||||
Icon=utilities-system-monitor
|
||||
|
||||
X-Plasma-API=python
|
||||
X-Plasma-MainScript=code/main.py
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alexeev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=ext-sysmon
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=http://kde-look.org/
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
3
install_extsysmon.sh
Executable file
3
install_extsysmon.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
plasmapkg -t dataengine -i extsysmon-1.0.zip
|
BIN
pytextmonitor-1.3.2.plasmoid
Normal file
BIN
pytextmonitor-1.3.2.plasmoid
Normal file
Binary file not shown.
@ -13,4 +13,4 @@ class Config():
|
||||
return self.config.readEntry(key, default).toString()
|
||||
|
||||
def set(self, key, value):
|
||||
self.config.writeEntry(key, value)
|
||||
self.config.writeEntry(key, value)
|
||||
|
@ -1,27 +1,39 @@
|
||||
class ConfigAccepted:
|
||||
def __init__(self, parent):
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.kdecore import *
|
||||
from PyKDE4.kdeui import *
|
||||
import config
|
||||
|
||||
|
||||
|
||||
class ConfigDefinition:
|
||||
def __init__(self, parent, configpage):
|
||||
"""class definition"""
|
||||
self.parent = parent
|
||||
self.configpage = configpage
|
||||
|
||||
|
||||
def configAccepted(self):
|
||||
"""function to accept settings"""
|
||||
settings = config.Config(self.parent)
|
||||
|
||||
# update local variables
|
||||
self.parent.interval = int(self.parent.configpage.ui.spinBox_interval.value())
|
||||
self.parent.settings.set('interval', self.parent.interval)
|
||||
self.parent.font_family = str(self.parent.configpage.ui.fontComboBox.currentFont().family())
|
||||
self.parent.settings.set('font_family', self.parent.font_family)
|
||||
self.parent.font_size = int(self.parent.configpage.ui.spinBox_fontSize.value())
|
||||
self.parent.settings.set('font_size', self.parent.font_size)
|
||||
self.parent.font_color = str(self.parent.configpage.ui.kcolorcombo.color().name())
|
||||
self.parent.settings.set('font_color', self.parent.font_color)
|
||||
if (self.parent.configpage.ui.comboBox_style.currentIndex() == 0):
|
||||
self.parent.interval = self.configpage.ui.spinBox_interval.value()
|
||||
settings.set('interval', self.parent.interval)
|
||||
self.parent.font_family = str(self.configpage.ui.fontComboBox.currentFont().family())
|
||||
settings.set('font_family', self.parent.font_family)
|
||||
self.parent.font_size = self.configpage.ui.spinBox_fontSize.value()
|
||||
settings.set('font_size', self.parent.font_size)
|
||||
self.parent.font_color = str(self.configpage.ui.kcolorcombo.color().name())
|
||||
settings.set('font_color', self.parent.font_color)
|
||||
if (self.configpage.ui.comboBox_style.currentIndex() == 0):
|
||||
self.parent.font_style = 'normal'
|
||||
else:
|
||||
self.parent.font_style = 'italic'
|
||||
self.parent.settings.set('font_style', self.parent.font_style)
|
||||
self.parent.font_weight = int(self.parent.configpage.ui.spinBox_weight.value())
|
||||
self.parent.settings.set('font_weight', self.parent.font_weight)
|
||||
settings.set('font_style', self.parent.font_style)
|
||||
self.parent.font_weight = self.configpage.ui.spinBox_weight.value()
|
||||
settings.set('font_weight', self.parent.font_weight)
|
||||
|
||||
# disconnecting from source and clear layout
|
||||
if (self.parent.uptimeBool == 1):
|
||||
@ -61,11 +73,11 @@ class ConfigAccepted:
|
||||
self.parent.label_temp.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_temp)
|
||||
if (self.parent.gpuBool == 1):
|
||||
self.parent.gpuChecker.stop()
|
||||
self.parent.extsysmon.disconnectSource("gpu", self.parent)
|
||||
self.parent.label_gpu.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_gpu)
|
||||
if (self.parent.gputempBool == 1):
|
||||
self.parent.gpuTempChecker.stop()
|
||||
self.parent.extsysmon.disconnectSource("gputemp", self.parent)
|
||||
self.parent.label_gputemp.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_gputemp)
|
||||
if (self.parent.memBool == 1):
|
||||
@ -91,7 +103,7 @@ class ConfigAccepted:
|
||||
self.parent.layout.removeItem(self.parent.label_hdd0)
|
||||
self.parent.layout.removeItem(self.parent.label_hdd1)
|
||||
if (self.parent.hddtempBool == 1):
|
||||
self.parent.hddTempChecker.stop()
|
||||
self.parent.extsysmon.disconnectSource("hddtemp", self.parent)
|
||||
self.parent.label_hddtemp.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_hddtemp)
|
||||
if (self.parent.netBool == 1):
|
||||
@ -108,30 +120,68 @@ class ConfigAccepted:
|
||||
self.parent.label_order = "------------"
|
||||
|
||||
for label in self.parent.dict_orders.keys():
|
||||
if (self.parent.configpage.checkboxes[self.parent.dict_orders[label]].checkState() == 2):
|
||||
if (self.configpage.checkboxes[self.parent.dict_orders[label]].checkState() == 2):
|
||||
exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = 1')
|
||||
pos = self.parent.configpage.sliders[self.parent.dict_orders[label]].value() - 1
|
||||
pos = self.configpage.sliders[self.parent.dict_orders[label]].value() - 1
|
||||
self.parent.label_order = self.parent.label_order[:pos] + label + self.parent.label_order[pos+1:]
|
||||
else:
|
||||
exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = 0')
|
||||
if (self.parent.dict_orders[label] == 'net'):
|
||||
exec ('self.parent.' + self.parent.dict_orders[label] + 'NonFormat = str(self.parent.configpage.lineedits[self.parent.dict_orders[label]].text())')
|
||||
exec ('self.parent.settings.set("' + self.parent.dict_orders[label] + 'NonFormat", self.parent.' + self.parent.dict_orders[label] + 'NonFormat)')
|
||||
exec ('self.parent.' + self.parent.dict_orders[label] + 'NonFormat = str(self.configpage.lineedits[self.parent.dict_orders[label]].text())')
|
||||
exec ('settings.set("' + self.parent.dict_orders[label] + 'NonFormat", self.parent.' + self.parent.dict_orders[label] + 'NonFormat)')
|
||||
else:
|
||||
exec ('self.parent.' + self.parent.dict_orders[label] + 'Format = str(self.parent.configpage.lineedits[self.parent.dict_orders[label]].text())')
|
||||
exec ('self.parent.settings.set("' + self.parent.dict_orders[label] + 'Format", self.parent.' + self.parent.dict_orders[label] + 'Format)')
|
||||
exec ('self.parent.settings.set("' + self.parent.dict_orders[label] + 'Bool", self.parent.' + self.parent.dict_orders[label] + 'Bool)')
|
||||
exec ('self.parent.' + self.parent.dict_orders[label] + 'Format = str(self.configpage.lineedits[self.parent.dict_orders[label]].text())')
|
||||
exec ('settings.set("' + self.parent.dict_orders[label] + 'Format", self.parent.' + self.parent.dict_orders[label] + 'Format)')
|
||||
exec ('settings.set("' + self.parent.dict_orders[label] + 'Bool", self.parent.' + self.parent.dict_orders[label] + 'Bool)')
|
||||
if (self.parent.dict_orders[label] == 'net'):
|
||||
self.parent.num_dev = int(self.parent.configpage.ui.comboBox_numNet.currentIndex())
|
||||
self.parent.settings.set('num_dev', self.parent.num_dev)
|
||||
self.parent.num_dev = self.configpage.ui.comboBox_numNet.currentIndex()
|
||||
settings.set('num_dev', self.parent.num_dev)
|
||||
elif (self.parent.dict_orders[label] == 'bat'):
|
||||
self.parent.battery_device = str(self.parent.configpage.ui.lineEdit_batdev.text())
|
||||
self.parent.ac_device = str(self.parent.configpage.ui.lineEdit_acdev.text())
|
||||
self.parent.settings.set('battery_device', self.parent.battery_device)
|
||||
self.parent.settings.set('ac_device', self.parent.ac_device)
|
||||
self.parent.battery_device = str(self.configpage.ui.lineEdit_batdev.text())
|
||||
self.parent.ac_device = str(self.configpage.ui.lineEdit_acdev.text())
|
||||
settings.set('battery_device', self.parent.battery_device)
|
||||
settings.set('ac_device', self.parent.ac_device)
|
||||
|
||||
self.parent.label_order = ''.join(self.parent.label_order.split('-'))
|
||||
self.parent.settings.set('label_order', self.parent.label_order)
|
||||
settings.set('label_order', self.parent.label_order)
|
||||
|
||||
# reinitializate
|
||||
self.parent.reinit.reinit()
|
||||
|
||||
|
||||
def createConfigurationInterface(self, parent):
|
||||
"""function to setup configuration window"""
|
||||
settings = config.Config(self.parent)
|
||||
|
||||
font = QFont(str(settings.get('font_family', 'Terminus')), settings.get('font_size', 12).toInt()[0], 400, False)
|
||||
self.configpage.ui.spinBox_interval.setValue(settings.get('interval', 2000).toInt()[0])
|
||||
self.configpage.ui.fontComboBox.setCurrentFont(font)
|
||||
self.configpage.ui.spinBox_fontSize.setValue(settings.get('font_size', 12).toInt()[0])
|
||||
self.configpage.ui.kcolorcombo.setColor(QColor(str(settings.get('font_color', '#000000'))))
|
||||
font = str(settings.get('font_style', 'normal'))
|
||||
if (font == 'normal'):
|
||||
self.configpage.ui.comboBox_style.setCurrentIndex(0)
|
||||
else:
|
||||
self.configpage.ui.comboBox_style.setCurrentIndex(1)
|
||||
self.configpage.ui.spinBox_weight.setValue(settings.get('font_weight', 400).toInt()[0])
|
||||
for label in self.parent.dict_orders.keys():
|
||||
exec ('bool = self.parent.' + self.parent.dict_orders[label] + 'Bool')
|
||||
if (bool == 1):
|
||||
self.configpage.checkboxes[self.parent.dict_orders[label]].setCheckState(2)
|
||||
self.configpage.sliders[self.parent.dict_orders[label]].setValue(self.parent.label_order.find(label)+1)
|
||||
else:
|
||||
self.configpage.checkboxes[self.parent.dict_orders[label]].setCheckState(0)
|
||||
if (self.parent.dict_orders[label] == 'net'):
|
||||
self.configpage.ui.comboBox_numNet.setCurrentIndex(settings.get('num_dev', 0).toInt()[0])
|
||||
self.configpage.lineedits[self.parent.dict_orders[label]].setText(str(settings.get(self.parent.dict_orders[label] + 'NonFormat', self.parent.dict_defFormat[self.parent.dict_orders[label]])))
|
||||
else:
|
||||
self.configpage.lineedits[self.parent.dict_orders[label]].setText(str(settings.get(self.parent.dict_orders[label] + 'Format', self.parent.dict_defFormat[self.parent.dict_orders[label]])))
|
||||
if (self.parent.dict_orders[label] == 'bat'):
|
||||
self.configpage.ui.lineEdit_batdev.setText(str(settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity')))
|
||||
self.configpage.ui.lineEdit_acdev.setText(str(settings.get('ac_device', '/sys/class/power_supply/AC/online')))
|
||||
|
||||
# add config page
|
||||
page = parent.addPage(self.configpage, i18n(self.parent.name()))
|
||||
page.setIcon(KIcon(self.parent.icon()))
|
||||
|
||||
parent.okClicked.connect(self.configAccepted)
|
@ -9,7 +9,7 @@ from PyKDE4 import plasmascript
|
||||
|
||||
|
||||
class ConfigWindow(QWidget):
|
||||
def __init__(self, parent, settings):
|
||||
def __init__(self, parent):
|
||||
"""settings window definition"""
|
||||
QWidget.__init__(self)
|
||||
self.ui = uic.loadUi(parent.package().filePath('ui', 'configwindow.ui'), self)
|
||||
|
@ -1,3 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.plasma import Plasma
|
||||
@ -14,6 +16,9 @@ class DataEngine:
|
||||
def connectToEngine(self):
|
||||
"""function to initializate engine"""
|
||||
self.parent.systemmonitor = self.parent.dataEngine("systemmonitor")
|
||||
if ((self.parent.gputempBool == 1) or (self.parent.gpuBool == 1) or (self.parent.hddtempBool == 1)):
|
||||
self.parent.extsysmon = self.parent.dataEngine("ext-sysmon")
|
||||
|
||||
if (self.parent.uptimeBool == 1):
|
||||
self.parent.systemmonitor.connectSource("system/uptime", self.parent, self.parent.interval)
|
||||
if (self.parent.cpuBool == 1):
|
||||
@ -26,170 +31,205 @@ class DataEngine:
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
|
||||
for core in range(self.parent.numCores):
|
||||
self.parent.systemmonitor.connectSource("cpu/cpu"+str(core)+"/clock", self.parent, self.parent.interval)
|
||||
if (self.parent.netBool == 1):
|
||||
self.parent.updateNetdev = 0
|
||||
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent, self.parent.interval)
|
||||
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent, self.parent.interval)
|
||||
if (self.parent.tempBool == 1):
|
||||
self.parent.systemmonitor.connectSource(self.parent.tempdev, self.parent, self.parent.interval)
|
||||
if (self.parent.gpuBool == 1):
|
||||
self.parent.extsysmon.connectSource("gpu", self.parent, self.parent.interval)
|
||||
if (self.parent.gputempBool == 1):
|
||||
self.parent.extsysmon.connectSource("gputemp", self.parent, self.parent.interval)
|
||||
if (self.parent.memBool == 1):
|
||||
if (self.parent.memInMb):
|
||||
self.parent.systemmonitor.connectSource("mem/physical/application", self.parent, self.parent.interval)
|
||||
else:
|
||||
self.parent.systemmonitor.connectSource("mem/physical/free", self.parent, 200)
|
||||
self.parent.systemmonitor.connectSource("mem/physical/used", self.parent, 200)
|
||||
self.parent.systemmonitor.connectSource("mem/physical/application", self.parent, 200)
|
||||
self.parent.systemmonitor.connectSource("mem/physical/free", self.parent, int(self.parent.interval*0.5))
|
||||
self.parent.systemmonitor.connectSource("mem/physical/used", self.parent, int(self.parent.interval*0.5))
|
||||
self.parent.systemmonitor.connectSource("mem/physical/application", self.parent, int(self.parent.interval*0.5))
|
||||
if (self.parent.swapBool == 1):
|
||||
if (self.parent.swapInMb):
|
||||
self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, self.parent.interval)
|
||||
else:
|
||||
self.parent.systemmonitor.connectSource("mem/swap/free", self.parent, 200)
|
||||
self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, 200)
|
||||
self.parent.systemmonitor.connectSource("mem/swap/free", self.parent, int(self.parent.interval*0.5))
|
||||
self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, int(self.parent.interval*0.5))
|
||||
if (self.parent.hddBool == 1):
|
||||
for mount in self.parent.mountPoints:
|
||||
self.parent.systemmonitor.connectSource("partitions" + mount + "/filllevel", self.parent, self.parent.interval)
|
||||
|
||||
if (self.parent.hddtempBool == 1):
|
||||
self.parent.extsysmon.connectSource("hddtemp", self.parent, self.parent.interval)
|
||||
if (self.parent.netBool == 1):
|
||||
self.parent.updateNetdev = 0
|
||||
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent, self.parent.interval)
|
||||
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent, self.parent.interval)
|
||||
|
||||
def dataUpdated(self, sourceName, data):
|
||||
"""function to refresh data"""
|
||||
if (sourceName == "system/uptime"):
|
||||
value = int(round(float(data[QString(u'value')]), 1))
|
||||
uptimeText = '%3sd%2sh%2sm' % (str(int(value/(24*60*60))), int(value/60/60)-int(value/24/60/60)*24, (value-value%60)/60%60)
|
||||
if (self.parent.uptimeFormat.split('$uptime')[0] != self.parent.uptimeFormat):
|
||||
line = self.parent.uptimeFormat.split('$uptime')[0] + uptimeText + self.parent.uptimeFormat.split('$uptime')[1]
|
||||
else:
|
||||
line = self.parent.uptimeFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_uptime.setText(text)
|
||||
elif (sourceName == "cpu/system/TotalLoad"):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
cpuText = "%5s" % (value)
|
||||
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
|
||||
if (self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[0]):
|
||||
line = self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] + cpuText + self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[1]
|
||||
try:
|
||||
if (sourceName == "system/uptime"):
|
||||
value = int(round(float(data[QString(u'value')]), 1))
|
||||
uptimeText = '%3sd%2sh%2sm' % (str(int(value/(24*60*60))), int(value/60/60)-int(value/24/60/60)*24, (value-value%60)/60%60)
|
||||
if (self.parent.uptimeFormat.split('$uptime')[0] != self.parent.uptimeFormat):
|
||||
line = self.parent.uptimeFormat.split('$uptime')[0] + uptimeText + self.parent.uptimeFormat.split('$uptime')[1]
|
||||
else:
|
||||
line = self.parent.cpuFormat.split('$ccpu')[0]
|
||||
line = self.parent.uptimeFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpu0.setText(text)
|
||||
if (self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[1]):
|
||||
line = self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] + cpuText + self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[1]
|
||||
self.parent.label_uptime.setText(text)
|
||||
elif (sourceName == "cpu/system/TotalLoad"):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
cpuText = "%5s" % (value)
|
||||
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
|
||||
if (self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[0]):
|
||||
line = self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] + cpuText + self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[1]
|
||||
else:
|
||||
line = self.parent.cpuFormat.split('$ccpu')[0]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpu0.setText(text)
|
||||
if (self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[1]):
|
||||
line = self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] + cpuText + self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[1]
|
||||
else:
|
||||
line = self.parent.cpuFormat.split('$ccpu')[1]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpu1.setText(text)
|
||||
else:
|
||||
line = self.parent.cpuFormat.split('$ccpu')[1]
|
||||
if (self.parent.cpuFormat.split('$cpu')[0] != self.parent.cpuFormat):
|
||||
line = self.parent.cpuFormat.split('$cpu')[0] + cpuText + self.parent.cpuFormat.split('$cpu')[1]
|
||||
else:
|
||||
line = self.parent.cpuFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpu.setText(text)
|
||||
elif ((str(sourceName)[:7] == "cpu/cpu") and (str(sourceName).split('/')[2] == "TotalLoad")):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
cpuText = "%5s" % (value)
|
||||
text = self.parent.formatLine.split('$LINE')[0] + cpuText + self.parent.formatLine.split('$LINE')[1]
|
||||
exec ('self.parent.label_coreCpu' + str(sourceName)[7] + '.setText(text)')
|
||||
elif (sourceName == "cpu/system/AverageClock"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
cpuclockText = "%4s" % (value)
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[0]):
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] + cpuclockText + self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[1]
|
||||
else:
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[0]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpuclock0.setText(text)
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[1]):
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] + cpuclockText + self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[1]
|
||||
else:
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[1]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpuclock1.setText(text)
|
||||
else:
|
||||
if (self.parent.cpuclockFormat.split('$cpucl')[0] != self.parent.cpuclockFormat):
|
||||
line = self.parent.cpuclockFormat.split('$cpucl')[0] + cpuclockText + self.parent.cpuclockFormat.split('$cpucl')[1]
|
||||
else:
|
||||
line = self.parent.cpuclockFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpuclock.setText(text)
|
||||
elif ((str(sourceName)[:7] == "cpu/cpu") and (str(sourceName).split('/')[2] == "clock")):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
cpuclockText = "%4s" % (value)
|
||||
text = self.parent.formatLine.split('$LINE')[0] + cpuclockText + self.parent.formatLine.split('$LINE')[1]
|
||||
exec ('self.parent.label_coreCpuclock' + str(sourceName)[7] + '.setText(text)')
|
||||
elif (sourceName == "network/interfaces/"+self.parent.netdev+"/transmitter/data"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
up_speed = "%4s" % (value)
|
||||
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
|
||||
line = '/' + up_speed + self.parent.netFormat.split('$net')[1]
|
||||
else:
|
||||
line = ''
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpu1.setText(text)
|
||||
else:
|
||||
if (self.parent.cpuFormat.split('$cpu')[0] != self.parent.cpuFormat):
|
||||
line = self.parent.cpuFormat.split('$cpu')[0] + cpuText + self.parent.cpuFormat.split('$cpu')[1]
|
||||
self.parent.label_netUp.setText(text)
|
||||
elif (sourceName == "network/interfaces/"+self.parent.netdev+"/receiver/data"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
down_speed = "%4s" % (value)
|
||||
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
|
||||
line = self.parent.netFormat.split('$net')[0] + down_speed
|
||||
else:
|
||||
line = self.parent.cpuFormat
|
||||
line = self.parent.netFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpu.setText(text)
|
||||
elif ((str(sourceName)[:7] == "cpu/cpu") and (str(sourceName).split('/')[2] == "TotalLoad")):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
cpuText = "%5s" % (value)
|
||||
text = self.parent.formatLine.split('$LINE')[0] + cpuText + self.parent.formatLine.split('$LINE')[1]
|
||||
exec ('self.parent.label_coreCpu' + str(sourceName)[7] + '.setText(text)')
|
||||
elif (sourceName == "cpu/system/AverageClock"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
cpuclockText = "%4s" % (value)
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[0]):
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] + cpuclockText + self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[1]
|
||||
self.parent.label_netDown.setText(text)
|
||||
# update network device
|
||||
self.parent.updateNetdev = self.parent.updateNetdev + 1
|
||||
if (self.parent.updateNetdev == 100):
|
||||
self.parent.updateNetdev = 0
|
||||
if (self.parent.netNonFormat.split('@@')[0] == self.parent.netNonFormat):
|
||||
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent)
|
||||
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent)
|
||||
self.parent.setupNetdev()
|
||||
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent, self.parent.interval)
|
||||
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent, self.parent.interval)
|
||||
if (self.parent.netNonFormat.split('$netdev')[0] != self.parent.netNonFormat):
|
||||
self.parent.netFormat = self.parent.netNonFormat.split('$netdev')[0] + self.parent.netdev + self.parent.netNonFormat.split('$netdev')[1]
|
||||
else:
|
||||
self.parent.netFormat = self.parent.netNonFormat
|
||||
elif (sourceName == self.parent.tempdev):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
tempText = "%4s" % (value)
|
||||
if (self.parent.tempFormat.split('$temp')[0] != self.parent.tempFormat):
|
||||
line = self.parent.tempFormat.split('$temp')[0] + tempText + self.parent.tempFormat.split('$temp')[1]
|
||||
else:
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[0]
|
||||
line = self.parent.tempFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpuclock0.setText(text)
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[1]):
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] + cpuclockText + self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[1]
|
||||
self.parent.label_temp.setText(text)
|
||||
elif (str(sourceName).split('/')[0] == "partitions"):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
hddText = "%5s" % (value)
|
||||
text = self.parent.formatLine.split('$LINE')[0] + hddText + self.parent.formatLine.split('$LINE')[1]
|
||||
exec ('self.parent.label_hdd_' + ''.join(str(sourceName).split('/')[1:-1]) + '.setText(text)')
|
||||
elif (sourceName == "mem/physical/free"):
|
||||
self.parent.mem_free = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/physical/used"):
|
||||
self.parent.mem_uf = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/physical/application"):
|
||||
if (self.parent.memInMb):
|
||||
mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0]
|
||||
mem = "%5s" % (mem)
|
||||
if (self.parent.memFormat.split('$memmb')[0] != self.parent.memFormat):
|
||||
line = self.parent.memFormat.split('$memmb')[0] + mem + self.parent.memFormat.split('$memmb')[1]
|
||||
else:
|
||||
line = self.parent.memFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_mem.setText(text)
|
||||
else:
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[1]
|
||||
self.parent.mem_used = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/swap/free"):
|
||||
self.parent.swap_free = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/swap/used"):
|
||||
if (self.parent.swapInMb):
|
||||
mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0]
|
||||
mem = "%5s" % (mem)
|
||||
if (self.parent.swapFormat.split('$swapmb')[0] != self.parent.swapFormat):
|
||||
line = self.parent.swapFormat.split('$swapmb')[0] + mem + self.parent.swapFormat.split('$swapmb')[1]
|
||||
else:
|
||||
line = self.parent.swapFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_swap.setText(text)
|
||||
else:
|
||||
self.parent.swap_used = float(data[QString(u'value')])
|
||||
elif (sourceName == "gpu"):
|
||||
value = str(data[QString(u'GPU')])
|
||||
gpuText = "%4s" % (value)
|
||||
if (self.parent.gpuFormat.split('$gpu')[0] != self.parent.gpuFormat):
|
||||
line = self.parent.gpuFormat.split('$gpu')[0] + gpuText + self.parent.gpuFormat.split('$gpu')[1]
|
||||
else:
|
||||
line = self.parent.gpuFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpuclock1.setText(text)
|
||||
else:
|
||||
if (self.parent.cpuclockFormat.split('$cpucl')[0] != self.parent.cpuclockFormat):
|
||||
line = self.parent.cpuclockFormat.split('$cpucl')[0] + cpuclockText + self.parent.cpuclockFormat.split('$cpucl')[1]
|
||||
self.parent.label_gpu.setText(text)
|
||||
elif (sourceName == "gputemp"):
|
||||
value = str(data[QString(u'GPUTemp')])
|
||||
gputempText = "%4s" % (value)
|
||||
if (self.parent.gputempFormat.split('$gputemp')[0] != self.parent.gputempFormat):
|
||||
line = self.parent.gputempFormat.split('$gputemp')[0] + gputempText + self.parent.gputempFormat.split('$gputemp')[1]
|
||||
else:
|
||||
line = self.parent.cpuclockFormat
|
||||
line = self.parent.gputempFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpuclock.setText(text)
|
||||
elif ((str(sourceName)[:7] == "cpu/cpu") and (str(sourceName).split('/')[2] == "clock")):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
cpuclockText = "%4s" % (value)
|
||||
text = self.parent.formatLine.split('$LINE')[0] + cpuclockText + self.parent.formatLine.split('$LINE')[1]
|
||||
exec ('self.parent.label_coreCpuclock' + str(sourceName)[7] + '.setText(text)')
|
||||
elif (sourceName == "network/interfaces/"+self.parent.netdev+"/transmitter/data"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
up_speed = "%4s" % (value)
|
||||
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
|
||||
line = '/' + up_speed + self.parent.netFormat.split('$net')[1]
|
||||
else:
|
||||
line = ''
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_netUp.setText(text)
|
||||
elif (sourceName == "network/interfaces/"+self.parent.netdev+"/receiver/data"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
down_speed = "%4s" % (value)
|
||||
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
|
||||
line = self.parent.netFormat.split('$net')[0] + down_speed
|
||||
else:
|
||||
line = self.parent.netFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_netDown.setText(text)
|
||||
# update network device
|
||||
self.parent.updateNetdev = self.parent.updateNetdev + 1
|
||||
if (self.parent.updateNetdev == 100):
|
||||
self.parent.updateNetdev = 0
|
||||
if (self.parent.netNonFormat.split('@@')[0] == self.parent.netNonFormat):
|
||||
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent)
|
||||
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent)
|
||||
self.parent.setupNetdev()
|
||||
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent, self.parent.interval)
|
||||
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent, self.parent.interval)
|
||||
if (self.parent.netNonFormat.split('$netdev')[0] != self.parent.netNonFormat):
|
||||
self.parent.netFormat = self.parent.netNonFormat.split('$netdev')[0] + self.parent.netdev + self.parent.netNonFormat.split('$netdev')[1]
|
||||
self.parent.label_gputemp.setText(text)
|
||||
elif (sourceName == "hddtemp"):
|
||||
value = str(data[QString(self.parent.hddtempFormat.split('@@')[1])])
|
||||
hddtempText = "%4s" % (value)
|
||||
if (self.parent.hddtempFormat.split('@@')[0] != self.parent.hddtempFormat):
|
||||
line = self.parent.hddtempFormat.split('@@')[0] + hddtempText + self.parent.hddtempFormat.split('@@')[2]
|
||||
else:
|
||||
self.parent.netFormat = self.parent.netNonFormat
|
||||
elif (sourceName == self.parent.tempdev):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
tempText = "%4s" % (value)
|
||||
if (self.parent.tempFormat.split('$temp')[0] != self.parent.tempFormat):
|
||||
line = self.parent.tempFormat.split('$temp')[0] + tempText + self.parent.tempFormat.split('$temp')[1]
|
||||
else:
|
||||
line = self.parent.tempFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_temp.setText(text)
|
||||
elif (str(sourceName).split('/')[0] == "partitions"):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
hddText = "%5s" % (value)
|
||||
text = self.parent.formatLine.split('$LINE')[0] + hddText + self.parent.formatLine.split('$LINE')[1]
|
||||
exec ('self.parent.label_hdd_' + ''.join(str(sourceName).split('/')[1:-1]) + '.setText(text)')
|
||||
elif (sourceName == "mem/physical/free"):
|
||||
self.parent.mem_free = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/physical/used"):
|
||||
self.parent.mem_uf = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/physical/application"):
|
||||
if (self.parent.memInMb):
|
||||
mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0]
|
||||
mem = "%5s" % (mem)
|
||||
if (self.parent.memFormat.split('$memmb')[0] != self.parent.memFormat):
|
||||
line = self.parent.memFormat.split('$memmb')[0] + mem + self.parent.memFormat.split('$memmb')[1]
|
||||
else:
|
||||
line = self.parent.memFormat
|
||||
line = self.parent.hddtempFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_mem.setText(text)
|
||||
else:
|
||||
self.parent.mem_used = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/swap/free"):
|
||||
self.parent.swap_free = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/swap/used"):
|
||||
if (self.parent.swapInMb):
|
||||
mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0]
|
||||
mem = "%5s" % (mem)
|
||||
if (self.parent.swapFormat.split('$swapmb')[0] != self.parent.swapFormat):
|
||||
line = self.parent.swapFormat.split('$swapmb')[0] + mem + self.parent.swapFormat.split('$swapmb')[1]
|
||||
else:
|
||||
line = self.parent.swapFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_swap.setText(text)
|
||||
else:
|
||||
self.parent.swap_used = float(data[QString(u'value')])
|
||||
self.parent.label_hddtemp.setText(text)
|
||||
except:
|
||||
pass
|
||||
|
@ -1,38 +0,0 @@
|
||||
import commands, time
|
||||
from PyQt4.QtCore import QThread
|
||||
|
||||
|
||||
|
||||
class GpuThread(QThread):
|
||||
def __init__(self, interval, gpudev):
|
||||
"""thread definition"""
|
||||
QThread.__init__(self)
|
||||
self.stopped = False
|
||||
self.interval = interval / 1000
|
||||
self.label_exit = 2
|
||||
self.gpudev = gpudev
|
||||
self.gpu = '----'
|
||||
|
||||
|
||||
def run(self):
|
||||
"""operating function"""
|
||||
while ((not self.stopped) and (self.label_exit > 0)):
|
||||
time.sleep(self.interval)
|
||||
# dirty hack
|
||||
self.label_exit = self.label_exit - 1
|
||||
if (self.gpudev == 'nvidia'):
|
||||
commandOut = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1")
|
||||
if (commandOut.split()[2] == 'N/A'):
|
||||
self.gpu = ' N/A'
|
||||
else:
|
||||
self.gpu = "%5s" % (str(round(float(commandOut.split()[2][:-1]), 1)))
|
||||
elif (self.gpudev == 'ati'):
|
||||
commandOut = commands.getoutput("aticonfig --od-getclocks | grep load | tail -n1")
|
||||
self.gpu = "%5s" % (str(round(float(commandOut.split()[3][:-1]), 1)))
|
||||
else:
|
||||
self.gpu = '-----'
|
||||
|
||||
|
||||
def stop(self):
|
||||
"""stop signal"""
|
||||
self.stopped = True
|
@ -1,35 +0,0 @@
|
||||
import commands, time, os
|
||||
from PyQt4.QtCore import QThread
|
||||
|
||||
|
||||
|
||||
class GpuTempThread(QThread):
|
||||
def __init__(self, interval, gpudev):
|
||||
"""thread definition"""
|
||||
QThread.__init__(self)
|
||||
self.stopped = False
|
||||
self.interval = interval / 1000
|
||||
self.label_exit = 2
|
||||
self.gpudev = gpudev
|
||||
self.gputemp = '----'
|
||||
|
||||
|
||||
def run(self):
|
||||
"""operating function"""
|
||||
while ((not self.stopped) and (self.label_exit > 0)):
|
||||
time.sleep(self.interval)
|
||||
# dirty hack
|
||||
self.label_exit = self.label_exit - 1
|
||||
if (self.gpudev == 'nvidia'):
|
||||
commandOut = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1")
|
||||
self.gputemp = "%4s" % (str(round(float(commandOut.split()[2]), 1)))
|
||||
elif (self.gpudev == 'ati'):
|
||||
commandOut = commands.getoutput("aticonfig --od-gettemperature | grep Temperature | tail -n1")
|
||||
self.gputemp = "%4s" % (str(round(float(commandOut.split()[4]), 1)))
|
||||
else:
|
||||
self.gputemp = '----'
|
||||
|
||||
|
||||
def stop(self):
|
||||
"""stop signal"""
|
||||
self.stopped = True
|
@ -1,29 +0,0 @@
|
||||
import commands, time
|
||||
from PyQt4.QtCore import QThread
|
||||
|
||||
|
||||
|
||||
class HddTempThread(QThread):
|
||||
def __init__(self, interval, hdd):
|
||||
"""thread definition"""
|
||||
QThread.__init__(self)
|
||||
self.stopped = False
|
||||
self.interval = interval / 1000
|
||||
self.label_exit = 2
|
||||
self.hdd = hdd
|
||||
self.hddtemp = '----'
|
||||
|
||||
|
||||
def run(self):
|
||||
"""operating function"""
|
||||
while ((not self.stopped) and (self.label_exit > 0)):
|
||||
time.sleep(self.interval)
|
||||
# dirty hack
|
||||
self.label_exit = self.label_exit - 1
|
||||
commandOut = commands.getoutput("hddtemp " + self.hdd)
|
||||
self.hddtemp = "%4s" % (str(round(float(commandOut.split(':')[2][:-3]), 1)))
|
||||
|
||||
|
||||
def stop(self):
|
||||
"""stop signal"""
|
||||
self.stopped = True
|
@ -9,7 +9,7 @@ from PyKDE4 import plasmascript
|
||||
from PyKDE4.plasma import Plasma
|
||||
import commands, os, time
|
||||
|
||||
import configaccepted
|
||||
import configdef
|
||||
import configwindow
|
||||
import dataengine
|
||||
import reinit
|
||||
@ -20,57 +20,42 @@ from util import *
|
||||
class pyTextWidget(plasmascript.Applet):
|
||||
def __init__(self, parent, args=None):
|
||||
"""widget definition"""
|
||||
plasmascript.Applet.__init__(self,parent)
|
||||
plasmascript.Applet.__init__(self, parent)
|
||||
|
||||
|
||||
def init(self):
|
||||
"""function to initializate widget"""
|
||||
self._name = str(self.package().metadata().pluginName())
|
||||
self.initTooltip()
|
||||
self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
|
||||
self.configAccepted = configaccepted.ConfigAccepted(self)
|
||||
|
||||
self.dataengine = dataengine.DataEngine(self)
|
||||
self.reinit = reinit.Reinit(self)
|
||||
|
||||
self.timer = QTimer()
|
||||
QObject.connect(self.timer, SIGNAL("timeout()"), self.updateLabel)
|
||||
|
||||
self.setupVar()
|
||||
self.reinit.reinit()
|
||||
|
||||
self.setHasConfigurationInterface(True)
|
||||
|
||||
|
||||
def createConfigurationInterface(self, parent):
|
||||
"""function to setup configuration window"""
|
||||
self.configpage = configwindow.ConfigWindow(self, self.settings)
|
||||
|
||||
font = QFont(str(self.settings.get('font_family', 'Terminus')), int(self.settings.get('font_size', 12)), 50)
|
||||
self.configpage.ui.spinBox_interval.setValue(int(self.settings.get('interval', 2000)))
|
||||
self.configpage.ui.fontComboBox.setCurrentFont(font)
|
||||
self.configpage.ui.spinBox_fontSize.setValue(int(self.settings.get('font_size', 12)))
|
||||
self.configpage.ui.kcolorcombo.setColor(QColor(str(self.settings.get('font_color', '#000000'))))
|
||||
font = str(self.settings.get('font_style', 'normal'))
|
||||
if (font == 'normal'):
|
||||
self.configpage.ui.comboBox_style.setCurrentIndex(0)
|
||||
else:
|
||||
self.configpage.ui.comboBox_style.setCurrentIndex(1)
|
||||
self.configpage.ui.spinBox_weight.setValue(int(self.settings.get('font_weight', 400)))
|
||||
for label in self.dict_orders.keys():
|
||||
exec ('bool = self.' + self.dict_orders[label] + 'Bool')
|
||||
if (bool == 1):
|
||||
self.configpage.checkboxes[self.dict_orders[label]].setCheckState(2)
|
||||
self.configpage.sliders[self.dict_orders[label]].setValue(self.label_order.find(label)+1)
|
||||
else:
|
||||
self.configpage.checkboxes[self.dict_orders[label]].setCheckState(0)
|
||||
if (self.dict_orders[label] == 'net'):
|
||||
self.configpage.ui.comboBox_numNet.setCurrentIndex(int(self.settings.get('num_dev', 0)))
|
||||
self.configpage.lineedits[self.dict_orders[label]].setText(str(self.settings.get(self.dict_orders[label] + 'NonFormat', self.dict_defFormat[self.dict_orders[label]])))
|
||||
else:
|
||||
self.configpage.lineedits[self.dict_orders[label]].setText(str(self.settings.get(self.dict_orders[label] + 'Format', self.dict_defFormat[self.dict_orders[label]])))
|
||||
if (self.dict_orders[label] == 'bat'):
|
||||
self.configpage.ui.lineEdit_batdev.setText(str(self.settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity')))
|
||||
self.configpage.ui.lineEdit_acdev.setText(str(self.settings.get('ac_device', '/sys/class/power_supply/AC/online')))
|
||||
|
||||
# add config page
|
||||
page = parent.addPage(self.configpage, i18n(self.name()))
|
||||
page.setIcon(KIcon(self.icon()))
|
||||
|
||||
parent.okClicked.connect(self.configAccepted.configAccepted)
|
||||
self.configpage = configwindow.ConfigWindow(self)
|
||||
self.configdef = configdef.ConfigDefinition(self, self.configpage)
|
||||
self.configdef.createConfigurationInterface(parent)
|
||||
|
||||
|
||||
def initTooltip(self):
|
||||
"""function to create tooltip"""
|
||||
self.tooltip = Plasma.ToolTipContent()
|
||||
self.tooltip.setMainText("PyTetMonitor")
|
||||
self.tooltip.setSubText('')
|
||||
Plasma.ToolTipManager.self().registerWidget(self.applet)
|
||||
# show tooltip
|
||||
#Plasma.ToolTipManager.self().setContent(self.applet, self.tooltip)
|
||||
|
||||
|
||||
def setupNetdev(self):
|
||||
@ -102,12 +87,6 @@ class pyTextWidget(plasmascript.Applet):
|
||||
# setup temperature device
|
||||
commandOut = commands.getoutput("sensors | grep Physical -B2")
|
||||
self.tempdev = "lmsensors/"+commandOut.split("\n")[0]+"/"+'_'.join(commandOut.split("\n")[2].split(":")[0].split())
|
||||
# setup gpu device
|
||||
commandOut = commands.getoutput("lspci")
|
||||
if (commandOut.lower().find('nvidia') > -1):
|
||||
self.gpudev = 'nvidia'
|
||||
elif (commandOut.lower().find('radeon') > -1):
|
||||
self.gpudev = 'ati'
|
||||
|
||||
# create dictionaries
|
||||
self.dict_orders = {'6':'bat', '1':'cpu', '7':'cpuclock', '9':'gpu', 'a':'gputemp',
|
||||
@ -124,24 +103,13 @@ class pyTextWidget(plasmascript.Applet):
|
||||
plasmascript.Applet.showConfigurationInterface(self)
|
||||
|
||||
|
||||
def showTooltip(self, text):
|
||||
"""function to create and set tooltip"""
|
||||
tooltip = Plasma.ToolTipContent()
|
||||
tooltip.setImage(KIcon(self.icon()))
|
||||
tooltip.setSubText(text)
|
||||
tooltip.setAutohide(False)
|
||||
Plasma.ToolTipManager.self().setContent(self.applet, tooltip)
|
||||
Plasma.ToolTipManager.self().registerWidget(self.applet)
|
||||
|
||||
|
||||
def startPolling(self):
|
||||
try:
|
||||
self.timer.start()
|
||||
QObject.connect(self.timer, SIGNAL("timeout()"), self.updateLabel)
|
||||
self.updateLabel()
|
||||
self.showTooltip('')
|
||||
self.tooltip.setSubText('')
|
||||
except Exception as (strerror):
|
||||
self.showTooltip(str(strerror))
|
||||
self.tooltip.setSubText(str(strerror))
|
||||
self.label_error = Plasma.Label(self.applet)
|
||||
self.label_error.setText('<font color="red">ERROR</font>')
|
||||
self.layout.addItem(self.label_error)
|
||||
@ -149,19 +117,10 @@ class pyTextWidget(plasmascript.Applet):
|
||||
|
||||
def updateLabel(self):
|
||||
"""function to update label"""
|
||||
if (self.gpuBool == 1):
|
||||
self.gpuText()
|
||||
self.gpuChecker.label_exit = 2
|
||||
if (self.gputempBool == 1):
|
||||
self.gputempText()
|
||||
self.gpuTempChecker.label_exit = 2
|
||||
if ((self.memBool == 1) and (self.memInMb == False)):
|
||||
self.memText()
|
||||
if ((self.swapBool == 1) and (self.swapInMb == False)):
|
||||
self.swapText()
|
||||
if (self.hddtempBool == 1):
|
||||
self.hddtempText()
|
||||
self.hddTempChecker.label_exit = 2
|
||||
if (self.batBool == 1):
|
||||
self.batText()
|
||||
|
||||
@ -193,36 +152,6 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.label_bat.setText(text)
|
||||
|
||||
|
||||
def gpuText(self):
|
||||
"""function to set gpu text"""
|
||||
if (self.gpuFormat.split('$gpu')[0] != self.gpuFormat):
|
||||
line = self.gpuFormat.split('$gpu')[0] + self.gpuChecker.gpu + self.gpuFormat.split('$gpu')[1]
|
||||
else:
|
||||
line = self.gpuFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_gpu.setText(text)
|
||||
|
||||
|
||||
def gputempText(self):
|
||||
"""function to set gpu temperature text"""
|
||||
if (self.gputempFormat.split('$gputemp')[0] != self.gputempFormat):
|
||||
line = self.gputempFormat.split('$gputemp')[0] + self.gpuTempChecker.gputemp + self.gputempFormat.split('$gputemp')[1]
|
||||
else:
|
||||
line = self.gputempFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_gputemp.setText(text)
|
||||
|
||||
|
||||
def hddtempText(self):
|
||||
"""function to set hdd temperature text"""
|
||||
if (self.hddtempFormat.split('@@')[0] != self.hddtempFormat):
|
||||
line = self.hddtempFormat.split('@@')[0] + self.hddTempChecker.hddtemp + self.hddtempFormat.split('@@')[2]
|
||||
else:
|
||||
line = self.hddtempFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_hddtemp.setText(text)
|
||||
|
||||
|
||||
def memText(self):
|
||||
"""function to set mem text"""
|
||||
full = self.mem_uf + self.mem_free
|
||||
|
@ -1,9 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyKDE4.plasma import Plasma
|
||||
import config
|
||||
import gpuchecker
|
||||
import gputempchecker
|
||||
import hddtempchecker
|
||||
|
||||
|
||||
|
||||
@ -14,22 +13,22 @@ class Reinit():
|
||||
|
||||
def reinit(self):
|
||||
"""function to reinitializate widget"""
|
||||
self.parent.settings = config.Config(self.parent)
|
||||
self.parent.interval = int(self.parent.settings.get('interval', 2000))
|
||||
self.parent.font_family = str(self.parent.settings.get('font_family', 'Terminus'))
|
||||
self.parent.font_size = int(self.parent.settings.get('font_size', 12))
|
||||
self.parent.font_color = str(self.parent.settings.get('font_color', '#000000'))
|
||||
self.parent.font_style = str(self.parent.settings.get('font_style', 'normal'))
|
||||
self.parent.font_weight = int(self.parent.settings.get('font_weight', 400))
|
||||
settings = config.Config(self.parent)
|
||||
self.parent.interval = settings.get('interval', 2000).toInt()[0]
|
||||
self.parent.font_family = str(settings.get('font_family', 'Terminus'))
|
||||
self.parent.font_size = settings.get('font_size', 12).toInt()[0]
|
||||
self.parent.font_color = str(settings.get('font_color', '#000000'))
|
||||
self.parent.font_style = str(settings.get('font_style', 'normal'))
|
||||
self.parent.font_weight = settings.get('font_weight', 400).toInt()[0]
|
||||
self.parent.formatLine = "<pre><p align=\"center\"><span style=\" font-family:'" + self.parent.font_family + "'; font-style:" + self.parent.font_style
|
||||
self.parent.formatLine = self.parent.formatLine + "; font-size:" + str(self.parent.font_size) + "pt; font-weight:" + str(self.parent.font_weight)
|
||||
self.parent.formatLine = self.parent.formatLine + "; color:" + self.parent.font_color + ";\">$LINE</span></p></pre>"
|
||||
self.parent.label_order = str(self.parent.settings.get('label_order', '1345'))
|
||||
self.parent.label_order = str(settings.get('label_order', '1345'))
|
||||
for label in self.parent.dict_orders.values():
|
||||
if ((label == 'cpu') or (label == 'mem') or (label == 'swap') or (label == 'net')):
|
||||
exec ('self.parent.' + label + 'Bool = int(self.parent.settings.get("' + label + 'Bool", 1))')
|
||||
exec ('self.parent.' + label + 'Bool = int(settings.get("' + label + 'Bool", 1))')
|
||||
else:
|
||||
exec ('self.parent.' + label + 'Bool = int(self.parent.settings.get("' + label + 'Bool", 0))')
|
||||
exec ('self.parent.' + label + 'Bool = int(settings.get("' + label + 'Bool", 0))')
|
||||
# small function for update if errors exist
|
||||
summ = 0
|
||||
for label in self.parent.dict_orders.values():
|
||||
@ -40,14 +39,14 @@ class Reinit():
|
||||
exec ('self.parent.' + label + 'Bool = 1')
|
||||
else:
|
||||
exec ('self.parent.' + label + 'Bool = 0')
|
||||
exec ('self.parent.settings.set("' + label + 'Bool", self.parent.' + label + 'Bool)')
|
||||
exec ('settings.set("' + label + 'Bool", self.parent.' + label + 'Bool)')
|
||||
self.parent.label_order = '1345'
|
||||
self.parent.settings.set('label_order', self.parent.label_order)
|
||||
settings.set('label_order', self.parent.label_order)
|
||||
|
||||
for order in self.parent.label_order:
|
||||
if (order == "1"):
|
||||
if (self.parent.cpuBool == 1):
|
||||
self.parent.cpuFormat = str(self.parent.settings.get('cpuFormat', '[cpu: $cpu%]'))
|
||||
self.parent.cpuFormat = str(settings.get('cpuFormat', '[cpu: $cpu%]'))
|
||||
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
|
||||
self.parent.label_cpu0 = Plasma.Label(self.parent.applet)
|
||||
self.parent.label_cpu1 = Plasma.Label(self.parent.applet)
|
||||
@ -81,7 +80,7 @@ class Reinit():
|
||||
self.parent.layout.addItem(self.parent.label_cpu)
|
||||
elif (order == "2"):
|
||||
if (self.parent.tempBool == 1):
|
||||
self.parent.tempFormat = str(self.parent.settings.get('tempFormat', '[temp: $temp°C]'))
|
||||
self.parent.tempFormat = str(settings.get('tempFormat', '[temp: $temp°C]'))
|
||||
self.parent.label_temp = Plasma.Label(self.parent.applet)
|
||||
if (self.parent.tempFormat.split('$temp')[0] != self.parent.tempFormat):
|
||||
line = self.parent.tempFormat.split('$temp')[0] + '----' + self.parent.tempFormat.split('$temp')[1]
|
||||
@ -92,7 +91,7 @@ class Reinit():
|
||||
self.parent.layout.addItem(self.parent.label_temp)
|
||||
elif (order == "3"):
|
||||
if (self.parent.memBool == 1):
|
||||
self.parent.memFormat = str(self.parent.settings.get('memFormat', '[mem: $mem%]'))
|
||||
self.parent.memFormat = str(settings.get('memFormat', '[mem: $mem%]'))
|
||||
if (self.parent.memFormat.split('$memmb')[0] != self.parent.memFormat):
|
||||
self.parent.memInMb = True
|
||||
text = self.parent.formatLine.split('$LINE')[0] + self.parent.memFormat.split('$memmb')[0] + '-----' + self.parent.memFormat.split('$memmb')[1] + self.parent.formatLine.split('$LINE')[1]
|
||||
@ -110,7 +109,7 @@ class Reinit():
|
||||
self.parent.layout.addItem(self.parent.label_mem)
|
||||
elif (order == "4"):
|
||||
if (self.parent.swapBool == 1):
|
||||
self.parent.swapFormat = str(self.parent.settings.get('swapFormat', '[swap: $swap%]'))
|
||||
self.parent.swapFormat = str(settings.get('swapFormat', '[swap: $swap%]'))
|
||||
if (self.parent.swapFormat.split('$swapmb')[0] != self.parent.swapFormat):
|
||||
self.parent.swapInMb = True
|
||||
text = self.parent.formatLine.split('$LINE')[0] + self.parent.swapFormat.split('$swapmb')[0] + '-----' + self.parent.swapFormat.split('$swapmb')[1] + self.parent.formatLine.split('$LINE')[1]
|
||||
@ -127,12 +126,12 @@ class Reinit():
|
||||
self.parent.layout.addItem(self.parent.label_swap)
|
||||
elif (order == "5"):
|
||||
if (self.parent.netBool == 1):
|
||||
self.parent.netNonFormat = str(self.parent.settings.get('netNonFormat', '[net: $netKB/s]'))
|
||||
self.parent.netNonFormat = str(settings.get('netNonFormat', '[net: $netKB/s]'))
|
||||
if (self.parent.netNonFormat.split('@@')[0] != self.parent.netNonFormat):
|
||||
self.parent.netdev = self.parent.netNonFormat.split('@@')[1]
|
||||
self.parent.netNonFormat = self.parent.netNonFormat.split('@@')[0] + self.parent.netNonFormat.split('@@')[2]
|
||||
else:
|
||||
self.parent.num_dev = int(self.parent.settings.get('num_dev', 0))
|
||||
self.parent.num_dev = int(settings.get('num_dev', 0))
|
||||
self.parent.setupNetdev()
|
||||
if (self.parent.netNonFormat.split('$netdev')[0] != self.parent.netNonFormat):
|
||||
self.parent.netFormat = self.parent.netNonFormat.split('$netdev')[0] + self.parent.netdev + self.parent.netNonFormat.split('$netdev')[1]
|
||||
@ -156,9 +155,9 @@ class Reinit():
|
||||
self.parent.layout.addItem(self.parent.label_netUp)
|
||||
elif (order == "6"):
|
||||
if (self.parent.batBool == 1):
|
||||
self.parent.batFormat = str(self.parent.settings.get('batFormat', '[bat: $bat%$ac]'))
|
||||
self.parent.battery_device= str(self.parent.settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity'))
|
||||
self.parent.ac_device = str(self.parent.settings.get('ac_device', '/sys/class/power_supply/AC/online'))
|
||||
self.parent.batFormat = str(settings.get('batFormat', '[bat: $bat%$ac]'))
|
||||
self.parent.battery_device= str(settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity'))
|
||||
self.parent.ac_device = str(settings.get('ac_device', '/sys/class/power_supply/AC/online'))
|
||||
self.parent.label_bat = Plasma.Label(self.parent.applet)
|
||||
line = self.parent.batFormat
|
||||
if (line.split('$ac')[0] != line):
|
||||
@ -170,7 +169,7 @@ class Reinit():
|
||||
self.parent.layout.addItem(self.parent.label_bat)
|
||||
elif (order == "7"):
|
||||
if (self.parent.cpuclockBool == 1):
|
||||
self.parent.cpuclockFormat = str(self.parent.settings.get('cpuclockFormat', '[mhz: $cpucl]'))
|
||||
self.parent.cpuclockFormat = str(settings.get('cpuclockFormat', '[mhz: $cpucl]'))
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
|
||||
self.parent.label_cpuclock0 = Plasma.Label(self.parent.applet)
|
||||
self.parent.label_cpuclock1 = Plasma.Label(self.parent.applet)
|
||||
@ -204,7 +203,7 @@ class Reinit():
|
||||
self.parent.layout.addItem(self.parent.label_cpuclock)
|
||||
elif (order == "8"):
|
||||
if (self.parent.uptimeBool == 1):
|
||||
self.parent.uptimeFormat = str(self.parent.settings.get('uptimeFormat', '[uptime: $uptime]'))
|
||||
self.parent.uptimeFormat = str(settings.get('uptimeFormat', '[uptime: $uptime]'))
|
||||
self.parent.label_uptime = Plasma.Label(self.parent.applet)
|
||||
if (self.parent.uptimeFormat.split('$uptime')[0] != self.parent.uptimeFormat):
|
||||
line = self.parent.uptimeFormat.split('$uptime')[0] + '---d--h--m' + self.parent.uptimeFormat.split('$uptime')[1]
|
||||
@ -215,7 +214,7 @@ class Reinit():
|
||||
self.parent.layout.addItem(self.parent.label_uptime)
|
||||
elif (order == "9"):
|
||||
if (self.parent.gpuBool == 1):
|
||||
self.parent.gpuFormat = str(self.parent.settings.get('gpuFormat', '[gpu: $gpu%]'))
|
||||
self.parent.gpuFormat = str(settings.get('gpuFormat', '[gpu: $gpu%]'))
|
||||
self.parent.label_gpu = Plasma.Label(self.parent.applet)
|
||||
if (self.parent.gpuFormat.split('$gpu')[0] != self.parent.gpuFormat):
|
||||
line = self.parent.gpuFormat.split('$gpu')[0] + '-----' + self.parent.gpuFormat.split('$gpu')[1]
|
||||
@ -226,7 +225,7 @@ class Reinit():
|
||||
self.parent.layout.addItem(self.parent.label_gpu)
|
||||
elif (order == "a"):
|
||||
if (self.parent.gputempBool == 1):
|
||||
self.parent.gputempFormat = str(self.parent.settings.get('gputempFormat', '[gpu temp: $gputemp°C]'))
|
||||
self.parent.gputempFormat = str(settings.get('gputempFormat', '[gpu temp: $gputemp°C]'))
|
||||
self.parent.label_gputemp = Plasma.Label(self.parent.applet)
|
||||
if (self.parent.gputempFormat.split('$gputemp')[0] != self.parent.gputempFormat):
|
||||
line = self.parent.gputempFormat.split('$gputemp')[0] + '----' + self.parent.gputempFormat.split('$gputemp')[1]
|
||||
@ -237,7 +236,7 @@ class Reinit():
|
||||
self.parent.layout.addItem(self.parent.label_gputemp)
|
||||
elif (order == "b"):
|
||||
if (self.parent.hddBool == 1):
|
||||
self.parent.hddFormat = str(self.parent.settings.get('hddFormat', '[hdd: @@/@@%]'))
|
||||
self.parent.hddFormat = str(settings.get('hddFormat', '[hdd: @@/@@%]'))
|
||||
if (self.parent.hddFormat.split('@@')[0] != self.parent.hddFormat):
|
||||
self.parent.mountPoints = self.parent.hddFormat.split('@@')[1].split(';')
|
||||
line = self.parent.hddFormat.split('@@')[0]
|
||||
@ -262,7 +261,7 @@ class Reinit():
|
||||
self.parent.layout.addItem(self.parent.label_hdd0)
|
||||
elif (order == "c"):
|
||||
if (self.parent.hddtempBool == 1):
|
||||
self.parent.hddtempFormat = str(self.parent.settings.get('hddtempFormat', '[hdd temp: @@/dev/sda@@°C]'))
|
||||
self.parent.hddtempFormat = str(settings.get('hddtempFormat', '[hdd temp: @@/dev/sda@@°C]'))
|
||||
self.parent.label_hddtemp = Plasma.Label(self.parent.applet)
|
||||
if (self.parent.hddtempFormat.split('@@')[0] != self.parent.hddtempFormat):
|
||||
line = self.parent.hddtempFormat.split('@@')[0] + '----' + self.parent.hddtempFormat.split('@@')[2]
|
||||
@ -277,17 +276,8 @@ class Reinit():
|
||||
self.parent.setBackgroundHints(Plasma.Applet.DefaultBackground)
|
||||
self.parent.resize(10,10)
|
||||
|
||||
# create threading
|
||||
# create dataengines
|
||||
self.parent.dataengine.connectToEngine()
|
||||
self.parent.timer = QTimer()
|
||||
|
||||
self.parent.timer.setInterval(self.parent.interval)
|
||||
if (self.parent.gpuBool == 1):
|
||||
self.parent.gpuChecker = gpuchecker.GpuThread(self.parent.interval, self.parent.gpudev)
|
||||
self.parent.gpuChecker.start()
|
||||
if (self.parent.gputempBool == 1):
|
||||
self.parent.gpuTempChecker = gputempchecker.GpuTempThread(self.parent.interval, self.parent.gpudev)
|
||||
self.parent.gpuTempChecker.start()
|
||||
if (self.parent.hddtempBool ==1):
|
||||
self.parent.hddTempChecker = hddtempchecker.HddTempThread(self.parent.interval, self.parent.hddtempFormat.split('@@')[1])
|
||||
self.parent.hddTempChecker.start()
|
||||
self.parent.startPolling()
|
||||
|
@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from shutil import copyfile
|
||||
from PyKDE4.kdecore import *
|
||||
import os
|
||||
|
||||
|
||||
|
||||
@ -10,16 +10,19 @@ class Util():
|
||||
def __init__(self, applet):
|
||||
self.applet = applet
|
||||
|
||||
|
||||
def createDirectory(self, name):
|
||||
if not os.path.isdir(name):
|
||||
try:
|
||||
os.mkdir(name)
|
||||
except:
|
||||
print 'Failed to create directory: ' + name
|
||||
|
||||
|
||||
|
||||
def kdeHome(self):
|
||||
return unicode(KGlobal.dirs().localkdedir())
|
||||
|
||||
|
||||
|
||||
def createNotifyrc(self):
|
||||
print '[%s] creating notifyrc' % (self.applet._name)
|
||||
self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name)
|
||||
@ -28,9 +31,10 @@ class Util():
|
||||
destination = self.kdeHome() + 'share/apps/%s/%s.notifyrc' % (self.applet._name, self.applet._name)
|
||||
copyfile(source, destination)
|
||||
|
||||
|
||||
def createConfig(self):
|
||||
self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name)
|
||||
|
||||
source = self.applet.package().path() + 'contents/misc/%s.ini' % self.applet._name
|
||||
destination = self.kdeHome() + 'share/apps/%s/%s.ini' % (self.applet._name, self.applet._name)
|
||||
copyfile(source, destination)
|
||||
copyfile(source, destination)
|
||||
|
@ -1,17 +1,19 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Py Text Monitor
|
||||
Type=Service
|
||||
ServiceTypes=Plasma/Applet
|
||||
Type=Service
|
||||
Icon=utilities-system-monitor
|
||||
|
||||
X-Plasma-API=python
|
||||
X-Plasma-MainScript=code/main.py
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alexeev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=py-text-monitor
|
||||
X-KDE-PluginInfo-Version=1.3.1
|
||||
X-KDE-PluginInfo-Version=1.3.2
|
||||
X-KDE-PluginInfo-Website=http://kde-look.org/
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
||||
|
Loading…
Reference in New Issue
Block a user