fix bugs that were found

This commit is contained in:
arcan1s 2014-04-01 23:35:31 +04:00
parent decf714e74
commit c66b255e8b
4 changed files with 35 additions and 21 deletions

View File

@ -61,9 +61,10 @@ class ConfigDefinition:
# temp and mount below
self.parent.hddNames = []
self.parent.hdd = {}
for item in self.configpage.ui.listWidget_hddDevice.items(QMimeData()):
self.parent.hddNames.append(str(item.text()))
self.parent.hdd[str(item.text())] =" 0.0"
for i in range(self.configpage.ui.listWidget_hddDevice.count()):
item = self.configpage.ui.listWidget_hddDevice.item(i).text()
self.parent.hddNames.append(str(item))
self.parent.hdd[str(item)] =" 0.0"
settings.set('hdd', '@@'.join(self.parent.hddNames))
self.parent.netdir = str(self.configpage.ui.lineEdit_netdir.text())
settings.set('netdir', self.parent.netdir)
@ -99,14 +100,15 @@ class ConfigDefinition:
self.parent.layout.removeItem(self.parent.label_cpuclock)
if (self.parent.tempBool > 0):
for item in self.parent.temp:
self.parent.systemmonitor.disconnectSource(item[0], self.parent)
self.parent.systemmonitor.disconnectSource(item, self.parent)
self.parent.label_temp.setText('')
self.parent.layout.removeItem(self.parent.label_temp)
self.parent.tempNames = []
self.parent.temp = {}
for item in self.configpage.ui.listWidget_tempDevice.items(QMimeData()):
self.parent.tempNames.append(str(item.text()))
self.parent.temp[str(item.text())] =" 0.0"
for i in range(self.configpage.ui.listWidget_tempDevice.count()):
item = self.configpage.ui.listWidget_tempDevice.item(i).text()
self.parent.tempNames.append(str(item))
self.parent.temp[str(item)] =" 0.0"
settings.set('temp_device', '@@'.join(self.parent.tempNames))
if (self.parent.gpuBool > 0):
self.parent.extsysmon.disconnectSource("gpu", self.parent)
@ -131,14 +133,15 @@ class ConfigDefinition:
self.parent.layout.removeItem(self.parent.label_swap)
if (self.parent.hddBool > 0):
for item in self.parent.mount:
self.parent.systemmonitor.disconnectSource("partitions" + item[0] + "/filllevel", self.parent)
self.parent.systemmonitor.disconnectSource("partitions" + item + "/filllevel", self.parent)
self.parent.label_hdd.setText('')
self.parent.layout.removeItem(self.parent.label_hdd)
self.parent.mountNames = []
self.parent.mount = {}
for item in self.configpage.ui.listWidget_mount.items(QMimeData()):
self.parent.mountNames.append(str(item.text()))
self.parent.mount[str(item.text())] =" 0.0"
for i in range(self.configpage.ui.listWidget_mount.count()):
item = self.configpage.ui.listWidget_mount.item(i).text()
self.parent.mountNames.append(str(item))
self.parent.mount[str(item)] =" 0.0"
settings.set('mount', '@@'.join(self.parent.mountNames))
if (self.parent.hddtempBool > 0):
self.parent.extsysmon.disconnectSource("hddtemp", self.parent)

View File

@ -147,7 +147,7 @@ class DataEngine:
self.parent.netFormat = self.parent.netNonFormat
elif (str(sourceName).split('/')[0] == "lmsensors"):
value = str(round(float(data[QString(u'value')]), 1))
self.parent.temp[sourceName] = "%4s" % (value)
self.parent.temp[str(sourceName)] = "%4s" % (value)
elif (str(sourceName).split('/')[0] == "partitions"):
value = str(round(float(data[QString(u'value')]), 1))
self.parent.mount['/'+'/'.join(str(sourceName).split('/')[1:-1])] = "%5s" % (value)

View File

@ -133,8 +133,8 @@ class pyTextWidget(plasmascript.Applet):
'cpuclock':'[mhz: $cpucl]', 'custom':'[$custom]', 'gpu':'[gpu: $gpu%]',
'gputemp':'[gpu temp: $gputemp°C]', 'hdd':'[hdd: $hdd0%]',
'hddtemp':'[hdd temp: $hddtemp0°C]', 'mem':'[mem: $mem%]',
'net':'[$netdev: $netKB/s]', 'swap':'[swap: $swap%]',
'temp':'[temp: $temp°C]', 'uptime':'[uptime: $uptime]',
'net':'[$netdev: $down/$upKB/s]', 'swap':'[swap: $swap%]',
'temp':'[temp: $temp0°C]', 'uptime':'[uptime: $uptime]',
'player':'[$artist - $title]', 'time':'[$time]'}
@ -164,6 +164,8 @@ class pyTextWidget(plasmascript.Applet):
self.cpuText()
if (self.cpuclockBool > 0):
self.cpuclockText()
if (self.customBool > 0):
self.getCustom()
if (self.hddBool > 0):
self.mountText()
if ((self.memBool > 0) and (self.memInMb == False)):
@ -218,12 +220,12 @@ class pyTextWidget(plasmascript.Applet):
def cpuclockText(self):
"""function to set cpu clock text"""
line = self.cpuclockFormat
for core in self.cpuclockCore.keys():
for core in self.cpuClockCore.keys():
if (core > -1):
if (line.split('$cpucl'+str(core))[0] != line):
line = line.split('$cpucl'+str(core))[0] + self.cpuclockCore[core] + line.split('$cpucl'+str(core))[1]
line = line.split('$cpucl'+str(core))[0] + self.cpuClockCore[core] + line.split('$cpucl'+str(core))[1]
if (line.split('$cpucl')[0] != line):
line = line.split('$cpucl')[0] + self.cpuclockCore[-1] + line.split('$cpucl')[1]
line = line.split('$cpucl')[0] + self.cpuClockCore[-1] + line.split('$cpucl')[1]
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
self.label_cpuclock.setText(text)
@ -247,7 +249,7 @@ class pyTextWidget(plasmascript.Applet):
def mountText(self):
"""function to set mount text"""
line = self.hddFormat
for i in self.mountNames:
for i in range(len(self.mountNames)):
if (line.split('$hdd'+str(i))[0] != line):
line = line.split('$hdd'+str(i))[0] + self.mount[self.mountNames[i]] + line.split('$hdd'+str(i))[1]
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
@ -284,13 +286,22 @@ class pyTextWidget(plasmascript.Applet):
def tempText(self):
"""function to set temperature text"""
line = self.tempFormat
for i in self.tempNames:
for i in range(len(self.tempNames)):
if (line.split('$temp'+str(i))[0] != line):
line = line.split('$temp'+str(i))[0] + self.temp[self.tempNames[i]] + line.split('$temp'+str(i))[1]
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
self.label_temp.setText(text)
def getCustom(self):
"""function to get output from custom command"""
commandOut = commands.getoutput(self.custom_command)
line = self.customFormat
line = line.split('$custom')[0] + commandOut + line.split('$custom')[1]
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
self.label_custom.setText(text)
@pyqtSignature("dataUpdated(const QString &, const Plasma::DataEngine::Data &)")
def dataUpdated(self, sourceName, data):
"""function to update label"""

View File

@ -104,7 +104,7 @@ class Reinit():
self.parent.layout.addItem(self.parent.label_cpu)
elif (order == "2"):
if (self.parent.tempBool > 0):
self.parent.tempFormat = str(settings.get('tempFormat', '[temp: $temp°C]'))
self.parent.tempFormat = str(settings.get('tempFormat', '[temp: $temp0°C]'))
self.parent.label_temp = NewPlasmaLabel(self.parent.applet, self.parent)
line = self.parent.tempFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
@ -141,7 +141,7 @@ class Reinit():
self.parent.layout.addItem(self.parent.label_swap)
elif (order == "5"):
if (self.parent.netBool > 0):
self.parent.netNonFormat = str(settings.get('netNonFormat', '[net: $netKB/s]'))
self.parent.netNonFormat = str(settings.get('netNonFormat', '[net: $down/$upKB/s]'))
self.parent.label_net = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.netdevBool > 0):
self.parent.netdev = self.parent.custom_netdev