1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-20 12:58:07 +01:00

Fix up some issues spotted by pychecker.

This commit is contained in:
metrics
2007-08-16 01:53:13 +00:00
parent 4e9e960ac9
commit ccf7960694
2 changed files with 26 additions and 13 deletions

View File

@@ -40,13 +40,10 @@ class WiredConnectThread() -- Connection thread for wired
# and helped keep this project moving # and helped keep this project moving
# #
import os
import sys
import re import re
import sys import sys
import threading import threading
import thread import thread
import operator
import misc import misc
import wnettools import wnettools
import wpath import wpath
@@ -65,6 +62,12 @@ class Controller(object):
after_script = None after_script = None
disconnect_script = None disconnect_script = None
def __init__(self):
""" Initialise the class. """
self.global_dns_1 = None
self.global_dns_2 = None
self.global_dns_3 = None
class ConnectThread(threading.Thread): class ConnectThread(threading.Thread):
@@ -141,7 +144,12 @@ class ConnectThread(threading.Thread):
class Wireless(Controller): class Wireless(Controller):
""" A wrapper for common wireless interface functions. """ """ A wrapper for common wireless interface functions. """
wpa_driver = None def __init__(self):
""" Initialise the class. """
Controller.__init__(self)
self.wpa_driver = None
def Scan(self,essid=None): def Scan(self,essid=None):
""" Scan for available wireless networks. """ Scan for available wireless networks.
@@ -243,7 +251,7 @@ class Wireless(Controller):
wiface.SetChannel(channel) wiface.SetChannel(channel)
wiface.SetEssid(essid) wiface.SetEssid(essid)
#Right now it just assumes you're using WEP #Right now it just assumes you're using WEP
if enc_used == True: if enc_used:
wiface.SetKey(key) wiface.SetKey(key)
wiface.Up() wiface.Up()
@@ -449,6 +457,11 @@ class WirelessConnectThread(ConnectThread):
class Wired(Controller): class Wired(Controller):
""" A wrapper for common wired interface functions. """ """ A wrapper for common wired interface functions. """
def __init__(self):
""" Initialise the class. """
Controller.__init__(self)
self.wpa_driver = None
def CheckPluggedIn(self): def CheckPluggedIn(self):
""" Check whether the wired connection is plugged in. """ Check whether the wired connection is plugged in.
@@ -527,7 +540,7 @@ class WiredConnectThread(ConnectThread):
""" """
ConnectThread.__init__(self, network, wireless, wired, ConnectThread.__init__(self, network, wireless, wired,
before_script, after_script, disconnect_script, gdns1, before_script, after_script, disconnect_script, gdns1,
gdns3, gdns3) gdns2, gdns3)
def run(self): def run(self):

View File

@@ -232,7 +232,7 @@ class WirelessInterface(Interface):
essid -- essid to set the interface to essid -- essid to set the interface to
""" """
cmd = 'iwconfig ' + self.wireless_interface + ' essid "' + essid + '"' cmd = 'iwconfig ' + self.iface + ' essid "' + essid + '"'
if self.verbose: print cmd if self.verbose: print cmd
misc.Run(cmd) misc.Run(cmd)
@@ -354,7 +354,7 @@ class WirelessInterface(Interface):
# Support for ralink legacy drivers (maybe only serialmonkey enhanced), # Support for ralink legacy drivers (maybe only serialmonkey enhanced),
# may not work w/ hidden networks # may not work w/ hidden networks
else: else:
iwpriv = misc.Run('iwpriv ' + self.wireless_interface + ' get_site_survey') iwpriv = misc.Run('iwpriv ' + self.iface + ' get_site_survey')
lines = iwpriv.splitlines() lines = iwpriv.splitlines()
lines = lines[2:] lines = lines[2:]
for x in lines: # Iterate through all networks found for x in lines: # Iterate through all networks found
@@ -403,7 +403,7 @@ class WirelessInterface(Interface):
mode = 'managed' mode = 'managed'
cmd = 'iwconfig ' + self.iface + ' mode ' + mode cmd = 'iwconfig ' + self.iface + ' mode ' + mode
if self.verbose: print cmd if self.verbose: print cmd
results = misc.Run(cmd) misc.Run(cmd)
def SetChannel(self, channel): def SetChannel(self, channel):
@@ -415,7 +415,7 @@ class WirelessInterface(Interface):
""" """
cmd = 'iwconfig ' + self.iface + ' channel ' + str(channel) cmd = 'iwconfig ' + self.iface + ' channel ' + str(channel)
if self.verbose: print cmd if self.verbose: print cmd
results = misc.Run(cmd) misc.Run(cmd)
def SetKey(self, key): def SetKey(self, key):
@@ -427,7 +427,7 @@ class WirelessInterface(Interface):
""" """
cmd = 'iwconfig ' + self.iface + ' key ' + key cmd = 'iwconfig ' + self.iface + ' key ' + key
if self.verbose: print cmd if self.verbose: print cmd
results = misc.Run(cmd) misc.Run(cmd)
def Associate(self, essid, channel=None, bssid=None): def Associate(self, essid, channel=None, bssid=None):
@@ -445,7 +445,7 @@ class WirelessInterface(Interface):
if bssid: if bssid:
cmd += ' ap ' + bssid cmd += ' ap ' + bssid
if self.verbose: print cmd if self.verbose: print cmd
results = misc.Run(cmd) misc.Run(cmd)
def Authenticate(self, network): def Authenticate(self, network):
@@ -457,7 +457,7 @@ class WirelessInterface(Interface):
""" """
misc.ParseEncryption(network) misc.ParseEncryption(network)
if self.wpa_driver == 'ralink legacy': if self.wpa_driver == 'ralink legacy':
_AuthenticateRalinkLegacy(network) self._AuthenticateRalinkLegacy(network)
else: else:
cmd = ('wpa_supplicant -B -i ' + self.iface + ' -c "' cmd = ('wpa_supplicant -B -i ' + self.iface + ' -c "'
+ wpath.networks + network['bssid'].replace(':','').lower() + wpath.networks + network['bssid'].replace(':','').lower()