mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-09-05 15:19:56 +00:00
- deleted setup number of network devices
* edited error checking
This commit is contained in:
@ -134,10 +134,7 @@ class ConfigDefinition:
|
|||||||
exec ('self.parent.' + self.parent.dict_orders[label] + 'Format = str(self.configpage.lineedits[self.parent.dict_orders[label]].text())')
|
exec ('self.parent.' + self.parent.dict_orders[label] + 'Format = str(self.configpage.lineedits[self.parent.dict_orders[label]].text())')
|
||||||
exec ('settings.set("' + self.parent.dict_orders[label] + 'Format", self.parent.' + self.parent.dict_orders[label] + 'Format)')
|
exec ('settings.set("' + self.parent.dict_orders[label] + 'Format", self.parent.' + self.parent.dict_orders[label] + 'Format)')
|
||||||
exec ('settings.set("' + self.parent.dict_orders[label] + 'Bool", self.parent.' + self.parent.dict_orders[label] + 'Bool)')
|
exec ('settings.set("' + self.parent.dict_orders[label] + 'Bool", self.parent.' + self.parent.dict_orders[label] + 'Bool)')
|
||||||
if (self.parent.dict_orders[label] == 'net'):
|
if (self.parent.dict_orders[label] == 'bat'):
|
||||||
self.parent.num_dev = self.configpage.ui.comboBox_numNet.currentIndex()
|
|
||||||
settings.set('num_dev', self.parent.num_dev)
|
|
||||||
elif (self.parent.dict_orders[label] == 'bat'):
|
|
||||||
self.parent.battery_device = str(self.configpage.ui.lineEdit_batdev.text())
|
self.parent.battery_device = str(self.configpage.ui.lineEdit_batdev.text())
|
||||||
self.parent.ac_device = str(self.configpage.ui.lineEdit_acdev.text())
|
self.parent.ac_device = str(self.configpage.ui.lineEdit_acdev.text())
|
||||||
settings.set('battery_device', self.parent.battery_device)
|
settings.set('battery_device', self.parent.battery_device)
|
||||||
@ -176,7 +173,6 @@ class ConfigDefinition:
|
|||||||
else:
|
else:
|
||||||
self.configpage.checkboxes[self.parent.dict_orders[label]].setCheckState(0)
|
self.configpage.checkboxes[self.parent.dict_orders[label]].setCheckState(0)
|
||||||
if (self.parent.dict_orders[label] == 'net'):
|
if (self.parent.dict_orders[label] == 'net'):
|
||||||
self.configpage.ui.comboBox_numNet.setCurrentIndex(settings.get('num_dev', 0).toInt()[0])
|
|
||||||
self.configpage.lineedits[self.parent.dict_orders[label]].setText(str(settings.get(self.parent.dict_orders[label] + 'NonFormat', self.parent.dict_defFormat[self.parent.dict_orders[label]])))
|
self.configpage.lineedits[self.parent.dict_orders[label]].setText(str(settings.get(self.parent.dict_orders[label] + 'NonFormat', self.parent.dict_defFormat[self.parent.dict_orders[label]])))
|
||||||
else:
|
else:
|
||||||
self.configpage.lineedits[self.parent.dict_orders[label]].setText(str(settings.get(self.parent.dict_orders[label] + 'Format', self.parent.dict_defFormat[self.parent.dict_orders[label]])))
|
self.configpage.lineedits[self.parent.dict_orders[label]].setText(str(settings.get(self.parent.dict_orders[label] + 'Format', self.parent.dict_defFormat[self.parent.dict_orders[label]])))
|
||||||
|
@ -49,8 +49,6 @@ class ConfigWindow(QWidget):
|
|||||||
if (label == 'bat'):
|
if (label == 'bat'):
|
||||||
self.ui.lineEdit_acdev.setEnabled(True)
|
self.ui.lineEdit_acdev.setEnabled(True)
|
||||||
self.ui.lineEdit_batdev.setEnabled(True)
|
self.ui.lineEdit_batdev.setEnabled(True)
|
||||||
elif (label == 'net'):
|
|
||||||
self.ui.comboBox_numNet.setEnabled(True)
|
|
||||||
elif (label == 'temp'):
|
elif (label == 'temp'):
|
||||||
self.ui.comboBox_temp.setEnabled(True)
|
self.ui.comboBox_temp.setEnabled(True)
|
||||||
slider_label = 0
|
slider_label = 0
|
||||||
@ -69,8 +67,6 @@ class ConfigWindow(QWidget):
|
|||||||
if (label == 'bat'):
|
if (label == 'bat'):
|
||||||
self.ui.lineEdit_acdev.setDisabled(True)
|
self.ui.lineEdit_acdev.setDisabled(True)
|
||||||
self.ui.lineEdit_batdev.setDisabled(True)
|
self.ui.lineEdit_batdev.setDisabled(True)
|
||||||
elif (label == 'net'):
|
|
||||||
self.ui.comboBox_numNet.setDisabled(True)
|
|
||||||
elif (label == 'temp'):
|
elif (label == 'temp'):
|
||||||
self.ui.comboBox_temp.setDisabled(True)
|
self.ui.comboBox_temp.setDisabled(True)
|
||||||
for slider in self.sliders.values():
|
for slider in self.sliders.values():
|
||||||
|
@ -60,22 +60,19 @@ class pyTextWidget(plasmascript.Applet):
|
|||||||
|
|
||||||
def setupNetdev(self):
|
def setupNetdev(self):
|
||||||
"""function to setup network device"""
|
"""function to setup network device"""
|
||||||
if (self.num_dev == 0):
|
self.netdev = "lo"
|
||||||
for line in commands.getoutput("ifconfig -a").split("\n"):
|
try:
|
||||||
if (line != ''):
|
|
||||||
if ((line[0] != ' ') and (line[0:3] != "lo:")):
|
|
||||||
self.netdev = line.split()[0][:-1]
|
|
||||||
else:
|
|
||||||
interfaces = []
|
interfaces = []
|
||||||
for line in commands.getoutput("ifconfig -a").split("\n"):
|
for line in commands.getoutput("ifconfig -a").split("\n"):
|
||||||
if (line != ''):
|
if ((line != '') and (line[0] != ' ') and (line[0:3] != 'lo:')):
|
||||||
if ((line[0] != ' ') and (line[0:3] != "lo:")):
|
interfaces.append(line.split(":")[0])
|
||||||
interfaces.append(line.split()[0][:-1])
|
|
||||||
|
for device in interfaces:
|
||||||
command_line = "if ! (ifconfig "+ interfaces[1] + " | grep 'inet ' > /dev/null); then "
|
if (commands.getoutput("ifconfig " + device + " | grep 'inet '") != ''):
|
||||||
command_line = command_line + "if ! (ifconfig "+ interfaces[0] + " | grep 'inet ' > /dev/null); then echo lo; "
|
self.netdev = device
|
||||||
command_line = command_line + "else echo "+ interfaces[0] + "; fi; else echo "+ interfaces[1] + "; fi"
|
break
|
||||||
self.netdev = commands.getoutput(command_line)
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def setupVar(self):
|
def setupVar(self):
|
||||||
@ -126,23 +123,23 @@ class pyTextWidget(plasmascript.Applet):
|
|||||||
"""function to set battery text"""
|
"""function to set battery text"""
|
||||||
line = self.batFormat
|
line = self.batFormat
|
||||||
if (line.split('$bat')[0] != line):
|
if (line.split('$bat')[0] != line):
|
||||||
if os.path.exists(self.battery_device):
|
try:
|
||||||
with open (self.battery_device, 'r') as bat_file:
|
with open (self.battery_device, 'r') as bat_file:
|
||||||
bat = bat_file.readline().split('\n')[0]
|
bat = bat_file.readline().split('\n')[0]
|
||||||
else:
|
except:
|
||||||
bat = 'off'
|
bat = 'off'
|
||||||
bat = "%3s" % (bat)
|
bat = "%3s" % (bat)
|
||||||
line = line.split('$bat')[0] + bat + line.split('$bat')[1]
|
line = line.split('$bat')[0] + bat + line.split('$bat')[1]
|
||||||
|
|
||||||
if (line.split('$ac')[0] != line):
|
if (line.split('$ac')[0] != line):
|
||||||
if os.path.exists(self.ac_device):
|
try:
|
||||||
with open (self.ac_device, 'r') as bat_file:
|
with open (self.ac_device, 'r') as bat_file:
|
||||||
bat = bat_file.readline().split('\n')[0]
|
bat = bat_file.readline().split('\n')[0]
|
||||||
if (bat == '1'):
|
if (bat == '1'):
|
||||||
bat = '(*)'
|
bat = '(*)'
|
||||||
else:
|
else:
|
||||||
bat = '( )'
|
bat = '( )'
|
||||||
else:
|
except:
|
||||||
bat = '(?)'
|
bat = '(?)'
|
||||||
line = line.split('$ac')[0] + bat + line.split('$ac')[1]
|
line = line.split('$ac')[0] + bat + line.split('$ac')[1]
|
||||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||||
|
@ -132,7 +132,6 @@ class Reinit():
|
|||||||
self.parent.netdev = self.parent.netNonFormat.split('@@')[1]
|
self.parent.netdev = self.parent.netNonFormat.split('@@')[1]
|
||||||
self.parent.netNonFormat = self.parent.netNonFormat.split('@@')[0] + self.parent.netNonFormat.split('@@')[2]
|
self.parent.netNonFormat = self.parent.netNonFormat.split('@@')[0] + self.parent.netNonFormat.split('@@')[2]
|
||||||
else:
|
else:
|
||||||
self.parent.num_dev = int(settings.get('num_dev', 0))
|
|
||||||
self.parent.setupNetdev()
|
self.parent.setupNetdev()
|
||||||
if (self.parent.netNonFormat.split('$netdev')[0] != self.parent.netNonFormat):
|
if (self.parent.netNonFormat.split('$netdev')[0] != self.parent.netNonFormat):
|
||||||
self.parent.netFormat = self.parent.netNonFormat.split('$netdev')[0] + self.parent.netdev + self.parent.netNonFormat.split('$netdev')[1]
|
self.parent.netFormat = self.parent.netNonFormat.split('$netdev')[0] + self.parent.netdev + self.parent.netNonFormat.split('$netdev')[1]
|
||||||
|
@ -1302,38 +1302,6 @@ $swapmb - swap usage, MB</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="comboBox_numNet">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>100</width>
|
|
||||||
<height>25</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>100</width>
|
|
||||||
<height>25</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">One device</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">Two devices</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEdit_net">
|
<widget class="QLineEdit" name="lineEdit_net">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@ -2296,7 +2264,6 @@ $ac - AC status</string>
|
|||||||
<tabstop>lineEdit_hddTemp</tabstop>
|
<tabstop>lineEdit_hddTemp</tabstop>
|
||||||
<tabstop>slider_hddTemp</tabstop>
|
<tabstop>slider_hddTemp</tabstop>
|
||||||
<tabstop>checkBox_net</tabstop>
|
<tabstop>checkBox_net</tabstop>
|
||||||
<tabstop>comboBox_numNet</tabstop>
|
|
||||||
<tabstop>lineEdit_net</tabstop>
|
<tabstop>lineEdit_net</tabstop>
|
||||||
<tabstop>slider_net</tabstop>
|
<tabstop>slider_net</tabstop>
|
||||||
<tabstop>checkBox_bat</tabstop>
|
<tabstop>checkBox_bat</tabstop>
|
||||||
|
Reference in New Issue
Block a user