diff --git a/daemon.py b/daemon.py index 61410e3..e32fe44 100644 --- a/daemon.py +++ b/daemon.py @@ -455,8 +455,8 @@ class ConnectionWizard(dbus.service.Object): for i, network in enumerate(scan): self.ReadWirelessNetworkProfile(i) print - - # This is unfinished so not on dbus yet + + # This is unfinished so not on dbus yet def AutoConnectScan(self): ''' Scan for networks and for known hidden networks @@ -1110,7 +1110,7 @@ class ConnectionWizard(dbus.service.Object): if iface: self.SetWirelessInterface(iface) else: - self.SetWirelessInterface("wlan0") + self.SetWirelessInterface("wlan0") self.SetWiredInterface("eth0") self.SetWPADriver("wext") self.SetAlwaysShowWiredInterface(0) diff --git a/edgy.py b/edgy.py index 692af88..0ba01af 100755 --- a/edgy.py +++ b/edgy.py @@ -19,7 +19,8 @@ reconnect when needed ##thanks to Arne Brix for programming most of this ##released under the GNU Public License ##see http://www.gnu.org/copyleft/gpl.html for details -##this will only work in Edgy and above because of gtk requirements +##this will only work if the GTK version is above 2.10.0 +##as it is in Ubuntu Edgy ##to run the tray icon ######## import os @@ -143,24 +144,24 @@ class TrayIconInfo(): def update_tray_icon(self): ''' updates tray icon and checks if wired profile chooser should run ''' - # Disable logging if debugging isn't on to prevent log spam - if not daemon.GetDebugMode(): - config.DisableLogging() + # Disable logging if debugging isn't on to prevent log spam + if not daemon.GetDebugMode(): + config.DisableLogging() - # First check for an active wired network, then for an - # active wireless network. If neither is found, change - # icon to reflect that and run auto_reconnect() - wired_ip = wired.GetWiredIP() + # First check for an active wired network, then for an + # active wireless network. If neither is found, change + # icon to reflect that and run auto_reconnect() + wired_ip = wired.GetWiredIP() if wired_ip is not None and wired.CheckPluggedIn(): self.check_for_wired_connection(wired_ip) - else: + else: self.still_wired = False # We're not wired any more wireless_ip = wireless.GetWirelessIP() if wireless_ip is not None: self.check_for_wireless_connection(wireless_ip) else: # No connection at all - tr.set_from_file("images/no-signal.png") - tr.set_tooltip(language['not_connected']) + tr.set_from_file("images/no-signal.png") + tr.set_tooltip(language['not_connected']) self.auto_reconnect() if not daemon.GetDebugMode(): @@ -170,18 +171,18 @@ class TrayIconInfo(): def set_signal_image(self, wireless_signal, lock): ''' Sets the tray icon picture for an active wireless connection ''' - if wireless_signal > 75: - tr.set_from_file("images/high-signal" + lock + ".png") - elif wireless_signal > 50: - tr.set_from_file("images/good-signal" + lock + ".png") - elif wireless_signal > 25: - tr.set_from_file("images/low-signal" + lock + ".png") - elif wireless_signal > 0: - tr.set_from_file("images/bad-signal" + lock + ".png") - elif wireless_signal == 0: - tr.set_from_file("images/no-signal.png") - # If we have no signal, we should try to reconnect. - self.auto_reconnect() + if wireless_signal > 75: + tr.set_from_file("images/high-signal" + lock + ".png") + elif wireless_signal > 50: + tr.set_from_file("images/good-signal" + lock + ".png") + elif wireless_signal > 25: + tr.set_from_file("images/low-signal" + lock + ".png") + elif wireless_signal > 0: + tr.set_from_file("images/bad-signal" + lock + ".png") + elif wireless_signal == 0: + tr.set_from_file("images/no-signal.png") + # If we have no signal, we should try to reconnect. + self.auto_reconnect() def auto_reconnect(self): ''' Automatically reconnects to a network if needed @@ -197,7 +198,7 @@ class TrayIconInfo(): cur_net_id = wireless.GetCurrentNetworkID() if cur_net_id > -1: # Needs to be a valid network if not self.tried_reconnect: - print 'Trying to autoreconnect to last used network' + print 'Trying to autoreconnect to last used network' wireless.ConnectWireless(cur_net_id) self.tried_reconnect = True elif wireless.CheckIfWirelessConnecting() == False: diff --git a/gui.py b/gui.py index 6e251ed..8a21a53 100644 --- a/gui.py +++ b/gui.py @@ -339,7 +339,10 @@ class PrettyWirelessNetworkEntry(PrettyNetworkEntry): self.show_all() def setSignalStrength(self,strength, dbm_strength): - strength = int(strength) + if strength is not None: + strength = int(strength) + else: + dbm_strength = -1 if dbm_strength is not None: dbm_strength = int(dbm_strength) else: diff --git a/misc.py b/misc.py index bdfd94d..292b364 100644 --- a/misc.py +++ b/misc.py @@ -138,13 +138,13 @@ def ParseEncryption(network): fileness.close() def LoadEncryptionMethods(): - ''' Load encryption methods from configuration files + ''' Load encryption methods from configuration files - Loads all the encryption methods from the template files - in /encryption/templates into a data structure. To be - loaded, the template must be listed in the "active" file. + Loads all the encryption methods from the template files + in /encryption/templates into a data structure. To be + loaded, the template must be listed in the "active" file. - ''' + ''' encryptionTypes = {} types = open("encryption/templates/active","r") enctypes = types.readlines() @@ -156,27 +156,27 @@ def LoadEncryptionMethods(): line = current.readlines() # Get the length so we know where in the array to add data typeID = len(encryptionTypes) - encryptionTypes[typeID] = {} - encryptionTypes[typeID][0] = line[0][7:].strip("\n") - encryptionTypes[typeID][1] = x - encryptionTypes[typeID][2] = {} - requiredFields = line[3][8:] - requiredFields = requiredFields.strip("\n") - requiredFields = requiredFields.split(" ") - index = -1 - for current in requiredFields: - # The pretty names will start with an * so we can - #seperate them with that - if current[0] == "*": + encryptionTypes[typeID] = {} + encryptionTypes[typeID][0] = line[0][7:].strip("\n") + encryptionTypes[typeID][1] = x + encryptionTypes[typeID][2] = {} + requiredFields = line[3][8:] + requiredFields = requiredFields.strip("\n") + requiredFields = requiredFields.split(" ") + index = -1 + for current in requiredFields: + # The pretty names will start with an * so we can + #seperate them with that + if current[0] == "*": # Make underscores spaces - #and remove the * + #and remove the * encryptionTypes[typeID][2][index][0] = current.replace("_", - " ").lstrip("*") - else: - # Add to the list of things that are required - index = len(encryptionTypes[typeID][2]) - encryptionTypes[typeID][2][index] = {} - encryptionTypes[typeID][2][index][1] = current + " ").lstrip("*") + else: + # Add to the list of things that are required + index = len(encryptionTypes[typeID][2]) + encryptionTypes[typeID][2][index] = {} + encryptionTypes[typeID][2][index][1] = current return encryptionTypes def noneToString(text): diff --git a/networking.py b/networking.py index 18480d1..0353f3b 100644 --- a/networking.py +++ b/networking.py @@ -175,8 +175,9 @@ class Wireless(Controller): wiface.SetEssid(essid) aps = wiface.GetNetworks() - aps.sort(key=lambda x: x['quality']) - aps.reverse() + print aps + aps.sort(key=lambda x: x['strength']) + #aps.reverse() return aps diff --git a/wnettools.py b/wnettools.py index 5510a44..2d32e56 100644 --- a/wnettools.py +++ b/wnettools.py @@ -388,11 +388,11 @@ class WirelessInterface(Interface): # Link Quality # Set strength to -1 if the quality is not found if misc.RunRegex(strength_pattern,cell): - ap['quality'] = misc.RunRegex(strength_pattern,cell) + ap['quality'] = misc.RunRegex(strength_pattern,cell) elif misc.RunRegex(altstrength_pattern,cell): - ap['quality'] = misc.RunRegex(altstrength_pattern,cell) + ap['quality'] = misc.RunRegex(altstrength_pattern,cell) else: - ap['quality'] = -1 + ap['quality'] = -1 # Signal Strength (only used if user doesn't want link # quality displayed or it isn't found)