mirror of
https://github.com/gryf/wicd.git
synced 2025-12-24 15:12:31 +01:00
Simplify the inheritance of static wnettools functions in the backends.
Make sure we select a default route flushing tool.
This commit is contained in:
@@ -31,9 +31,9 @@ class WirelessInterface() -- Control a wireless network interface.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import wicd.misc as misc
|
||||
import wicd.wnettools as wnettools
|
||||
|
||||
from wicd import misc
|
||||
from wicd import wnettools
|
||||
from wicd.wnettools import *
|
||||
import re
|
||||
import os
|
||||
import os.path
|
||||
@@ -78,30 +78,6 @@ auth_pattern = re.compile('.*wpa_state=(.*?)\n', re.I | re.M | re.S)
|
||||
RALINK_DRIVER = 'ralink legacy'
|
||||
|
||||
|
||||
def SetDNS(*args, **kargs):
|
||||
""" Call the wnettools SetDNS method. """
|
||||
return wnettools.SetDNS(*args, **kargs)
|
||||
|
||||
def GetDefaultGateway(*args, **kargs):
|
||||
""" Call the wnettools GetDefaultGateway method. """
|
||||
return wnettools.GetDefaultGateway(*args, **kargs)
|
||||
|
||||
def StopDHCP(*args, **kargs):
|
||||
""" Call the wnettools StopDHCP method. """
|
||||
return wnettools.StopDHCP(*args, **kargs)
|
||||
|
||||
def GetWirelessInterfaces(*args, **kargs):
|
||||
""" Call the wnettools GetWirelessInterfaces method. """
|
||||
return wnettools.GetWirelessInterfaces(*args, **kargs)
|
||||
|
||||
def GetWiredInterfaces(*args, **kargs):
|
||||
""" Call the wnettools GetWiredInterfaces method. """
|
||||
return wnettools.GetWiredInterfaces(*args, **kargs)
|
||||
|
||||
def IsValidWpaSuppDriver(*args, **kargs):
|
||||
""" Call the wnettools IsValidWpaSuppDrive method. """
|
||||
return wnettools.IsValidWpaSuppDriver(*args, **kargs)
|
||||
|
||||
def NeedsExternalCalls(*args, **kargs):
|
||||
""" Return True, since this backend using iwconfig/ifconfig. """
|
||||
return True
|
||||
|
||||
@@ -31,9 +31,10 @@ class WirelessInterface() -- Control a wireless network interface.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import wicd.misc as misc
|
||||
import wicd.wnettools as wnettools
|
||||
import wicd.wpath as wpath
|
||||
from wicd import misc
|
||||
from wicd import wnettools
|
||||
from wicd import wpath
|
||||
from wicd.wnettools import *
|
||||
|
||||
import iwscan
|
||||
import wpactrl
|
||||
@@ -82,29 +83,6 @@ SIOCGMIIPHY = 0x8947
|
||||
SIOCETHTOOL = 0x8946
|
||||
SIOCGIFFLAGS = 0x8913
|
||||
|
||||
def SetDNS(*args, **kargs):
|
||||
""" Call the wnettools SetDNS method. """
|
||||
return wnettools.SetDNS(*args, **kargs)
|
||||
|
||||
def GetDefaultGateway(*args, **kargs):
|
||||
""" Call the wnettools GetDefaultGateway method. """
|
||||
return wnettools.GetDefaultGateway(*args, **kargs)
|
||||
|
||||
def StopDHCP(*args, **kargs):
|
||||
""" Call the wnettools StopDHCP method. """
|
||||
return wnettools.StopDHCP(*args, **kargs)
|
||||
|
||||
def GetWirelessInterfaces(*args, **kargs):
|
||||
""" Call the wnettools GetWirelessInterfaces method. """
|
||||
return wnettools.GetWirelessInterfaces(*args, **kargs)
|
||||
|
||||
def GetWiredInterfaces(*args, **kargs):
|
||||
""" Call the wnettools GetWiredInterfaces method. """
|
||||
return wnettools.GetWiredInterfaces(*args, **kargs)
|
||||
|
||||
def IsValidWpaSuppDriver(*args, **kargs):
|
||||
""" Call the wnettools IsValidWpaSuppDrive method. """
|
||||
return wnettools.IsValidWpaSuppDriver(*args, **kargs)
|
||||
|
||||
def get_iw_ioctl_result(iface, call):
|
||||
""" Makes the given ioctl call and returns the results.
|
||||
|
||||
@@ -47,6 +47,9 @@ blacklist_strict = '!"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ '
|
||||
blacklist_norm = ";`$!*|><&\\"
|
||||
blank_trans = maketrans("", "")
|
||||
|
||||
__all__ = ["SetDNS", "GetDefaultGateway", "GetWiredInterfaces", "StopDHCP",
|
||||
"GetWirelessInterfaces", "IsValidWpaSuppDriver", "NeedsExternalCalls"]
|
||||
|
||||
def _sanitize_string(string):
|
||||
if string:
|
||||
return translate(str(string), blank_trans, blacklist_norm)
|
||||
@@ -483,9 +486,12 @@ class BaseInterface(object):
|
||||
if self.route_cmd and self.flush_tool == misc.ROUTE:
|
||||
cmds = ['%s del default' % self.route_cmd]
|
||||
cmds.append('route del dev %s' % self.iface)
|
||||
elif self.ip_cmd and self.flush_tool == misc.IP:
|
||||
elif self.ip_cmd:
|
||||
#cmd = "ip route flush dev " + self.iface
|
||||
cmds = ['%s route flush all' % self.ip_cmd]
|
||||
else:
|
||||
print "No flush command available!"
|
||||
cmds = []
|
||||
for cmd in cmds:
|
||||
if self.verbose: print cmd
|
||||
misc.Run(cmd)
|
||||
|
||||
Reference in New Issue
Block a user