1
0
mirror of https://github.com/gryf/wicd.git synced 2026-01-07 06:14:16 +01:00

merging in a bunch of trunk changes

This commit is contained in:
Dan O'Reilly
2008-12-07 21:15:29 -05:00
parent a6acb8a661
commit 46bbde7745
8 changed files with 79 additions and 25 deletions

View File

@@ -53,7 +53,7 @@ more stable for some set ups.
# Compile the regex patterns that will be used to search the output of iwlist
# scan for info these are well tested, should work on most cards
essid_pattern = re.compile('.*ESSID:(.*?)\n', re.I | re.M | re.S)
essid_pattern = re.compile('.*ESSID:"?(.*?)"?\s*\n', re.I | re.M | re.S)
ap_mac_pattern = re.compile('.*Address: (.*?)\n', re.I | re.M | re.S)
channel_pattern = re.compile('.*Channel:? ?(\d\d?)', re.I | re.M | re.S)
strength_pattern = re.compile('.*Quality:?=? ?(\d+)\s*/?\s*(\d*)', re.I | re.M | re.S)
@@ -330,11 +330,9 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
"""
ap = {}
ap['essid'] = misc.RunRegex(essid_pattern, cell)
if ap['essid']:
ap['essid'] = ap['essid'].strip('"')
try:
ap['essid'] = misc.to_unicode(ap['essid'])
except UnicodeDecodeError, UnicodeEncodeError:
except (UnicodeDecodeError, UnicodeEncodeError):
print 'Unicode problem with current network essid, ignoring!!'
return None
if ap['essid'] in ['<hidden>', ""]:
@@ -494,8 +492,12 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
[(strength, max_strength)] = strength_pattern.findall(output)
if max_strength and strength:
return 100 * int(strength) // int(max_strength)
if int(max_strength) != 0:
return 100 * int(strength) // int(max_strength)
else:
# Prevent a divide by zero error.
ap['quality'] = int(strength)
if strength is None:
strength = misc.RunRegex(altstrength_pattern, output)

View File

@@ -229,7 +229,7 @@ class ConnectionStatus(object):
# Some checks to keep reconnect retries from going crazy.
if self.reconnect_tries > 2 and \
time.time() - self.last_reconnect_time < 90:
time.time() - self.last_reconnect_time < 300:
return
self.reconnecting = True

View File

@@ -102,6 +102,12 @@ class TrayIcon(object):
self.tr = self.StatusTrayIconGUI(use_tray)
self.icon_info = self.TrayConnectionInfo(self.tr, use_tray, animate)
def is_embedded(self):
if USE_EGG:
raise NotImplementedError
else:
return self.tr.is_embedded()
class TrayConnectionInfo(object):
""" Class for updating the tray icon status. """

View File

@@ -862,7 +862,7 @@ class WirelessDaemon(dbus.service.Object):
@dbus.service.method('org.wicd.daemon.wireless')
def GetIwconfig(self):
""" Calls and returns the output of iwconfig"""
return self.wifi.GetIwconfig()
return misc.to_unicode(self.wifi.GetIwconfig())
@dbus.service.method('org.wicd.daemon.wireless')
def GetNumberOfNetworks(self):
@@ -1506,12 +1506,16 @@ def main(argv):
if redirect_stderr or redirect_stdout:
logpath = os.path.join(wpath.log, 'wicd.log')
if not os.path.exists(wpath.log):
os.makedirs(wpath.log)
os.chmod(wpath.log, 755)
output = ManagedStdio(logpath)
if os.path.exists(logpath):
try:
os.chmod(logpath, 0600)
except:
print 'unable to chmod log file to 0600'
if redirect_stdout: sys.stdout = output
if redirect_stderr: sys.stderr = output

View File

@@ -64,8 +64,8 @@ def SetDNS(dns1=None, dns2=None, dns3=None, search_dom=None):
Keyword arguments:
dns1 -- IP address of DNS server 1
dns2 -- IP address of DNS server 1
dns3 -- IP address of DNS server 1
dns2 -- IP address of DNS server 2
dns3 -- IP address of DNS server 3
"""
resolv = open("/etc/resolv.conf", "w")
@@ -823,15 +823,14 @@ class BaseWirelessInterface(BaseInterface):
cmd_list.append('NetworkType=' + info['nettype'])
cmd_list.append('AuthMode=' + info['authmode'])
cmd_list.append('EncrypType=' + info['enctype'])
cmd_list.append('SSID=' + info['essid'])
cmd_list.append(info['keyname'] + '=' + network.get('key'))
cmd_list.append('SSID="%s"' % network['essid'])
cmd_list.append('%s="%s"' % (network['keyname'], network['key']))
if info['nettype'] == 'SHARED' and info['enctype'] == 'WEP':
cmd_list.append('DefaultKeyID=1')
cmd_list.append('SSID=' + info['essid'])
for cmd in cmd_list:
cmd = 'iwpriv ' + self.iface + ' ' + cmd
if self.verbose: print cmd
cmd = ['iwpriv', self.iface, 'set', cmd]
if self.verbose: print ' '.join(cmd)
misc.Run(cmd)
def GetBSSID(self, iwconfig=None):