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