1
0
mirror of https://github.com/gryf/wicd.git synced 2026-02-23 10:35:51 +01:00

Refactored a few daemon methods from bring registered under the 'wireless' service to 'daemon'.

Fixed the wired autoconnect profile chooser, which was badly broken.
Added a check to GetPluggedIn() that makes sure that the wired interface is up before checking.  If it's not, it tries to put it up.  This is necessary because ethtool doesn't make this check for us, as mii-tool did.
This commit is contained in:
imdano
2008-01-22 16:05:30 +00:00
parent c83f18fd65
commit 9bd9605411
5 changed files with 69 additions and 52 deletions

View File

@@ -262,6 +262,10 @@ class WiredInterface(Interface):
"""
link_tool = 'ethtool'
if not self.IsUp():
print 'Wired Interface is down, putting it up'
self.Up()
time.sleep(6)
tool_data = misc.Run(link_tool + ' ' + self.iface, True)
if misc.RunRegex(re.compile('(Operation not supported)|\
(ethtool: command not found)', re.I),
@@ -269,17 +273,26 @@ class WiredInterface(Interface):
print "ethtool check failed, falling back to mii-tool"
link_tool = 'mii-tool'
if misc.RunRegex(re.compile('(Invalid argument)', re.I | re.M | re.S),
tool_data) is not None:
print 'wired interface appears down, putting up for mii-tool check'
self.Up()
tool_data = misc.Run(link_tool + ' ' + self.iface)
tool_data = misc.Run(link_tool + ' ' + self.iface, True)
if misc.RunRegex(re.compile('(Link detected: yes)|(link ok)',
re.I | re.M | re.S), tool_data) is not None:
return True
else:
return False
def IsUp(self):
""" Determines if the interface is up. """
cmd = "ifconfig " + self.iface
output = misc.Run(cmd)
lines = output.split('\n')
if len(lines) < 5:
return False
for line in lines[1:4]:
if line.strip().startswith('UP'):
return True
return False
class WirelessInterface(Interface):