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

fixed indentation problems

This commit is contained in:
compwiz18
2007-09-04 02:43:25 +00:00
parent 7176183b47
commit 64e5c27ba2
6 changed files with 62 additions and 57 deletions

View File

@@ -455,8 +455,8 @@ class ConnectionWizard(dbus.service.Object):
for i, network in enumerate(scan): for i, network in enumerate(scan):
self.ReadWirelessNetworkProfile(i) self.ReadWirelessNetworkProfile(i)
print print
# This is unfinished so not on dbus yet # This is unfinished so not on dbus yet
def AutoConnectScan(self): def AutoConnectScan(self):
''' Scan for networks and for known hidden networks ''' Scan for networks and for known hidden networks
@@ -1110,7 +1110,7 @@ class ConnectionWizard(dbus.service.Object):
if iface: if iface:
self.SetWirelessInterface(iface) self.SetWirelessInterface(iface)
else: else:
self.SetWirelessInterface("wlan0") self.SetWirelessInterface("wlan0")
self.SetWiredInterface("eth0") self.SetWiredInterface("eth0")
self.SetWPADriver("wext") self.SetWPADriver("wext")
self.SetAlwaysShowWiredInterface(0) self.SetAlwaysShowWiredInterface(0)

49
edgy.py
View File

@@ -19,7 +19,8 @@ reconnect when needed
##thanks to Arne Brix for programming most of this ##thanks to Arne Brix for programming most of this
##released under the GNU Public License ##released under the GNU Public License
##see http://www.gnu.org/copyleft/gpl.html for details ##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 ##to run the tray icon
######## ########
import os import os
@@ -143,24 +144,24 @@ class TrayIconInfo():
def update_tray_icon(self): def update_tray_icon(self):
''' updates tray icon and checks if wired profile chooser should run ''' ''' updates tray icon and checks if wired profile chooser should run '''
# Disable logging if debugging isn't on to prevent log spam # Disable logging if debugging isn't on to prevent log spam
if not daemon.GetDebugMode(): if not daemon.GetDebugMode():
config.DisableLogging() config.DisableLogging()
# First check for an active wired network, then for an # First check for an active wired network, then for an
# active wireless network. If neither is found, change # active wireless network. If neither is found, change
# icon to reflect that and run auto_reconnect() # icon to reflect that and run auto_reconnect()
wired_ip = wired.GetWiredIP() wired_ip = wired.GetWiredIP()
if wired_ip is not None and wired.CheckPluggedIn(): if wired_ip is not None and wired.CheckPluggedIn():
self.check_for_wired_connection(wired_ip) self.check_for_wired_connection(wired_ip)
else: else:
self.still_wired = False # We're not wired any more self.still_wired = False # We're not wired any more
wireless_ip = wireless.GetWirelessIP() wireless_ip = wireless.GetWirelessIP()
if wireless_ip is not None: if wireless_ip is not None:
self.check_for_wireless_connection(wireless_ip) self.check_for_wireless_connection(wireless_ip)
else: # No connection at all else: # No connection at all
tr.set_from_file("images/no-signal.png") tr.set_from_file("images/no-signal.png")
tr.set_tooltip(language['not_connected']) tr.set_tooltip(language['not_connected'])
self.auto_reconnect() self.auto_reconnect()
if not daemon.GetDebugMode(): if not daemon.GetDebugMode():
@@ -170,18 +171,18 @@ class TrayIconInfo():
def set_signal_image(self, wireless_signal, lock): def set_signal_image(self, wireless_signal, lock):
''' Sets the tray icon picture for an active wireless connection ''' ''' Sets the tray icon picture for an active wireless connection '''
if wireless_signal > 75: if wireless_signal > 75:
tr.set_from_file("images/high-signal" + lock + ".png") tr.set_from_file("images/high-signal" + lock + ".png")
elif wireless_signal > 50: elif wireless_signal > 50:
tr.set_from_file("images/good-signal" + lock + ".png") tr.set_from_file("images/good-signal" + lock + ".png")
elif wireless_signal > 25: elif wireless_signal > 25:
tr.set_from_file("images/low-signal" + lock + ".png") tr.set_from_file("images/low-signal" + lock + ".png")
elif wireless_signal > 0: elif wireless_signal > 0:
tr.set_from_file("images/bad-signal" + lock + ".png") tr.set_from_file("images/bad-signal" + lock + ".png")
elif wireless_signal == 0: elif wireless_signal == 0:
tr.set_from_file("images/no-signal.png") tr.set_from_file("images/no-signal.png")
# If we have no signal, we should try to reconnect. # If we have no signal, we should try to reconnect.
self.auto_reconnect() self.auto_reconnect()
def auto_reconnect(self): def auto_reconnect(self):
''' Automatically reconnects to a network if needed ''' Automatically reconnects to a network if needed
@@ -197,7 +198,7 @@ class TrayIconInfo():
cur_net_id = wireless.GetCurrentNetworkID() cur_net_id = wireless.GetCurrentNetworkID()
if cur_net_id > -1: # Needs to be a valid network if cur_net_id > -1: # Needs to be a valid network
if not self.tried_reconnect: 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) wireless.ConnectWireless(cur_net_id)
self.tried_reconnect = True self.tried_reconnect = True
elif wireless.CheckIfWirelessConnecting() == False: elif wireless.CheckIfWirelessConnecting() == False:

5
gui.py
View File

@@ -339,7 +339,10 @@ class PrettyWirelessNetworkEntry(PrettyNetworkEntry):
self.show_all() self.show_all()
def setSignalStrength(self,strength, dbm_strength): 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: if dbm_strength is not None:
dbm_strength = int(dbm_strength) dbm_strength = int(dbm_strength)
else: else:

48
misc.py
View File

@@ -138,13 +138,13 @@ def ParseEncryption(network):
fileness.close() fileness.close()
def LoadEncryptionMethods(): def LoadEncryptionMethods():
''' Load encryption methods from configuration files ''' Load encryption methods from configuration files
Loads all the encryption methods from the template files Loads all the encryption methods from the template files
in /encryption/templates into a data structure. To be in /encryption/templates into a data structure. To be
loaded, the template must be listed in the "active" file. loaded, the template must be listed in the "active" file.
''' '''
encryptionTypes = {} encryptionTypes = {}
types = open("encryption/templates/active","r") types = open("encryption/templates/active","r")
enctypes = types.readlines() enctypes = types.readlines()
@@ -156,27 +156,27 @@ def LoadEncryptionMethods():
line = current.readlines() line = current.readlines()
# Get the length so we know where in the array to add data # Get the length so we know where in the array to add data
typeID = len(encryptionTypes) typeID = len(encryptionTypes)
encryptionTypes[typeID] = {} encryptionTypes[typeID] = {}
encryptionTypes[typeID][0] = line[0][7:].strip("\n") encryptionTypes[typeID][0] = line[0][7:].strip("\n")
encryptionTypes[typeID][1] = x encryptionTypes[typeID][1] = x
encryptionTypes[typeID][2] = {} encryptionTypes[typeID][2] = {}
requiredFields = line[3][8:] requiredFields = line[3][8:]
requiredFields = requiredFields.strip("\n") requiredFields = requiredFields.strip("\n")
requiredFields = requiredFields.split(" ") requiredFields = requiredFields.split(" ")
index = -1 index = -1
for current in requiredFields: for current in requiredFields:
# The pretty names will start with an * so we can # The pretty names will start with an * so we can
#seperate them with that #seperate them with that
if current[0] == "*": if current[0] == "*":
# Make underscores spaces # Make underscores spaces
#and remove the * #and remove the *
encryptionTypes[typeID][2][index][0] = current.replace("_", encryptionTypes[typeID][2][index][0] = current.replace("_",
" ").lstrip("*") " ").lstrip("*")
else: else:
# Add to the list of things that are required # Add to the list of things that are required
index = len(encryptionTypes[typeID][2]) index = len(encryptionTypes[typeID][2])
encryptionTypes[typeID][2][index] = {} encryptionTypes[typeID][2][index] = {}
encryptionTypes[typeID][2][index][1] = current encryptionTypes[typeID][2][index][1] = current
return encryptionTypes return encryptionTypes
def noneToString(text): def noneToString(text):

View File

@@ -175,8 +175,9 @@ class Wireless(Controller):
wiface.SetEssid(essid) wiface.SetEssid(essid)
aps = wiface.GetNetworks() aps = wiface.GetNetworks()
aps.sort(key=lambda x: x['quality']) print aps
aps.reverse() aps.sort(key=lambda x: x['strength'])
#aps.reverse()
return aps return aps

View File

@@ -388,11 +388,11 @@ class WirelessInterface(Interface):
# Link Quality # Link Quality
# Set strength to -1 if the quality is not found # Set strength to -1 if the quality is not found
if misc.RunRegex(strength_pattern,cell): 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): elif misc.RunRegex(altstrength_pattern,cell):
ap['quality'] = misc.RunRegex(altstrength_pattern,cell) ap['quality'] = misc.RunRegex(altstrength_pattern,cell)
else: else:
ap['quality'] = -1 ap['quality'] = -1
# Signal Strength (only used if user doesn't want link # Signal Strength (only used if user doesn't want link
# quality displayed or it isn't found) # quality displayed or it isn't found)