From f08ccbd45d9d0121cfde9dfa5fee022c75d16dfa Mon Sep 17 00:00:00 2001 From: arcan1s Date: Thu, 23 May 2013 01:49:05 +0400 Subject: [PATCH] New release (TRUE!) 1.3.1: * refactoring * bug fixes + multithreads - creating threads for gpu and hdd --- README | 8 +- pytextmonitor-1.3.1.plasmoid | Bin 13520 -> 16773 bytes source/contents/code/configaccepted.py | 137 ++++++ source/contents/code/dataengine.py | 195 ++++++++ source/contents/code/gpuchecker.py | 38 ++ source/contents/code/gputempchecker.py | 35 ++ source/contents/code/hddtempchecker.py | 29 ++ source/contents/code/main.py | 646 +------------------------ source/contents/code/reinit.py | 293 +++++++++++ source/contents/code/util.py | 36 -- 10 files changed, 757 insertions(+), 660 deletions(-) create mode 100644 source/contents/code/configaccepted.py create mode 100644 source/contents/code/dataengine.py create mode 100644 source/contents/code/gpuchecker.py create mode 100644 source/contents/code/gputempchecker.py create mode 100644 source/contents/code/hddtempchecker.py create mode 100644 source/contents/code/reinit.py delete mode 100644 source/contents/code/util.py diff --git a/README b/README index db3e9f4..0ec3a52 100644 --- a/README +++ b/README @@ -10,17 +10,19 @@ For edited output you must open Settings window and setup output format in lines label "$ccpu" means load CPU for each core, % label "$cpucl" - average cpu clock, MHz label "$ccpucl" - cpu clock for each core, MHz - label "$temp" - average temperature in system (if doesn't work please let me know) - label "$gpu" -GPU usage, % + label "$temp" - average temperature in system + label "$gpu" - GPU usage, %. `aticonfig` or `nvidia-smi` must be installed + label "$gputemp" - GPU temperature. `aticonfig` or `nvidia-smi` must be installed label "$mem" - usage memory, % label "$memmb" - usage memory, MB label "$swap" - swap, % label "$swapmb" - swap, MB - label "@@/@@" (in hdd label) - mount point ('/' in example) usage, %. Separator for mount points list is ';', for example "@@/;/home;/mnt/global@@" + label "@@/@@" (in hdd label) - mount point ('/' in example) usage, %. Separator for mount points list is ';', for example "@@/;/home;/mnt/global@@". `hddtemp` must be installed label "@@/dev/sda@@" (in hddtemp label) - HDD ('/dev/sda' in example) temperature label "$net" - download and upload speed, KB/s. You may also specify the number of devices (1 or 2) - without their names. And you may specify network device: something like @@eth0@@ label "$netdev" - current network device label "$bat" - battery charge, %. Battery device may be set below. File ("/sys/class/power_supply/BAT0/capacity" by default) must contain only battery charge in percent label "$ac" - status AC device. Return (*) if AC device is online or ( ) if offline. AC device may be set below. FIle ("/sys/class/power_supply/AC/online" by default) must contain '1' if AC is online + 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. diff --git a/pytextmonitor-1.3.1.plasmoid b/pytextmonitor-1.3.1.plasmoid index aa9ca66692f5e295ac93b88454e439b4d46449cf..ec7889760f4e1a82c23acc00fade852de3f6cfcc 100644 GIT binary patch delta 11029 zcmcbR+1kuF!GQVx#yJy>oxxOP5c7|Xb2gr<;bBhV-9FiuSEc@i_1wT6Hgf|@E4UdL zSza(RFtDUBFfasoGqZ>=Ffed1wDN9uQrsZP;KatjaMpx@L7G8^Avr&)0eNFDX&AiHEay@S+RJ{20 zwM|dm{7X-Zgk_wAQx_lqo0{wK8-ri|{QW1%k~2p6Q;+X`)Bn@NZ+uZHnkZ?-Xxq@w zd0)9CFW~W^`jVQOqJ{^_iPCGs`rco->eXAnAzOao0gjFSTbInQbz2;0B+)W+iE~Yc z*Y2AuJdHT!u59eAPjpx7_jS8brGF(N$+iFg_*Rd~f%1L^@ zQ+Uy)+l+n}%)L+jVo1^Vk^A;afzxIGum3h29(QlOU63SYv)8RJb4RdpgNq68zLj3? zQo9A^xH@DXoif`xqyFrc#w*7K*Xe9zUX@>ve9+5s&c*J)({2;r2y9HRYWY_&xuN*= zZqBl|N2HuTq(qhqCP??VCu!&;wri#+X75pZuw+HMwL{ydA~Pw)+FTF!#VgKqfyh>PP+edU*g*CR~@tW7}?YuseY|}U%Zg&Jw=*=KOD%hqRQaQj&3+c!s!iYejelJ1+uU}v=x*7L2)TtzKF;_r>#SU| zp}x0r#sjUZhMtQz^qoA-U39&5Ide$8y;Fwcd29FS64v|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Zhi~OnKNXGT&-yr9Z_T7PT{??vHuOgO?wZQjamp;W zRHV1OY3BEibs7BC0c=)pQ=>Jn?Yq9P)9t`SktsnE&$LXoe$Ghqwhj=;*j8x&!zxJf zQnodl2h-f!2d~}Q6SU{xwIu5mGhbI--CnsOU`hY3V;h|&Yu9&WHr|q4?l%3tqg;&P zx#_19#U;F3{@Q*_+vU`|;MtQ3|MKH|WK|Yf)I{HtSS_B3=g zZ2O;uvi_ZVZ`KC6cgwyf?W>AnXISaCod4?2S1%UW9$J>?W-syTT4DE&;>`35@qGKz z%P+)))Smr&u;Abpy>q?0HSa7~{^20Qn&m3aJZD{un-uMQHf;RY{Omx%w&^FBPxl?V zSNE|VG0$4rJo%fII{VS$>4C?Jr*BrVc3}cf(q`KlG253-pUh|{V~;r(E5QH)j0_A6 zTN*of85nTP%(8-KW#}$7uoy^ zB9nC-WSGm^!H%)4Y~JK_Kke&nHAV&oZYBl>0S1KPC5;*e3=FxcC5b7CC5d_|sm0kP f`30dNtPIRYizml9O7d|sa55+{Gce3B1bF}elRoTo diff --git a/source/contents/code/configaccepted.py b/source/contents/code/configaccepted.py new file mode 100644 index 0000000..a3a8a55 --- /dev/null +++ b/source/contents/code/configaccepted.py @@ -0,0 +1,137 @@ +class ConfigAccepted: + def __init__(self, parent): + """class definition""" + self.parent = parent + + + def configAccepted(self): + """function to accept settings""" + # 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.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) + + # disconnecting from source and clear layout + if (self.parent.uptimeBool == 1): + self.parent.systemmonitor.disconnectSource("system/uptime", self.parent) + self.parent.label_uptime.setText('') + self.parent.layout.removeItem(self.parent.label_uptime) + if (self.parent.cpuBool == 1): + self.parent.systemmonitor.disconnectSource("cpu/system/TotalLoad", self.parent) + if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat): + self.parent.label_cpu0.setText('') + self.parent.layout.removeItem(self.parent.label_cpu0) + self.parent.label_cpu1.setText('') + self.parent.layout.removeItem(self.parent.label_cpu1) + for core in range(self.parent.numCores): + self.parent.systemmonitor.disconnectSource("cpu/cpu"+str(core)+"/TotalLoad", self.parent) + exec ("self.parent.label_coreCpu" + str(core) + ".setText('')") + exec ("self.parent.layout.removeItem(self.parent.label_coreCpu" + str(core) + ")") + else: + self.parent.label_cpu.setText('') + self.parent.layout.removeItem(self.parent.label_cpu) + if (self.parent.cpuclockBool == 1): + self.parent.systemmonitor.disconnectSource("cpu/system/AverageClock", self.parent) + if (self.parent.cpuclockFormat.split('$ccpu')[0] != self.parent.cpuclockFormat): + self.parent.label_cpuclock0.setText('') + self.parent.layout.removeItem(self.parent.label_cpuclock0) + self.parent.label_cpuclock1.setText('') + self.parent.layout.removeItem(self.parent.label_cpuclock1) + for core in range(self.parent.numCores): + self.parent.systemmonitor.disconnectSource("cpu/cpu"+str(core)+"/clock", self.parent) + exec ("self.parent.label_coreCpuclock" + str(core) + ".setText('')") + exec ("self.parent.layout.removeItem(self.parent.label_coreCpuclock" + str(core) + ")") + else: + self.parent.label_cpuclock.setText('') + self.parent.layout.removeItem(self.parent.label_cpuclock) + if (self.parent.tempBool == 1): + self.parent.systemmonitor.disconnectSource(self.parent.tempdev, self.parent) + self.parent.label_temp.setText('') + self.parent.layout.removeItem(self.parent.label_temp) + if (self.parent.gpuBool == 1): + self.parent.gpuChecker.stop() + self.parent.label_gpu.setText('') + self.parent.layout.removeItem(self.parent.label_gpu) + if (self.parent.gputempBool == 1): + self.parent.gpuTempChecker.stop() + self.parent.label_gputemp.setText('') + self.parent.layout.removeItem(self.parent.label_gputemp) + if (self.parent.memBool == 1): + self.parent.systemmonitor.disconnectSource("mem/physical/application", self.parent) + if (self.parent.memInMb == False): + self.parent.systemmonitor.disconnectSource("mem/physical/free", self.parent) + self.parent.systemmonitor.disconnectSource("mem/physical/used", self.parent) + self.parent.label_mem.setText('') + self.parent.layout.removeItem(self.parent.label_mem) + if (self.parent.swapBool == 1): + self.parent.systemmonitor.disconnectSource("mem/swap/used", self.parent) + if (self.parent.swapInMb == False): + self.parent.systemmonitor.disconnectSource("mem/swap/free", self.parent) + self.parent.label_swap.setText('') + self.parent.layout.removeItem(self.parent.label_swap) + if (self.parent.hddBool == 1): + for mount in self.parent.mountPoints: + self.parent.systemmonitor.disconnectSource("partitions" + mount + "/filllevel", self.parent) + exec ('self.parent.label_hdd_' + ''.join(mount.split('/')) + '.setText("")') + exec ("self.parent.layout.removeItem(self.parent.label_hdd_" + ''.join(mount.split('/')) + ")") + self.parent.label_hdd0.setText('') + self.parent.label_hdd1.setText('') + 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.label_hddtemp.setText('') + self.parent.layout.removeItem(self.parent.label_hddtemp) + if (self.parent.netBool == 1): + 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.label_netDown.setText('') + self.parent.label_netUp.setText('') + self.parent.layout.removeItem(self.parent.label_netUp) + self.parent.layout.removeItem(self.parent.label_netDown) + if (self.parent.batBool == 1): + self.parent.label_bat.setText('') + self.parent.layout.removeItem(self.parent.label_bat) + + self.parent.label_order = "------------" + + for label in self.parent.dict_orders.keys(): + if (self.parent.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 + 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)') + 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)') + 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) + 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.label_order = ''.join(self.parent.label_order.split('-')) + self.parent.settings.set('label_order', self.parent.label_order) + + # reinitializate + self.parent.reinit.reinit() diff --git a/source/contents/code/dataengine.py b/source/contents/code/dataengine.py new file mode 100644 index 0000000..dd52c9f --- /dev/null +++ b/source/contents/code/dataengine.py @@ -0,0 +1,195 @@ +from PyQt4.QtCore import * +from PyQt4.QtGui import * +from PyKDE4.plasma import Plasma +from PyKDE4 import plasmascript + + + +class DataEngine: + def __init__(self, parent): + """class definition""" + self.parent = parent + + + def connectToEngine(self): + """function to initializate engine""" + self.parent.systemmonitor = self.parent.dataEngine("systemmonitor") + if (self.parent.uptimeBool == 1): + self.parent.systemmonitor.connectSource("system/uptime", self.parent, self.parent.interval) + if (self.parent.cpuBool == 1): + self.parent.systemmonitor.connectSource("cpu/system/TotalLoad", self.parent, self.parent.interval) + if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat): + for core in range(self.parent.numCores): + self.parent.systemmonitor.connectSource("cpu/cpu"+str(core)+"/TotalLoad", self.parent, self.parent.interval) + if (self.parent.cpuclockBool == 1): + self.parent.systemmonitor.connectSource("cpu/system/AverageClock", self.parent, self.parent.interval) + 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.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) + 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) + if (self.parent.hddBool == 1): + for mount in self.parent.mountPoints: + self.parent.systemmonitor.connectSource("partitions" + mount + "/filllevel", 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] + 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: + 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_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] + 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 + 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')]) diff --git a/source/contents/code/gpuchecker.py b/source/contents/code/gpuchecker.py new file mode 100644 index 0000000..01162de --- /dev/null +++ b/source/contents/code/gpuchecker.py @@ -0,0 +1,38 @@ +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 diff --git a/source/contents/code/gputempchecker.py b/source/contents/code/gputempchecker.py new file mode 100644 index 0000000..65c2533 --- /dev/null +++ b/source/contents/code/gputempchecker.py @@ -0,0 +1,35 @@ +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 diff --git a/source/contents/code/hddtempchecker.py b/source/contents/code/hddtempchecker.py new file mode 100644 index 0000000..b1a0000 --- /dev/null +++ b/source/contents/code/hddtempchecker.py @@ -0,0 +1,29 @@ +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 diff --git a/source/contents/code/main.py b/source/contents/code/main.py index 1727dcc..3ae74d9 100644 --- a/source/contents/code/main.py +++ b/source/contents/code/main.py @@ -5,14 +5,15 @@ from PyQt4.QtGui import * from PyKDE4.kdecore import * from PyKDE4.kdeui import * from PyKDE4.kio import * -from PyKDE4.plasma import Plasma from PyKDE4 import plasmascript -from PyQt4 import QtCore -from configwindow import * -from config import * -from util import * +from PyKDE4.plasma import Plasma import commands, os, time +import configaccepted +import configwindow +import dataengine +import reinit + class pyTextWidget(plasmascript.Applet): @@ -25,144 +26,17 @@ class pyTextWidget(plasmascript.Applet): """function to initializate widget""" self._name = str(self.package().metadata().pluginName()) self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet) + self.configAccepted = configaccepted.ConfigAccepted(self) + self.dataengine = dataengine.DataEngine(self) + self.reinit = reinit.Reinit(self) self.setupVar() - self.reinit() + self.reinit.reinit() self.setHasConfigurationInterface(True) - - - def configAccepted(self): - """function to accept settings""" - # update local variables - self.interval = int(self.configpage.ui.spinBox_interval.value()) - self.settings.set('interval', self.interval) - self.font_family = str(self.configpage.ui.fontComboBox.currentFont().family()) - self.settings.set('font_family', self.font_family) - self.font_size = int(self.configpage.ui.spinBox_fontSize.value()) - self.settings.set('font_size', self.font_size) - self.font_color = str(self.configpage.ui.kcolorcombo.color().name()) - self.settings.set('font_color', self.font_color) - if (self.configpage.ui.comboBox_style.currentIndex() == 0): - self.font_style = 'normal' - else: - self.font_style = 'italic' - self.settings.set('font_style', self.font_style) - self.font_weight = int(self.configpage.ui.spinBox_weight.value()) - self.settings.set('font_weight', self.font_weight) - - # disconnecting from source and clear layout - if (self.uptimeBool == 1): - self.systemmonitor.disconnectSource("system/uptime", self) - self.label_uptime.setText('') - self.layout.removeItem(self.label_uptime) - if (self.cpuBool == 1): - self.systemmonitor.disconnectSource("cpu/system/TotalLoad", self) - if (self.cpuFormat.split('$ccpu')[0] != self.cpuFormat): - self.label_cpu0.setText('') - self.layout.removeItem(self.label_cpu0) - self.label_cpu1.setText('') - self.layout.removeItem(self.label_cpu1) - for core in range(self.numCores): - self.systemmonitor.disconnectSource("cpu/cpu"+str(core)+"/TotalLoad", self) - exec ("self.label_coreCpu" + str(core) + ".setText('')") - exec ("self.layout.removeItem(self.label_coreCpu" + str(core) + ")") - else: - self.label_cpu.setText('') - self.layout.removeItem(self.label_cpu) - if (self.cpuclockBool == 1): - self.systemmonitor.disconnectSource("cpu/system/AverageClock", self) - if (self.cpuclockFormat.split('$ccpu')[0] != self.cpuclockFormat): - self.label_cpuclock0.setText('') - self.layout.removeItem(self.label_cpuclock0) - self.label_cpuclock1.setText('') - self.layout.removeItem(self.label_cpuclock1) - for core in range(self.numCores): - self.systemmonitor.disconnectSource("cpu/cpu"+str(core)+"/clock", self) - exec ("self.label_coreCpuclock" + str(core) + ".setText('')") - exec ("self.layout.removeItem(self.label_coreCpuclock" + str(core) + ")") - else: - self.label_cpuclock.setText('') - self.layout.removeItem(self.label_cpuclock) - if (self.tempBool == 1): - self.systemmonitor.disconnectSource(self.tempdev, self) - self.label_temp.setText('') - self.layout.removeItem(self.label_temp) - if (self.gpuBool == 1): - self.label_gpu.setText('') - self.layout.removeItem(self.label_gpu) - if (self.gputempBool == 1): - self.label_gputemp.setText('') - self.layout.removeItem(self.label_gputemp) - if (self.memBool == 1): - self.systemmonitor.disconnectSource("mem/physical/application", self) - if (self.memInMb == False): - self.systemmonitor.disconnectSource("mem/physical/free", self) - self.systemmonitor.disconnectSource("mem/physical/used", self) - self.label_mem.setText('') - self.layout.removeItem(self.label_mem) - if (self.swapBool == 1): - self.systemmonitor.disconnectSource("mem/swap/used", self) - if (self.swapInMb == False): - self.systemmonitor.disconnectSource("mem/swap/free", self) - self.label_swap.setText('') - self.layout.removeItem(self.label_swap) - if (self.hddBool == 1): - for mount in self.mountPoints: - self.systemmonitor.disconnectSource("partitions" + mount + "/filllevel", self) - exec ('self.label_hdd_' + ''.join(mount.split('/')) + '.setText("")') - exec ("self.layout.removeItem(self.label_hdd_" + ''.join(mount.split('/')) + ")") - self.label_hdd0.setText('') - self.label_hdd1.setText('') - self.layout.removeItem(self.label_hdd0) - self.layout.removeItem(self.label_hdd1) - if (self.hddtempBool == 1): - self.label_hddtemp.setText('') - self.layout.removeItem(self.label_hddtemp) - if (self.netBool == 1): - self.systemmonitor.disconnectSource("network/interfaces/"+self.netdev+"/transmitter/data", self) - self.systemmonitor.disconnectSource("network/interfaces/"+self.netdev+"/receiver/data", self) - self.label_netDown.setText('') - self.label_netUp.setText('') - self.layout.removeItem(self.label_netUp) - self.layout.removeItem(self.label_netDown) - if (self.batBool == 1): - self.label_bat.setText('') - self.layout.removeItem(self.label_bat) - - self.label_order = "------------" - - for label in self.dict_orders.keys(): - if (self.configpage.checkboxes[self.dict_orders[label]].checkState() == 2): - exec ('self.' + self.dict_orders[label] + 'Bool = 1') - pos = self.configpage.sliders[self.dict_orders[label]].value() - 1 - self.label_order = self.label_order[:pos] + label + self.label_order[pos+1:] - else: - exec ('self.' + self.dict_orders[label] + 'Bool = 0') - if (self.dict_orders[label] == 'net'): - exec ('self.' + self.dict_orders[label] + 'NonFormat = str(self.configpage.lineedits[self.dict_orders[label]].text())') - exec ('self.settings.set("' + self.dict_orders[label] + 'NonFormat", self.' + self.dict_orders[label] + 'NonFormat)') - else: - exec ('self.' + self.dict_orders[label] + 'Format = str(self.configpage.lineedits[self.dict_orders[label]].text())') - exec ('self.settings.set("' + self.dict_orders[label] + 'Format", self.' + self.dict_orders[label] + 'Format)') - exec ('self.settings.set("' + self.dict_orders[label] + 'Bool", self.' + self.dict_orders[label] + 'Bool)') - if (self.dict_orders[label] == 'net'): - self.num_dev = int(self.configpage.ui.comboBox_numNet.currentIndex()) - self.settings.set('num_dev', self.num_dev) - elif (self.dict_orders[label] == 'bat'): - self.battery_device = str(self.configpage.ui.lineEdit_batdev.text()) - self.ac_device = str(self.configpage.ui.lineEdit_acdev.text()) - self.settings.set('battery_device', self.battery_device) - self.settings.set('ac_device', self.ac_device) - - self.label_order = ''.join(self.label_order.split('-')) - self.settings.set('label_order', self.label_order) - - # reinitializate - self.reinit() - - + + def createConfigurationInterface(self, parent): """function to setup configuration window""" - self.configpage = ConfigWindow(self, self.settings) + 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))) @@ -195,280 +69,7 @@ class pyTextWidget(plasmascript.Applet): page = parent.addPage(self.configpage, i18n(self.name())) page.setIcon(KIcon(self.icon())) - parent.okClicked.connect(self.configAccepted) - - - def reinit(self): - """function to reinitializate widget""" - self.settings = Config(self) - self.interval = int(self.settings.get('interval', 2000)) - self.font_family = str(self.settings.get('font_family', 'Terminus')) - self.font_size = int(self.settings.get('font_size', 12)) - self.font_color = str(self.settings.get('font_color', '#000000')) - self.font_style = str(self.settings.get('font_style', 'normal')) - self.font_weight = int(self.settings.get('font_weight', 400)) - self.formatLine = "

$LINE

" - self.label_order = str(self.settings.get('label_order', '1345')) - for label in self.dict_orders.values(): - if ((label == 'cpu') or (label == 'mem') or (label == 'swap') or (label == 'net')): - exec ('self.' + label + 'Bool = int(self.settings.get("' + label + 'Bool", 1))') - else: - exec ('self.' + label + 'Bool = int(self.settings.get("' + label + 'Bool", 0))') - # small function for update if errors exist - summ = 0 - for label in self.dict_orders.values(): - exec ('summ += self.' + label + 'Bool') - if (len(self.label_order) != summ): - for label in self.dict_orders.values(): - if ((label == 'cpu') or (label == 'mem') or (label == 'swap') or (label == 'net')): - exec ('self.' + label + 'Bool = 1') - else: - exec ('self.' + label + 'Bool = 0') - exec ('self.settings.set("' + label + 'Bool", self.' + label + 'Bool)') - self.label_order = '1345' - self.settings.set('label_order', self.label_order) - - for order in self.label_order: - if (order == "1"): - if (self.cpuBool == 1): - self.cpuFormat = str(self.settings.get('cpuFormat', '[cpu: $cpu%]')) - if (self.cpuFormat.split('$ccpu')[0] != self.cpuFormat): - self.label_cpu0 = Plasma.Label(self.applet) - self.label_cpu1 = Plasma.Label(self.applet) - if (self.cpuFormat.split('$ccpu')[0].split('$cpu')[0] != self.cpuFormat.split('$ccpu')[0]): - line = self.cpuFormat.split('$ccpu')[0].split('$cpu')[0] + '-----' + self.cpuFormat.split('$ccpu')[0].split('$cpu')[1] - else: - line = self.cpuFormat.split('$ccpu')[0] - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_cpu0.setText(text) - self.layout.addItem(self.label_cpu0) - text = self.formatLine.split('$LINE')[0] + "-----" + self.formatLine.split('$LINE')[1] - for core in range(self.numCores): - #text = self.formatLine.split('$LINE')[0] + "Core" + str(core) + "\n-----" + self.formatLine.split('$LINE')[1] - exec ('self.label_coreCpu' + str(core) + ' = Plasma.Label(self.applet)') - exec ('self.label_coreCpu' + str(core) + '.setText(text)') - exec ('self.layout.addItem(self.label_coreCpu' + str(core) + ')') - if (self.cpuFormat.split('$ccpu')[1].split('$cpu')[0] != self.cpuFormat.split('$ccpu')[1]): - line = self.cpuFormat.split('$ccpu')[1].split('$cpu')[0] + '-----' + self.cpuFormat.split('$ccpu')[1].split('$cpu')[1] - else: - line = self.cpuFormat.split('$ccpu')[1] - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_cpu1.setText(text) - self.layout.addItem(self.label_cpu1) - else: - self.label_cpu = Plasma.Label(self.applet) - if (self.cpuFormat.split('$cpu')[0] != self.cpuFormat): - line = self.cpuFormat.split('$cpu')[0] + '-----' + self.cpuFormat.split('$cpu')[1] - else: - line = self.cpuFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_cpu.setText(text) - self.layout.addItem(self.label_cpu) - elif (order == "2"): - if (self.tempBool == 1): - self.tempFormat = str(self.settings.get('tempFormat', '[temp: $temp°C]')) - self.label_temp = Plasma.Label(self.applet) - if (self.tempFormat.split('$temp')[0] != self.tempFormat): - line = self.tempFormat.split('$temp')[0] + '----' + self.tempFormat.split('$temp')[1] - else: - line = self.tempFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_temp.setText(text) - self.layout.addItem(self.label_temp) - elif (order == "3"): - if (self.memBool == 1): - self.memFormat = str(self.settings.get('memFormat', '[mem: $mem%]')) - if (self.memFormat.split('$memmb')[0] != self.memFormat): - self.memInMb = True - text = self.formatLine.split('$LINE')[0] + self.memFormat.split('$memmb')[0] + '-----' + self.memFormat.split('$memmb')[1] + self.formatLine.split('$LINE')[1] - elif (self.memFormat.split('$mem')[0] != self.memFormat): - self.memInMb = False - self.mem_used = 0.0 - self.mem_free = 1.0 - self.mem_uf = 0.0 - line = self.memFormat.split('$mem')[0] + '-----' + self.memFormat.split('$mem')[1] - else: - line = self.memFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_mem = Plasma.Label(self.applet) - self.label_mem.setText(text) - self.layout.addItem(self.label_mem) - elif (order == "4"): - if (self.swapBool == 1): - self.swapFormat = str(self.settings.get('swapFormat', '[swap: $swap%]')) - if (self.swapFormat.split('$swapmb')[0] != self.swapFormat): - self.swapInMb = True - text = self.formatLine.split('$LINE')[0] + self.swapFormat.split('$swapmb')[0] + '-----' + self.swapFormat.split('$swapmb')[1] + self.formatLine.split('$LINE')[1] - elif (self.swapFormat.split('$swap')[0] != self.swapFormat): - self.swapInMb = False - self.swap_free = 1.0 - self.swap_used = 0.0 - line = self.swapFormat.split('$swap')[0] + '-----' + self.swapFormat.split('$swap')[1] - else: - line = self.swapFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_swap = Plasma.Label(self.applet) - self.label_swap.setText(text) - self.layout.addItem(self.label_swap) - elif (order == "5"): - if (self.netBool == 1): - self.netNonFormat = str(self.settings.get('netNonFormat', '[net: $netKB/s]')) - if (self.netNonFormat.split('@@')[0] != self.netNonFormat): - self.netdev = self.netNonFormat.split('@@')[1] - self.netNonFormat = self.netNonFormat.split('@@')[0] + self.netNonFormat.split('@@')[2] - else: - self.num_dev = int(self.settings.get('num_dev', 0)) - self.setupNetdev() - if (self.netNonFormat.split('$netdev')[0] != self.netNonFormat): - self.netFormat = self.netNonFormat.split('$netdev')[0] + self.netdev + self.netNonFormat.split('$netdev')[1] - else: - self.netFormat = self.netNonFormat - self.label_netDown = Plasma.Label(self.applet) - if (self.netFormat.split('$net')[0] != self.netFormat): - line = self.netFormat.split('$net')[0] + '----' - else: - line = self.netFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_netDown.setText(text) - self.layout.addItem(self.label_netDown) - self.label_netUp = Plasma.Label(self.applet) - if (self.netFormat.split('$net')[0] != self.netFormat): - line = '/----' + self.netFormat.split('$net')[1] - else: - line = '' - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_netUp.setText(text) - self.layout.addItem(self.label_netUp) - elif (order == "6"): - if (self.batBool == 1): - self.batFormat = str(self.settings.get('batFormat', '[bat: $bat%$ac]')) - self.battery_device= str(self.settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity')) - self.ac_device = str(self.settings.get('ac_device', '/sys/class/power_supply/AC/online')) - self.label_bat = Plasma.Label(self.applet) - line = self.batFormat - if (line.split('$ac')[0] != line): - line = line.split('$ac')[0] + '(-)' + line.split('$ac')[1] - if (line.split('$bat')[0] != line): - line = line.split('$bat')[0] + '---' + line.split('$bat')[1] - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_bat.setText(text) - self.layout.addItem(self.label_bat) - elif (order == "7"): - if (self.cpuclockBool == 1): - self.cpuclockFormat = str(self.settings.get('cpuclockFormat', '[mhz: $cpucl]')) - if (self.cpuclockFormat.split('$ccpucl')[0] != self.cpuclockFormat): - self.label_cpuclock0 = Plasma.Label(self.applet) - self.label_cpuclock1 = Plasma.Label(self.applet) - if (self.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] != self.cpuclockFormat.split('$ccpucl')[0]): - line = self.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] + '----' + self.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[1] - else: - line = self.cpuclockFormat.split('$ccpucl')[0] - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_cpuclock0.setText(text) - self.layout.addItem(self.label_cpuclock0) - text = self.formatLine.split('$LINE')[0] + "----" + self.formatLine.split('$LINE')[1] - for core in range(self.numCores): - exec ('self.label_coreCpuclock' + str(core) + ' = Plasma.Label(self.applet)') - exec ('self.label_coreCpuclock' + str(core) + '.setText(text)') - exec ('self.layout.addItem(self.label_coreCpuclock' + str(core) + ')') - if (self.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] != self.cpuclockFormat.split('$ccpucl')[1]): - line = self.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] + '----' + self.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[1] - else: - line = self.cpuclockFormat.split('$ccpucl')[1] - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_cpuclock1.setText(text) - self.layout.addItem(self.label_cpuclock1) - else: - self.label_cpuclock = Plasma.Label(self.applet) - if (self.cpuclockFormat.split('$cpucl')[0] != self.cpuclockFormat): - line = self.cpuclockFormat.split('$cpucl')[0] + '----' + self.cpuclockFormat.split('$cpucl')[1] - else: - line = self.cpuclockFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_cpuclock.setText(text) - self.layout.addItem(self.label_cpuclock) - elif (order == "8"): - if (self.uptimeBool == 1): - self.uptimeFormat = str(self.settings.get('uptimeFormat', '[uptime: $uptime]')) - self.label_uptime = Plasma.Label(self.applet) - if (self.uptimeFormat.split('$uptime')[0] != self.uptimeFormat): - line = self.uptimeFormat.split('$uptime')[0] + '---d--h--m' + self.uptimeFormat.split('$uptime')[1] - else: - line = self.uptimeFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_uptime.setText(text) - self.layout.addItem(self.label_uptime) - elif (order == "9"): - if (self.gpuBool == 1): - self.gpuFormat = str(self.settings.get('gpuFormat', '[gpu: $gpu%]')) - self.label_gpu = Plasma.Label(self.applet) - if (self.gpuFormat.split('$gpu')[0] != self.gpuFormat): - line = self.gpuFormat.split('$gpu')[0] + '-----' + 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) - self.layout.addItem(self.label_gpu) - elif (order == "a"): - if (self.gputempBool == 1): - self.gputempFormat = str(self.settings.get('gputempFormat', '[gpu temp: $gputemp°C]')) - self.label_gputemp = Plasma.Label(self.applet) - if (self.gputempFormat.split('$gputemp')[0] != self.gputempFormat): - line = self.gputempFormat.split('$gputemp')[0] + '----' + 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) - self.layout.addItem(self.label_gputemp) - elif (order == "b"): - if (self.hddBool == 1): - self.hddFormat = str(self.settings.get('hddFormat', '[hdd: @@/@@%]')) - if (self.hddFormat.split('@@')[0] != self.hddFormat): - self.mountPoints = self.hddFormat.split('@@')[1].split(';') - line = self.hddFormat.split('@@')[0] - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_hdd0 = Plasma.Label(self.applet) - self.label_hdd0.setText(text) - self.layout.addItem(self.label_hdd0) - text = self.formatLine.split('$LINE')[0] + "-----" + self.formatLine.split('$LINE')[1] - for mount in self.mountPoints: - exec ('self.label_hdd_' + ''.join(mount.split('/')) + ' = Plasma.Label(self.applet)') - exec ('self.label_hdd_' + ''.join(mount.split('/')) + '.setText(text)') - exec ('self.layout.addItem(self.label_hdd_' + ''.join(mount.split('/')) + ')') - line = self.hddFormat.split('@@')[2] - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_hdd1 = Plasma.Label(self.applet) - self.label_hdd1.setText(text) - self.layout.addItem(self.label_hdd1) - else: - line = self.hddFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_hdd0.setText(text) - self.layout.addItem(self.label_hdd0) - elif (order == "c"): - if (self.hddtempBool == 1): - self.hddtempFormat = str(self.settings.get('hddtempFormat', '[hdd temp: @@/dev/sda@@°C]')) - self.label_hddtemp = Plasma.Label(self.applet) - if (self.hddtempFormat.split('@@')[0] != self.hddtempFormat): - line = self.hddtempFormat.split('@@')[0] + '----' + 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) - self.layout.addItem(self.label_hddtemp) - self.applet.setLayout(self.layout) - self.theme = Plasma.Svg(self) - self.theme.setImagePath("widgets/background") - self.setBackgroundHints(Plasma.Applet.DefaultBackground) - self.resize(10,10) - - # start timer - self.connectToEngine() - self.timer = QtCore.QTimer() - self.timer.setInterval(self.interval) - self.startPolling() + parent.okClicked.connect(self.configAccepted.configAccepted) def setupNetdev(self): @@ -535,7 +136,7 @@ class pyTextWidget(plasmascript.Applet): def startPolling(self): try: self.timer.start() - QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.updateLabel) + QObject.connect(self.timer, SIGNAL("timeout()"), self.updateLabel) self.updateLabel() self.showTooltip('') except Exception as (strerror): @@ -549,14 +150,17 @@ class pyTextWidget(plasmascript.Applet): """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() @@ -590,19 +194,8 @@ class pyTextWidget(plasmascript.Applet): def gpuText(self): """function to set gpu text""" - if (self.gpudev == 'nvidia'): - commandOut = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1") - if (commandOut.split()[2] == 'N/A'): - gpu = ' N/A' - else: - gpu = "%5s" % (str(round(float(commandOut.split()[2][:-1]), 1))) - elif (self.gpudev == 'ati'): - commandOut = commands.getoutput("aticonfig --od-getclocks | grep load | tail -n1") - gpu = "%5s" % (str(round(float(commandOut.split()[3][:-1]), 1))) - else: - gpu = '-----' if (self.gpuFormat.split('$gpu')[0] != self.gpuFormat): - line = self.gpuFormat.split('$gpu')[0] + gpu + self.gpuFormat.split('$gpu')[1] + 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] @@ -611,16 +204,8 @@ class pyTextWidget(plasmascript.Applet): def gputempText(self): """function to set gpu temperature text""" - if (self.gpudev == 'nvidia'): - commandOut = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1") - gputemp = "%4s" % (str(round(float(commandOut.split()[2]), 1))) - elif (self.gpudev == 'ati'): - commandOut = commands.getoutput("aticonfig --od-gettemperature | grep Temperature | tail -n1") - gputemp = "%4s" % (str(round(float(commandOut.split()[4]), 1))) - else: - gputemp = '----' if (self.gputempFormat.split('$gputemp')[0] != self.gputempFormat): - line = self.gputempFormat.split('$gputemp')[0] + gputemp + self.gputempFormat.split('$gputemp')[1] + 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] @@ -629,10 +214,8 @@ class pyTextWidget(plasmascript.Applet): def hddtempText(self): """function to set hdd temperature text""" - commandOut = commands.getoutput("hddtemp "+self.hddtempFormat.split('@@')[1]) - hddtemp = "%4s" % (str(round(float(commandOut.split(':')[2][:-3]), 1))) if (self.hddtempFormat.split('@@')[0] != self.hddtempFormat): - line = self.hddtempFormat.split('@@')[0] + hddtemp + self.hddtempFormat.split('@@')[2] + 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] @@ -663,191 +246,12 @@ class pyTextWidget(plasmascript.Applet): line = self.swapFormat text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] self.label_swap.setText(text) - - - def connectToEngine(self): - """function to initializate engine""" - self.systemmonitor = self.dataEngine("systemmonitor") - if (self.uptimeBool == 1): - self.systemmonitor.connectSource("system/uptime", self, self.interval) - if (self.cpuBool == 1): - self.systemmonitor.connectSource("cpu/system/TotalLoad", self, self.interval) - if (self.cpuFormat.split('$ccpu')[0] != self.cpuFormat): - for core in range(self.numCores): - self.systemmonitor.connectSource("cpu/cpu"+str(core)+"/TotalLoad", self, self.interval) - if (self.cpuclockBool == 1): - self.systemmonitor.connectSource("cpu/system/AverageClock", self, self.interval) - if (self.cpuclockFormat.split('$ccpucl')[0] != self.cpuclockFormat): - for core in range(self.numCores): - self.systemmonitor.connectSource("cpu/cpu"+str(core)+"/clock", self, self.interval) - if (self.netBool == 1): - self.updateNetdev = 0 - self.systemmonitor.connectSource("network/interfaces/"+self.netdev+"/transmitter/data", self, self.interval) - self.systemmonitor.connectSource("network/interfaces/"+self.netdev+"/receiver/data", self, self.interval) - if (self.tempBool == 1): - self.systemmonitor.connectSource(self.tempdev, self, self.interval) - if (self.memBool == 1): - if (self.memInMb): - self.systemmonitor.connectSource("mem/physical/application", self, self.interval) - else: - self.systemmonitor.connectSource("mem/physical/free", self, 200) - self.systemmonitor.connectSource("mem/physical/used", self, 200) - self.systemmonitor.connectSource("mem/physical/application", self, 200) - if (self.swapBool == 1): - if (self.swapInMb): - self.systemmonitor.connectSource("mem/swap/used", self, self.interval) - else: - self.systemmonitor.connectSource("mem/swap/free", self, 200) - self.systemmonitor.connectSource("mem/swap/used", self, 200) - if (self.hddBool == 1): - for mount in self.mountPoints: - self.systemmonitor.connectSource("partitions" + mount + "/filllevel", self, self.interval) - + + @pyqtSignature("dataUpdated(const QString &, const Plasma::DataEngine::Data &)") 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.uptimeFormat.split('$uptime')[0] != self.uptimeFormat): - line = self.uptimeFormat.split('$uptime')[0] + uptimeText + self.uptimeFormat.split('$uptime')[1] - else: - line = self.uptimeFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_uptime.setText(text) - elif (sourceName == "cpu/system/TotalLoad"): - value = str(round(float(data[QString(u'value')]), 1)) - cpuText = "%5s" % (value) - if (self.cpuFormat.split('$ccpu')[0] != self.cpuFormat): - if (self.cpuFormat.split('$ccpu')[0].split('$cpu')[0] != self.cpuFormat.split('$ccpu')[0]): - line = self.cpuFormat.split('$ccpu')[0].split('$cpu')[0] + cpuText + self.cpuFormat.split('$ccpu')[0].split('$cpu')[1] - else: - line = self.cpuFormat.split('$ccpu')[0] - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_cpu0.setText(text) - if (self.cpuFormat.split('$ccpu')[1].split('$cpu')[0] != self.cpuFormat.split('$ccpu')[1]): - line = self.cpuFormat.split('$ccpu')[1].split('$cpu')[0] + cpuText + self.cpuFormat.split('$ccpu')[1].split('$cpu')[1] - else: - line = self.cpuFormat.split('$ccpu')[1] - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_cpu1.setText(text) - else: - if (self.cpuFormat.split('$cpu')[0] != self.cpuFormat): - line = self.cpuFormat.split('$cpu')[0] + cpuText + self.cpuFormat.split('$cpu')[1] - else: - line = self.cpuFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.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.formatLine.split('$LINE')[0] + cpuText + self.formatLine.split('$LINE')[1] - #text = self.formatLine.split('$LINE')[0] + "Core" + str(sourceName)[7] + "\n" + cpuText + self.formatLine.split('$LINE')[1] - exec ('self.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.cpuclockFormat.split('$ccpucl')[0] != self.cpuclockFormat): - if (self.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] != self.cpuclockFormat.split('$ccpucl')[0]): - line = self.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] + cpuclockText + self.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[1] - else: - line = self.cpuclockFormat.split('$ccpucl')[0] - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_cpuclock0.setText(text) - if (self.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] != self.cpuclockFormat.split('$ccpucl')[1]): - line = self.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] + cpuclockText + self.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[1] - else: - line = self.cpuclockFormat.split('$ccpucl')[1] - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_cpuclock1.setText(text) - else: - if (self.cpuclockFormat.split('$cpucl')[0] != self.cpuclockFormat): - line = self.cpuclockFormat.split('$cpucl')[0] + cpuclockText + self.cpuclockFormat.split('$cpucl')[1] - else: - line = self.cpuclockFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.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.formatLine.split('$LINE')[0] + cpuclockText + self.formatLine.split('$LINE')[1] - exec ('self.label_coreCpuclock' + str(sourceName)[7] + '.setText(text)') - elif (sourceName == "network/interfaces/"+self.netdev+"/transmitter/data"): - value = str(data[QString(u'value')]).split('.')[0] - up_speed = "%4s" % (value) - if (self.netFormat.split('$net')[0] != self.netFormat): - line = '/' + up_speed + self.netFormat.split('$net')[1] - else: - line = '' - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_netUp.setText(text) - elif (sourceName == "network/interfaces/"+self.netdev+"/receiver/data"): - value = str(data[QString(u'value')]).split('.')[0] - down_speed = "%4s" % (value) - if (self.netFormat.split('$net')[0] != self.netFormat): - line = self.netFormat.split('$net')[0] + down_speed - else: - line = self.netFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_netDown.setText(text) - # update network device - self.updateNetdev = self.updateNetdev + 1 - if (self.updateNetdev == 100): - self.updateNetdev = 0 - if (self.netNonFormat.split('@@')[0] == self.netNonFormat): - self.systemmonitor.disconnectSource("network/interfaces/"+self.netdev+"/transmitter/data", self) - self.systemmonitor.disconnectSource("network/interfaces/"+self.netdev+"/receiver/data", self) - self.setupNetdev() - self.systemmonitor.connectSource("network/interfaces/"+self.netdev+"/transmitter/data", self, self.interval) - self.systemmonitor.connectSource("network/interfaces/"+self.netdev+"/receiver/data", self, self.interval) - if (self.netNonFormat.split('$netdev')[0] != self.netNonFormat): - self.netFormat = self.netNonFormat.split('$netdev')[0] + self.netdev + self.netNonFormat.split('$netdev')[1] - else: - self.netFormat = self.netNonFormat - elif (sourceName == self.tempdev): - value = str(round(float(data[QString(u'value')]), 1)) - tempText = "%4s" % (value) - if (self.tempFormat.split('$temp')[0] != self.tempFormat): - line = self.tempFormat.split('$temp')[0] + tempText + self.tempFormat.split('$temp')[1] - else: - line = self.tempFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_temp.setText(text) - elif (str(sourceName).split('/')[0] == "partitions"): - value = str(round(float(data[QString(u'value')]), 1)) - hddText = "%5s" % (value) - text = self.formatLine.split('$LINE')[0] + hddText + self.formatLine.split('$LINE')[1] - exec ('self.label_hdd_' + ''.join(str(sourceName).split('/')[1:-1]) + '.setText(text)') - elif (sourceName == "mem/physical/free"): - self.mem_free = float(data[QString(u'value')]) - elif (sourceName == "mem/physical/used"): - self.mem_uf = float(data[QString(u'value')]) - elif (sourceName == "mem/physical/application"): - if (self.memInMb): - mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0] - mem = "%5s" % (mem) - if (self.memFormat.split('$memmb')[0] != self.memFormat): - line = self.memFormat.split('$memmb')[0] + mem + self.memFormat.split('$memmb')[1] - else: - line = self.memFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_mem.setText(text) - else: - self.mem_used = float(data[QString(u'value')]) - elif (sourceName == "mem/swap/free"): - self.swap_free = float(data[QString(u'value')]) - elif (sourceName == "mem/swap/used"): - if (self.swapInMb): - mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0] - mem = "%5s" % (mem) - if (self.swapFormat.split('$swapmb')[0] != self.swapFormat): - line = self.swapFormat.split('$swapmb')[0] + mem + self.swapFormat.split('$swapmb')[1] - else: - line = self.swapFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_swap.setText(text) - else: - self.swap_used = float(data[QString(u'value')]) + """function to update label""" + self.dataengine.dataUpdated(sourceName, data) diff --git a/source/contents/code/reinit.py b/source/contents/code/reinit.py new file mode 100644 index 0000000..75d2b3a --- /dev/null +++ b/source/contents/code/reinit.py @@ -0,0 +1,293 @@ +from PyQt4.QtCore import * +from PyKDE4.plasma import Plasma +import config +import gpuchecker +import gputempchecker +import hddtempchecker + + + +class Reinit(): + def __init__(self, parent): + """class definition""" + self.parent = parent + + 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)) + self.parent.formatLine = "

$LINE

" + self.parent.label_order = str(self.parent.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))') + else: + exec ('self.parent.' + label + 'Bool = int(self.parent.settings.get("' + label + 'Bool", 0))') + # small function for update if errors exist + summ = 0 + for label in self.parent.dict_orders.values(): + exec ('summ += self.parent.' + label + 'Bool') + if (len(self.parent.label_order) != summ): + 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 = 1') + else: + exec ('self.parent.' + label + 'Bool = 0') + exec ('self.parent.settings.set("' + label + 'Bool", self.parent.' + label + 'Bool)') + self.parent.label_order = '1345' + self.parent.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%]')) + 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) + 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] + '-----' + 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) + self.parent.layout.addItem(self.parent.label_cpu0) + text = self.parent.formatLine.split('$LINE')[0] + "-----" + self.parent.formatLine.split('$LINE')[1] + for core in range(self.parent.numCores): + exec ('self.parent.label_coreCpu' + str(core) + ' = Plasma.Label(self.parent.applet)') + exec ('self.parent.label_coreCpu' + str(core) + '.setText(text)') + exec ('self.parent.layout.addItem(self.parent.label_coreCpu' + str(core) + ')') + 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] + '-----' + 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) + self.parent.layout.addItem(self.parent.label_cpu1) + else: + self.parent.label_cpu = Plasma.Label(self.parent.applet) + if (self.parent.cpuFormat.split('$cpu')[0] != self.parent.cpuFormat): + line = self.parent.cpuFormat.split('$cpu')[0] + '-----' + 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) + 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.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] + 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) + 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%]')) + 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] + elif (self.parent.memFormat.split('$mem')[0] != self.parent.memFormat): + self.parent.memInMb = False + self.parent.mem_used = 0.0 + self.parent.mem_free = 1.0 + self.parent.mem_uf = 0.0 + line = self.parent.memFormat.split('$mem')[0] + '-----' + self.parent.memFormat.split('$mem')[1] + else: + line = self.parent.memFormat + text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1] + self.parent.label_mem = Plasma.Label(self.parent.applet) + self.parent.label_mem.setText(text) + 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%]')) + 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] + elif (self.parent.swapFormat.split('$swap')[0] != self.parent.swapFormat): + self.parent.swapInMb = False + self.parent.swap_free = 1.0 + self.parent.swap_used = 0.0 + line = self.parent.swapFormat.split('$swap')[0] + '-----' + self.parent.swapFormat.split('$swap')[1] + else: + line = self.parent.swapFormat + text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1] + self.parent.label_swap = Plasma.Label(self.parent.applet) + self.parent.label_swap.setText(text) + 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]')) + 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.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] + else: + self.parent.netFormat = self.parent.netNonFormat + self.parent.label_netDown = Plasma.Label(self.parent.applet) + if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat): + line = self.parent.netFormat.split('$net')[0] + '----' + 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) + self.parent.layout.addItem(self.parent.label_netDown) + self.parent.label_netUp = Plasma.Label(self.parent.applet) + if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat): + line = '/----' + 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) + 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.label_bat = Plasma.Label(self.parent.applet) + line = self.parent.batFormat + if (line.split('$ac')[0] != line): + line = line.split('$ac')[0] + '(-)' + line.split('$ac')[1] + if (line.split('$bat')[0] != line): + line = line.split('$bat')[0] + '---' + line.split('$bat')[1] + text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1] + self.parent.label_bat.setText(text) + 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]')) + 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) + 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] + '----' + 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) + self.parent.layout.addItem(self.parent.label_cpuclock0) + text = self.parent.formatLine.split('$LINE')[0] + "----" + self.parent.formatLine.split('$LINE')[1] + for core in range(self.parent.numCores): + exec ('self.parent.label_coreCpuclock' + str(core) + ' = Plasma.Label(self.parent.applet)') + exec ('self.parent.label_coreCpuclock' + str(core) + '.setText(text)') + exec ('self.parent.layout.addItem(self.parent.label_coreCpuclock' + str(core) + ')') + 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] + '----' + 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) + self.parent.layout.addItem(self.parent.label_cpuclock1) + else: + self.parent.label_cpuclock = Plasma.Label(self.parent.applet) + if (self.parent.cpuclockFormat.split('$cpucl')[0] != self.parent.cpuclockFormat): + line = self.parent.cpuclockFormat.split('$cpucl')[0] + '----' + 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) + 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.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] + 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) + 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.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] + else: + line = self.parent.gpuFormat + text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1] + self.parent.label_gpu.setText(text) + 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.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] + else: + line = self.parent.gputempFormat + text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1] + self.parent.label_gputemp.setText(text) + 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: @@/@@%]')) + if (self.parent.hddFormat.split('@@')[0] != self.parent.hddFormat): + self.parent.mountPoints = self.parent.hddFormat.split('@@')[1].split(';') + line = self.parent.hddFormat.split('@@')[0] + text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1] + self.parent.label_hdd0 = Plasma.Label(self.parent.applet) + self.parent.label_hdd0.setText(text) + self.parent.layout.addItem(self.parent.label_hdd0) + text = self.parent.formatLine.split('$LINE')[0] + "-----" + self.parent.formatLine.split('$LINE')[1] + for mount in self.parent.mountPoints: + exec ('self.parent.label_hdd_' + ''.join(mount.split('/')) + ' = Plasma.Label(self.parent.applet)') + exec ('self.parent.label_hdd_' + ''.join(mount.split('/')) + '.setText(text)') + exec ('self.parent.layout.addItem(self.parent.label_hdd_' + ''.join(mount.split('/')) + ')') + line = self.parent.hddFormat.split('@@')[2] + text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1] + self.parent.label_hdd1 = Plasma.Label(self.parent.applet) + self.parent.label_hdd1.setText(text) + self.parent.layout.addItem(self.parent.label_hdd1) + else: + line = self.parent.hddFormat + text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1] + self.parent.label_hdd0.setText(text) + 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.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] + else: + line = self.parent.hddtempFormat + text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1] + self.parent.label_hddtemp.setText(text) + self.parent.layout.addItem(self.parent.label_hddtemp) + self.parent.applet.setLayout(self.parent.layout) + self.parent.theme = Plasma.Svg(self.parent) + self.parent.theme.setImagePath("widgets/background") + self.parent.setBackgroundHints(Plasma.Applet.DefaultBackground) + self.parent.resize(10,10) + + # create threading + 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() diff --git a/source/contents/code/util.py b/source/contents/code/util.py deleted file mode 100644 index 32b87db..0000000 --- a/source/contents/code/util.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- - -import os -from shutil import copyfile -from PyKDE4.kdecore import * - - - -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) - - source = self.applet.package().path() + 'contents/misc/%s.notifyrc' % self.applet._name - 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) \ No newline at end of file