1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-19 20:38:00 +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

@@ -17,6 +17,10 @@ wicd_start() {
else
echo "Starting wicd daemon..."
wicd 2>/dev/null 1>&2
# Activate the pm-utils sleep hook
if [ ! -x %PMUTILS%55wicd ]; then
chmod +x %PMUTILS%55wicd
fi
fi
}
@@ -28,6 +32,11 @@ wicd_stop() {
else
pkill -f python.*wicd-daemon.py 2>/dev/null
fi
# Deactivate the pm-utils sleep hook
if [ -x %PMUTILS%55wicd ]; then
chmod -x %PMUTILS%55wicd
fi
}
# See how we were called and take appropriate action
@@ -49,3 +58,4 @@ case $1 in
;;
esac

29
in/other=55wicd.in Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/sh
# pm-utils hook to handle suspend/resume properly for wicd
. "${PM_FUNCTIONS}" || . "${FUNCTIONS}"
wicd_suspend()
{
# Put wifi interface down
%LIB%suspend.py
}
wicd_resume()
{
# Bring wifi interface back up
%LIB%autoconnect.py
}
case "$1" in
hibernate|suspend)
wicd_suspend
;;
thaw|resume)
wicd_resume
;;
*) exit $NA
;;
esac

View File

@@ -22,6 +22,7 @@ import shutil
import sys
# Be sure to keep this updated!
# VERSIONNUMBER
VERSION_NUM = '1.6.0'
class configure(Command):
@@ -54,6 +55,7 @@ class configure(Command):
('log=', None, 'set the log directory'),
('resume=', None, 'set the directory the resume from suspend script is stored in'),
('suspend=', None, 'set the directory the suspend script is stored in'),
('pmutils=', None, 'set the directory the pm-utils hooks are stored in'),
('dbus=', None, 'set the directory the dbus config file is stored in'),
('desktop=', None, 'set the directory the .desktop file is stored in'),
('icons=', None, "set the base directory for the .desktop file's icons"),
@@ -80,8 +82,8 @@ class configure(Command):
('no-install-man', None, 'do not install the man file'),
('no-install-kde', None, 'do not install the kde autostart file'),
('no-install-acpi', None, 'do not install the suspend.d and resume.d acpi scripts'),
('no-install-install', None, 'do not install the INSTALL file'),
('no-install-license', None, 'do not install the LICENSE file')
('no-install-pmutils', None, 'do not install the pm-utils hooks'),
('no-install-docs', None, 'do not install the auxiliary documentation')
]
@@ -99,6 +101,7 @@ class configure(Command):
self.log = '/var/log/wicd/'
self.resume = '/etc/acpi/resume.d/'
self.suspend = '/etc/acpi/suspend.d/'
self.pmutils = '/usr/lib/pm-utils/sleep.d/'
self.dbus = '/etc/dbus-1/system.d/'
self.desktop = '/usr/share/applications/'
self.translations = '/usr/share/locale/'
@@ -111,8 +114,8 @@ class configure(Command):
self.no_install_man = False
self.no_install_kde = False
self.no_install_acpi = False
self.no_install_install = False
self.no_install_license = False
self.no_install_pmutils = False
self.no_install_docs = False
# figure out what the default init file
# location should be on several different distros
@@ -137,7 +140,7 @@ class configure(Command):
self.initfile = 'init/debian/wicd'
elif os.access('/etc/arch-release', os.F_OK):
self.init = '/etc/rc.d/'
self.init = 'init/arch/wicd'
self.initfile = 'init/arch/wicd'
elif os.access('/etc/slackware-version', os.F_OK) or \
os.access('/etc/slamd64-version', os.F_OK):
self.init = '/etc/rc.d/'
@@ -283,6 +286,7 @@ try:
(wpath.dbus, ['other/wicd.conf']),
(wpath.desktop, ['other/wicd.desktop']),
(wpath.log, []),
(wpath.etc, []),
(wpath.icons + 'scalable/apps/', ['icons/scalable/wicd-client.svg']),
(wpath.icons + '192x192/apps/', ['icons/192px/wicd-client.png']),
(wpath.icons + '128x128/apps/', ['icons/128px/wicd-client.png']),
@@ -304,16 +308,13 @@ try:
(wpath.lib, ['wicd/wicd-client.py', 'wicd/monitor.py', 'wicd/wicd-daemon.py', 'wicd/configscript.py', 'wicd/suspend.py', 'wicd/autoconnect.py']), #'wicd/wicd-gui.py',
(wpath.backends, ['wicd/backends/be-external.py', 'wicd/backends/be-ioctl.py']),
(wpath.autostart, ['other/wicd-tray.desktop', ]),
(wpath.docdir, [ 'AUTHORS', 'README' ])
]
piddir = os.path.dirname(wpath.pidfile)
if not piddir.endswith('/'):
piddir += '/'
data.append (( piddir, [] ))
if not wpath.no_install_install:
data.append(( wpath.docdir, [ 'INSTALL' ] ))
if not wpath.no_install_license:
data.append(( wpath.docdir, [ 'LICENSE' ] ))
if not wpath.no_install_docs:
data.append(( wpath.docdir, [ 'INSTALL', 'LICENSE', 'AUTHORS', 'README' ]))
if not wpath.no_install_kde:
data.append(( wpath.kdedir, [ 'other/wicd-tray.desktop' ]))
if not wpath.no_install_init:
@@ -323,9 +324,12 @@ try:
data.append(( wpath.mandir + 'man5/', [ 'man/wicd-manager-settings.conf.5' ]))
data.append(( wpath.mandir + 'man5/', [ 'man/wicd-wired-settings.conf.5' ]))
data.append(( wpath.mandir + 'man5/', [ 'man/wicd-wireless-settings.conf.5' ]))
data.append(( wpath.mandir + 'man1/', [ 'man/wicd-client.1' ]))
if not wpath.no_install_acpi:
data.append(( wpath.resume, ['other/80-wicd-connect.sh' ]))
data.append(( wpath.suspend, ['other/50-wicd-suspend.sh' ]))
if not wpath.no_install_pmutils:
data.append(( wpath.pmutils, ['other/55wicd' ]))
print 'Creating pid path', os.path.basename(wpath.pidfile)
print 'Language support for',
for language in os.listdir('translations/'):

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,7 +492,11 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
[(strength, max_strength)] = strength_pattern.findall(output)
if max_strength and 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):