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 zcmaKSWl&w)*6cX4l*`X7!k(yC*Dz1Hs~$Al7R#<5@-jetD`u+}C8*jCsRD7$Gzz$|H~g`@C7o z&3swPt{!k8Fvxuf5D3x)1Oh3^LO`OwylI;v%BU&w*{lC8gKXa6q9Wc_

{X(NFB$VtuJY zNHFL}{d{a-G6$WzCG$1~w*pWEZ#DD90{o{K{MO?MCY4Ng*?eYZalj?h7?=TgoD#uo zM+?3!)?)WKCC8uuk1uw*Kb=T#0a}~lHq{}-3uari3NAl!NPR=AO><3Mv(+E4eR@*& z#zTgSA>jqoa;0HV@LeNR9xRu5uuiIt-h-09(77TuMtd!2`L)Yn3KN{NLk}PmMmd7p zL!$R$oe!^kFjA{aC%HzreC-l3md&c9eqwA09baW6aa&OcV8igYhBzA1fYEyYnSPW? zx*CWwdk5og8Sc!BNCc>|-k>S@89wxiT`RW?4X}S1Yw5Vf}Z9VMXL&SVkKQpZ8C% zBieOjQHOj=hGa(1mSq+C5kR{LweAP-V5Zv8?x# zF?AumPOEOsngn@;7iq8fqNFa>K(uGt2F)z9bU}5@;4qxid~gYb8XzcQAw142nTpNZ zX&*nXjg0Zj5;eQ6e6)x`Sla6K@@TdfihI7Y2~YV)2H`JUqy=5_E((<55iFX(L~*26 z@HyBVF{^=L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aS;Q9R8LHWp;JCE`Gvfg@=cvHyZXaMQyfm<;A<6~auE}Cah z_imf768cMaW}3H2rTUFFNyzU>fVi=AXQi;bEKp5EryzV1m&%_S_2?^(h$q#w_MX1+ z1GOWVnEaj!gJBHSl`qTBem=2JYvq(zu)qB0(7ydr;9N?|-X4#^3U~D+nzm4uR_OI} zmX^1uict@_b1cVbxqJiKybMpiY$GKcIJ@#|%yq}m!(}BqjCH3aRSM!TK$2$pa>v3` zA5co#7RUlrnQ0Lq@gHJ|1CPI^agMPW3Z%sefq`j zrGjr#y$LwUYWN2XTurw&R`LQWm^RI>B9HuP1he)6@G{UjYkiBWoobzZi)I348K-^= zExu(cMRD!Jbz(`3K(uYhDnY4K+U6Hh1NN!3anq0Z^5Jhn*H-Of;QWIyLbJ{4(`1k&epljg&Ije72(mg*d!jOBK>acrS1C@XT^nZ}nUWfzcAD~Tw z5+)Y;-xiDikI{la|IjR`F(e8N^nb}L+<#>D-;5*$5mFcj3{cV)31L#Ch$xIJ=D&U1 zq)id#Pyavr{cFAdJ%1V}iAj_g<{t$7H;B(StX^!>3bID?&+I7BAQ0w%8(b7Z#|8p9 sT6&mTn0lD9SXjE-dpNsjYW%Z~A@?MsF9hgFAS4jQKiZtm{_h6<3zI(Va{vGU 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