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

Added distro-specific init scripts based on those used by NM (these are very experimental and likely broken in many cases).

Updated setup.py to pick which initscript to install based on the distro detected.
Updated MANIFEST.in to make sure launchdaemon.sh is included in the sdist build.
Fixed a bunch of crash bugs in tool detection system when tools are detected.
Made tool detection work correctly when "which" returns output if no match is found (as opposed to no output).  Eventually we might want to hardcode possible paths instead of using which at all...
Fixed some message formatting in the daemon.
Added some docstrings.
Added a pidfile system for increased initscript compatibility (sort of, it's somewhat incomplete).
This commit is contained in:
imdano
2008-03-24 00:03:35 +00:00
parent c055ea0d36
commit ef9b5cc7f3
18 changed files with 567 additions and 188 deletions

View File

@@ -4,3 +4,4 @@ recursive-include other *
recursive-include encryption * recursive-include encryption *
recursive-include images * recursive-include images *
recursive-include translations * recursive-include translations *
include launchdaemon.sh

View File

@@ -172,6 +172,7 @@ class ConnectionWizard(dbus.service.Object):
print "autoconnecting...", str(self.GetWirelessInterface()) print "autoconnecting...", str(self.GetWirelessInterface())
self.AutoConnect(True) self.AutoConnect(True)
else: else:
self.Scan()
print "--no-scan detected, not autoconnecting..." print "--no-scan detected, not autoconnecting..."
########## DAEMON FUNCTIONS ########## DAEMON FUNCTIONS
@@ -440,8 +441,8 @@ class ConnectionWizard(dbus.service.Object):
def GetAutoReconnect(self): def GetAutoReconnect(self):
""" Returns the value of self.auto_reconnect. See SetAutoReconnect. """ """ Returns the value of self.auto_reconnect. See SetAutoReconnect. """
do = bool(self.auto_reconnect) do = bool(self.auto_reconnect)
return self.__printReturn('returning automatically reconnect when\ return self.__printReturn('returning automatically reconnect when ' \
connection drops', do) + 'connection drops', do)
@dbus.service.method('org.wicd.daemon') @dbus.service.method('org.wicd.daemon')
def SetAutoReconnect(self, value): def SetAutoReconnect(self, value):
@@ -567,7 +568,7 @@ class ConnectionWizard(dbus.service.Object):
state - info contents: state - info contents:
NOT_CONNECTED - info[0] = "" NOT_CONNECTED - info[0] = ""
CONNECTING - info[0] = "wired" or "wireless" CONNECTING - info[0] = "wired" or "wireless"
info[1] = None for wired, essid for wireless info[1] = None if wired, an essid if wireless
WIRED - info[0] = IP Adresss WIRED - info[0] = IP Adresss
WIRELESS - info[0] = IP Address WIRELESS - info[0] = IP Address
info[1] = essid info[1] = essid
@@ -719,8 +720,8 @@ class ConnectionWizard(dbus.service.Object):
""" Sets property to value in network specified. """ """ Sets property to value in network specified. """
# We don't write script settings here. # We don't write script settings here.
if (property.strip()).endswith("script"): if (property.strip()).endswith("script"):
print "Setting script properties through the daemon is not \ print "Setting script properties through the daemon is not" \
permitted." + " permitted."
return False return False
self.LastScan[networkid][property] = misc.Noneify(value) self.LastScan[networkid][property] = misc.Noneify(value)
#end function SetProperty #end function SetProperty
@@ -729,7 +730,10 @@ class ConnectionWizard(dbus.service.Object):
def DetectWirelessInterface(self): def DetectWirelessInterface(self):
""" Returns an automatically detected wireless interface. """ """ Returns an automatically detected wireless interface. """
iface = self.wifi.DetectWirelessInterface() iface = self.wifi.DetectWirelessInterface()
if iface:
print 'automatically detected wireless interface ' + iface print 'automatically detected wireless interface ' + iface
else:
print "Couldn't detect a wireless interface."
return str(iface) return str(iface)
@dbus.service.method('org.wicd.daemon.wireless') @dbus.service.method('org.wicd.daemon.wireless')
@@ -877,7 +881,7 @@ class ConnectionWizard(dbus.service.Object):
@dbus.service.method('org.wicd.daemon.wired') @dbus.service.method('org.wicd.daemon.wired')
def CheckWiredConnectingMessage(self): def CheckWiredConnectingMessage(self):
""" Returns the wired interface\'s status message. """ """ Returns the wired interface's status message. """
if self.wired.connecting_thread: if self.wired.connecting_thread:
return self.wired.connecting_thread.GetStatus() return self.wired.connecting_thread.GetStatus()
else: else:
@@ -887,8 +891,8 @@ class ConnectionWizard(dbus.service.Object):
def SetWiredProperty(self, property, value): def SetWiredProperty(self, property, value):
if self.WiredNetwork: if self.WiredNetwork:
if (property.strip()).endswith("script"): if (property.strip()).endswith("script"):
print "Setting script properties through the daemon \ print "Setting script properties through the daemon" \
is not permitted." + " is not permitted."
return False return False
self.WiredNetwork[property] = misc.Noneify(value) self.WiredNetwork[property] = misc.Noneify(value)
return True return True
@@ -1404,10 +1408,11 @@ Arguments:
\t-f\t--no-daemon\tDon't daemonize (run in foreground). \t-f\t--no-daemon\tDon't daemonize (run in foreground).
\t-e\t--no-stderr\tDon't redirect stderr. \t-e\t--no-stderr\tDon't redirect stderr.
\t-o\t--no-stdout\tDon't redirect stdout. \t-o\t--no-stdout\tDon't redirect stdout.
\t-P\t--pidfile path\tCreate a pidfile at the specified path.
\t-h\t--help\t\tPrint this help. \t-h\t--help\t\tPrint this help.
""" """
def daemonize(): def daemonize(write_pid, pidfile):
""" Disconnect from the controlling terminal. """ Disconnect from the controlling terminal.
Fork twice, once to disconnect ourselves from the parent terminal and a Fork twice, once to disconnect ourselves from the parent terminal and a
@@ -1436,7 +1441,10 @@ def daemonize():
try: try:
pid = os.fork() pid = os.fork()
if pid > 0: if pid > 0:
if not write_pid:
print "wicd daemon: pid " + str(pid) print "wicd daemon: pid " + str(pid)
else:
print >> open(pidfile,'wt'), str(pid)
sys.exit(0) sys.exit(0)
except OSError, e: except OSError, e:
print >> sys.stderr, "Fork #2 failed: %d (%s)" % (e.errno, e.strerror) print >> sys.stderr, "Fork #2 failed: %d (%s)" % (e.errno, e.strerror)
@@ -1456,13 +1464,16 @@ def main(argv):
auto_scan = True auto_scan = True
try: try:
opts, args = getopt.getopt(sys.argv[1:], 'feos', opts, args = getopt.getopt(sys.argv[1:], 'feosP:',
['help', 'no-daemon', 'no-stderr', 'no-stdout', 'no-scan']) ['help', 'no-daemon', 'no-stderr', 'no-stdout', 'no-scan',
'pidfile:'])
except getopt.GetoptError: except getopt.GetoptError:
# Print help information and exit # Print help information and exit
usage() usage()
sys.exit(2) sys.exit(2)
write_pid = False
pid_file = None
for o, a in opts: for o, a in opts:
if o in ('-h', '--help'): if o in ('-h', '--help'):
usage() usage()
@@ -1475,12 +1486,16 @@ def main(argv):
do_daemonize = False do_daemonize = False
if o in ('-s', '--no-scan'): if o in ('-s', '--no-scan'):
auto_scan = False auto_scan = False
if o in ('-P', '--pidfile'):
write_pid = True
pid_file = a
if do_daemonize: daemonize() if do_daemonize: daemonize(write_pid, pid_file)
if redirect_stderr or redirect_stdout: output = LogWriter() if redirect_stderr or redirect_stdout: output = LogWriter()
if redirect_stdout: sys.stdout = output if redirect_stdout: sys.stdout = output
if redirect_stderr: sys.stderr = output if redirect_stderr: sys.stderr = output
time.sleep(1)
print '---------------------------' print '---------------------------'
print 'wicd initializing...' print 'wicd initializing...'

62
misc.py
View File

@@ -253,7 +253,8 @@ def get_gettext():
if (osLanguage): if (osLanguage):
langs += osLanguage.split(":") langs += osLanguage.split(":")
langs += ["en_US"] langs += ["en_US"]
lang = gettext.translation('wicd', local_path, languages=langs, fallback=True) lang = gettext.translation('wicd', local_path, languages=langs,
fallback=True)
_ = lang.gettext _ = lang.gettext
return _ return _
@@ -277,62 +278,3 @@ def error(parent, message):
dialog.set_markup(message) dialog.set_markup(message)
dialog.run() dialog.run()
dialog.destroy() dialog.destroy()
class LogWriter:
""" A class to provide timestamped logging. """
def __init__(self):
self.file = open(wpath.log + 'wicd.log','a')
self.eol = True
self.logging_enabled = True
def __del__(self):
self.file.close()
def write(self, data):
""" Writes the data to the log with a timestamp.
This function handles writing of data to a log file. In order to
handle output redirection, we need to be careful with how we
handle the addition of timestamps. In any set of data that is
written, we replace the newlines with a timestamp + new line,
except for newlines that are the final character in data.
When a newline is the last character in data, we set a flag to
indicate that the next write should have a timestamp prepended
as well, which ensures that the timestamps match the time at
which the data is written, rather than the previous write.
Keyword arguments:
data -- The string to write to the log.
"""
#global logging_enabled
data = data.encode('utf-8')
if len(data) <= 0: return
if self.logging_enabled:
if self.eol:
self.file.write(self.get_time() + ' :: ')
self.eol = False
if data[-1] == '\n':
self.eol = True
data = data[:-1]
self.file.write(
data.replace('\n', '\n' + self.get_time() + ' :: '))
if self.eol: self.file.write('\n')
self.file.close()
def get_time(self):
""" Return a string with the current time nicely formatted.
The format of the returned string is yyyy/mm/dd HH:MM:SS
"""
x = time.localtime()
return ''.join([
str(x[0]).rjust(4,'0'), '/', str(x[1]).rjust(2,'0'), '/',
str(x[2]).rjust(2,'0'), ' ', str(x[3]).rjust(2,'0'), ':',
str(x[4]).rjust(2,'0'), ':', str(x[5]).rjust(2,'0')])

View File

@@ -1,5 +1,13 @@
#!/usr/bin/env python #!/usr/bin/env python
""" monitor -- connection monitoring process
This process is spawned as a child of the daemon, and is responsible
for monitoring connection status and initiating autoreconnection
when appropriate.
"""
# #
# Copyright (C) 2007 Adam Blackburn # Copyright (C) 2007 Adam Blackburn
# Copyright (C) 2007 Dan O'Reilly # Copyright (C) 2007 Dan O'Reilly
@@ -19,7 +27,6 @@
import dbus import dbus
import gobject import gobject
import os
import sys import sys
import time import time
from dbus.mainloop.glib import DBusGMainLoop from dbus.mainloop.glib import DBusGMainLoop
@@ -34,7 +41,7 @@ if sys.platform == 'linux2':
libc = dl.open('/lib/libc.so.6') libc = dl.open('/lib/libc.so.6')
libc.call('prctl', 15, 'wicd-monitor\0', 0, 0, 0) # 15 is PR_SET_NAME libc.call('prctl', 15, 'wicd-monitor\0', 0, 0, 0) # 15 is PR_SET_NAME
except: except:
pass print 'Failed to set the process name'
if __name__ == '__main__': if __name__ == '__main__':
wpath.chdir(__file__) wpath.chdir(__file__)
@@ -244,13 +251,16 @@ class ConnectionStatus():
self.reconnecting = False self.reconnecting = False
def reply_handle(): def reply_handle():
""" Just a dummy function needed for asynchronous dbus calls. """
pass pass
def err_handle(e): def err_handle(error):
""" Just a dummy function needed for asynchronous dbus calls. """
pass pass
def main(): def main():
""" Start the connection monitor and set the updater to run every 2 sec. """
monitor = ConnectionStatus() monitor = ConnectionStatus()
gobject.timeout_add(3000, monitor.update_connection_status) gobject.timeout_add(3000, monitor.update_connection_status)

View File

@@ -56,14 +56,6 @@ if __name__ == '__main__':
class Controller(object): class Controller(object):
""" Parent class for the different interface types. """ """ Parent class for the different interface types. """
connecting_thread = None
before_script = None
after_script = None
disconnect_script = None
driver = None
wiface = None
liface = None
def __init__(self): def __init__(self):
""" Initialise the class. """ """ Initialise the class. """
self.global_dns_1 = None self.global_dns_1 = None
@@ -74,6 +66,13 @@ class Controller(object):
self._dhcp_client = None self._dhcp_client = None
self._flush_tool = None self._flush_tool = None
self._debug = None self._debug = None
self.connecting_thread = None
self.before_script = None
self.after_script = None
self.disconnect_script = None
self.driver = None
self.wiface = None
self.liface = None
def set_wireless_iface(self, value): def set_wireless_iface(self, value):
self._wireless_interface = value self._wireless_interface = value

3
other/50-wicd-suspend.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
# Bring wifi network interface back up.
/opt/wicd/suspend.py

4
other/80-wicd-connect.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
# Bring wifi network interface back up.
/opt/wicd/autoconnect.py

12
other/hammer-00186ddbac.desktop Executable file
View File

@@ -0,0 +1,12 @@
[Desktop Entry]
Categories=Application;Network;
Encoding=UTF-8
Exec=/opt/wicd/gui.py
GenericName=Network Manager
Icon=/opt/wicd/images/wicd.png
Icon[en_US]=/opt/wicd/images/wicd.png
Name=Wicd
Name[en_US]=Wicd
Terminal=false
Type=Application
Version=1.0

View File

@@ -0,0 +1,63 @@
#!/bin/bash
#
# Copyright (C) 2007 Dan O'Reilly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License Version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
WICD_BIN=$/opt/wicd/daemon.py
CMD=$0
ARG=$1
# general config
. /etc/rc.conf
. /etc/rc.d/functions
# Sanity checks.
[ -x $WICD_BIN ] || exit 0
set -- $(ps ax | grep 'python.*$WICD_BIN')
PID=$1
case "$ARG" in
start)
stat_busy "Starting wicd"
if [ -z "$PID" ]; then
$WICD_BIN
fi
if [ ! -z "$PID" -o $? -gt 0 ]; then
stat_fail
else
add_daemon wicd
stat_done
fi
;;
stop)
stat_busy "Stopping wicd"
[ ! -z "$PID" ] && kill $PID &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon wicd
stat_done
fi
;;
restart)
$CMD stop
sleep 1
$CMD start
;;
*)
echo "usage: $CMD {start|stop|restart}"
;;
esac
exit 0

68
other/initscripts/debian/wicd Executable file
View File

@@ -0,0 +1,68 @@
#! /bin/sh
#
# wicd wicd daemon
# Daemon for managing network connections.
# This file should be placed in /etc/init.d.
#
# Authors: Dan O'Reilly <oreilldf@gmail.com>
#
# Version: @(#)skeleton 2.85-23 28-Jul-2004 miquels@cistron.nl
#
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Network connection manager daemon"
NAME="wicd"
PROCNAME=wicd-daemon
DAEMON=/opt/wicd/daemon.py
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
USER=root
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
#
# Function that starts the daemon/service.
#
d_start() {
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--user $USER --exec $DAEMON -- $DAEMON_OPTS
}
#
# Function that stops the daemon/service.
#
d_stop() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
--oknodo --user $USER --name $PROCNAME
}
case "$1" in
start)
echo -n "Starting $NAME:"
d_start
echo " Done."
;;
stop)
echo -n "Stopping $NAME:"
d_stop
echo " Done."
;;
restart|force-reload)
echo -n "Restarting $NAME:"
d_stop
sleep 1
d_start
echo " Done."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0

View File

@@ -0,0 +1,44 @@
#!/sbin/runscript
#
# wicd: wicd daemon
#
# chkconfig: 345 98 02
# description: This is a daemon for managing network connections.
#
# processname: wicd
# pidfile: /var/run/wicd.pid
#
### BEGIN INIT INFO
# Provides: $network
### END INIT INFO
WICD_BIN=/opt/wicd/daemon.py
NAME=wicd-daemon
# Sanity checks.
[ -x $WICD_BIN ] || exit 0
# so we can rearrange this easily
processname=$WICD_BIN
pidfile=/var/run/wicd.pid
processargs="-P ${pidfile}"
start()
{
if [ -e ${pidfile} ]; then
rm -f ${pidfile}
fi
ebegin "Starting wicd"
start-stop-daemon --start --quiet --exec ${processname} -- ${processargs}
eend $?
}
stop()
{
ebegin "Stopping wicd"
start-stop-daemon --stop --quiet --name ${NAME} --pidfile ${pidfile}
eend $?
if [ -e ${pidfile} ]; then
rm -f $pidfile
fi
}

View File

@@ -0,0 +1,75 @@
#!/bin/sh
#
# wicd: wicd daemon
#
# chkconfig: 345 20 89
# description: This is a daemon for managing network connections.
#
# processname: wicd
# pidfile: /var/run/wicd/wicd.pid
#
WICD_BIN=/opt/wicd/daemon.py
# Sanity checks.
[ -x $WICD_BIN ] || exit 11
# Source function library.
. /etc/rc.d/init.d/functions
# so we can rearrange this easily
processname=$WICD_BIN
servicename=wicd
pidfile=/var/run/wicd/wicd.pid
RETVAL=0
start()
{
echo -n $"Starting wicd daemon: "
daemon --check $servicename $processname --pid-file=$pidfile
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename
}
stop()
{
echo -n $"Stopping wicd daemon: "
killproc -p $pidfile $servicename
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
rm -f /var/lock/subsys/$servicename
rm -f $pidfile
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p $pidfile $processname
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/$servicename ]; then
stop
start
fi
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
;;
esac
exit $RETVAL

View File

@@ -0,0 +1,88 @@
#!/bin/sh
#
# wicd: wicd daemon
#
# description: This is a daemon managing network connections.
#
# processname: wicd-daemon
# pidfile: /var/run/wicd.pid
#
WICD_BIN=/opt/wicd/daemon.py
# Sanity checks.
[ -x $WICD_BIN ] || exit 0
PIDFILE=/var/run/wicd.pid
$WICD_EXEC="$WICD_BIN -P $PIDFILE"
wicd_start()
{
if [ "`pgrep dbus-daemon`" = "" ]; then
echo "D-BUS must be running to start wicd"
return
fi
# Just in case the pidfile is still there, we may need to nuke it.
if [ -e "$PIDFILE" ]; then
rm -f $PIDFILE
fi
echo "Starting wicd daemon: $WICD_BIN"
$WICD_EXEC
}
wicd_status()
{
local pidlist=`cat $PIDFILE 2>/dev/null`
if [ -z "$pidlist" ]; then
return 1
fi
local command=`ps -p $pidlist -o comm=`
if [ "$command" != 'wicd-daemon' ]; then
return 1
fi
}
wicd_stop()
{
echo -en "Stopping wicd: "
local pidlist=`cat $PIDFILE 2>/dev/null`
if [ ! -z "$pidlist" ]; then
kill $pidlist &>/dev/null
rm -f $PIDFILE &>/dev/null
fi
echo "stopped";
}
wicd_restart()
{
wicd_stop
wicd_start
}
case "$1" in
'start')
if ( ! wicd_status ); then
wicd_start
else
echo "wicd is already running (will not start it twice)."
fi
;;
'stop')
wicd_stop
;;
'restart')
wicd_restart
;;
'status')
if ( wicd_status ); then
echo "wicd is currently running"
else
echo "wicd is not running."
fi
;;
*)
echo "usage $0 start|stop|status|restart"
esac

View File

@@ -0,0 +1,49 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: wicd-daemon
# Required-Start: dbus
# Default-Start: 3 4 5
# Default-Stop:
# Description: wicd, a wired and wireless connection manager.
### END INIT INFO
WICD_BIN=/opt/wicd/daemon.py
test -x $WICD_BIN || exit 5
. /etc/rc.status
rc_reset
case "$1" in
start)
checkproc $WICD_BIN
if [ $? = 0 ]; then
echo -n "wicd already running"
rc_status -v
rc_exit
fi
echo -n "Starting wicd"
startproc $WICD_BIN
rc_status -v
;;
stop)
echo -n "Shutting down wicd"
killproc -TERM $WICD_BIN
rc_status -v
;;
restart)
$0 stop
$0 start
rc_status
;;
status)
echo -n "Checking for wicd: "
checkproc $WICD_BIN
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac

17
other/wicd.conf Executable file
View File

@@ -0,0 +1,17 @@
<!-- This configuration file specifies the required security policies
for connection-manager to work. -->
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- ../system.conf have denied everything, so we just punch some holes -->
<policy context="default">
<allow own="org.wicd.daemon"/>
<allow send_destination="org.wicd.daemon"/>
<allow receive_sender="org.wicd.daemon"/>
</policy>
</busconfig>

BIN
other/wicd.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

166
setup.py
View File

@@ -16,6 +16,78 @@
# #
from distutils.core import setup from distutils.core import setup
import os
data=[
('/etc/acpi/resume.d', ['other/80-wicd-connect.sh']),
('/etc/dbus-1/system.d', ['other/wicd.conf']),
('/etc/acpi/suspend.d', ['other/50-wicd-suspend.sh']),
('/usr/share/applications', ['other/hammer-00186ddbac.desktop']),
('', ['launchdaemon.sh']),
('/usr/share/pixmaps', ['other/wicd.png']),
('images', ['images/good-signal.png', 'images/low-signal.png',
'images/no-signal.png', 'images/good-signal-lock.png' ,'images/wired.png',
'images/wicd-purple.png', 'images/signal-25.png', 'images/signal-50.png',
'images/wicd-green.png', 'images/signal-100.png', 'images/wicd.png',
'images/low-signal-lock.png', 'images/wicd-blue.png', 'images/bad-signal.png',
'images/bad-signal-lock.png', 'images/wicd-orange.png', 'images/signal-75.png',
'images/high-signal.png', 'images/wicd-red.png', 'images/high-signal-lock.png']),
('encryption/templates', ['encryption/templates/peap', 'encryption/templates/wep-hex', 'encryption/templates/wpa',
'encryption/templates/wep-passphrase', 'encryption/templates/wep-shared',
'encryption/templates/ttls', 'encryption/templates/leap', 'encryption/templates/peap-tkip',
'encryption/templates/eap', 'encryption/templates/active']),
('data', ['data/wicd.png', 'data/wicd.glade']),
('translations', ['translations/wicd.pot', 'translations/ids']),
('translations/de_DE/LC_MESSAGES', ['translations/de_DE/LC_MESSAGES/wicd.mo']),
('translations/zh_HK/LC_MESSAGES', ['translations/zh_HK/LC_MESSAGES/wicd.mo']),
('translations/fr_FR/LC_MESSAGES', ['translations/fr_FR/LC_MESSAGES/wicd.mo']),
('translations/ca_ES/LC_MESSAGES', ['translations/ca_ES/LC_MESSAGES/wicd.mo']),
('translations/ko_KR/LC_MESSAGES', ['translations/ko_KR/LC_MESSAGES/wicd.mo']),
('translations/gl_GL/LC_MESSAGES', ['translations/gl_GL/LC_MESSAGES/wicd.mo']),
('translations/no_NO/LC_MESSAGES', ['translations/no_NO/LC_MESSAGES/wicd.mo']),
('translations/bg_PHO/LC_MESSAGES', ['translations/bg_PHO/LC_MESSAGES/wicd.mo']),
('translations/po', ['translations/po/bg_PHO.po', 'translations/po/ja_JA.po', 'translations/po/de_DE.po',
'translations/po/de_DE.po', 'translations/po/zh_CN.po', 'translations/po/fr_FR.po',
'translations/po/ar_EG.po', 'translations/po/it_IT.po', 'translations/po/fi_FI.po',
'translations/po/sl_SI.po', 'translations/po/es_ES.po', 'translations/po/da_DK.po',
'translations/po/sv_SE.po', 'translations/po/ca_ES.po', 'translations/po/nl_NL.po',
'translations/po/no_NO.po', 'translations/po/gl_GL.po', 'translations/po/pl_PL.po',
'translations/po/ru_RU.po', 'translations/po/en_US.po', 'translations/po/pt_BR.po',
'translations/po/cs_CZ.po', 'translations/po/tr_TR.po', 'translations/po/zh_HK.po',
'translations/po/hu_HU.po', 'translations/po/ko_KR.po']),
('translations/sl_SI/LC_MESSAGES', ['translations/sl_SI/LC_MESSAGES/wicd.mo']),
('translations/da_DK/LC_MESSAGES', ['translations/da_DK/LC_MESSAGES/wicd.mo']),
('translations/ja_JA/LC_MESSAGES', ['translations/ja_JA/LC_MESSAGES/wicd.mo']),
('translations/zh_CN/LC_MESSAGES', ['translations/zh_CN/LC_MESSAGES/wicd.mo']),
('translations/ru_RU/LC_MESSAGES', ['translations/ru_RU/LC_MESSAGES/wicd.mo']),
('translations/it_IT/LC_MESSAGES', ['translations/it_IT/LC_MESSAGES/wicd.mo']),
('translations/es_ES/LC_MESSAGES', ['translations/es_ES/LC_MESSAGES/wicd.mo']),
('translations/pt_BR/LC_MESSAGES', ['translations/pt_BR/LC_MESSAGES/wicd.mo']),
('translations/cs_CZ/LC_MESSAGES', ['translations/cs_CZ/LC_MESSAGES/wicd.mo']),
('translations/sv_SE/LC_MESSAGES', ['translations/sv_SE/LC_MESSAGES/wicd.mo']),
('translations/ar_EG/LC_MESSAGES', ['translations/ar_EG/LC_MESSAGES/wicd.mo']),
('translations/tr_TR/LC_MESSAGES', ['translations/tr_TR/LC_MESSAGES/wicd.mo']),
('translations/en_US/LC_MESSAGES', ['translations/en_US/LC_MESSAGES/wicd.mo']),
('translations/fi_FI/LC_MESSAGES', ['translations/fi_FI/LC_MESSAGES/wicd.mo']),
('translations/pl_PL/LC_MESSAGES', ['translations/pl_PL/LC_MESSAGES/wicd.mo']),
('translations/hu_HU/LC_MESSAGES', ['translations/hu_HU/LC_MESSAGES/wicd.mo']),
('translations/nl_NL/LC_MESSAGES', ['translations/nl_NL/LC_MESSAGES/wicd.mo'])]
if os.access('/etc/redhat-release', os.F_OK):
data.append(('/etc/rc.d/init.d', ['other/initscripts/redhat/wicd']))
elif os.access('/etc/SuSE-release', os.F_OK):
data.append(('/etc/init.d', ['other/initscripts/debian/wicd']))
elif os.access('/etc/fedora-release', os.F_OK):
data.append(('/etc/rc.d/init.d', ['other/initscripts/redhat/wicd']))
elif os.access('/etc/gentoo-release', os.F_OK):
data.append(('/etc/init.d', ['other/initscripts/gentoo/wicd']))
elif os.access('/etc/debian-release', os.F_OK):
data.append(('/etc/init.d', ['other/initscripts/debian/wicd']))
elif os.access('/etc/arch-release', os.F_OK):
data.append(('/etc/rc.d', ['other/initscripts/arch/wicd']))
elif os.access('/etc/slackware-release', os.F_OK):
data.append(('/etc/rc.d', ['other/initscripts/slackware/wicd']))
setup(name="Wicd", setup(name="Wicd",
version="1.5.0", version="1.5.0",
@@ -34,97 +106,5 @@ connect at startup to any preferred network within range.
license="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html", license="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html",
scripts=['configscript.py', 'autoconnect.py', 'gui.py', 'wicd.py', 'daemon.py', 'suspend.py', 'monitor.py'], scripts=['configscript.py', 'autoconnect.py', 'gui.py', 'wicd.py', 'daemon.py', 'suspend.py', 'monitor.py'],
py_modules=['networking', 'misc', 'wnettools', 'wpath'], py_modules=['networking', 'misc', 'wnettools', 'wpath'],
data_files=[ data_files=data
('/etc/init.d', ['other/wicd']),
('/etc/acpi/resume.d', ['other/80-wicd-connect.sh']),
('/etc/dbus-1/system.d', ['other/wicd.conf']),
('/etc/acpi/suspend.d', ['other/50-wicd-suspend.sh']),
('/usr/share/applications', ['other/hammer-00186ddbac.desktop']),
('', ['launchdaemon.sh']),
('/usr/share/pixmaps', ['other/wicd.png']),
('images', ['images/good-signal.png']),
('images', ['images/low-signal.png']),
('images', ['images/no-signal.png']),
('images', ['images/good-signal-lock.png']),
('images', ['images/wired.png']),
('images', ['images/wicd-purple.png']),
('images', ['images/signal-25.png']),
('images', ['images/signal-50.png']),
('images', ['images/wicd-green.png']),
('images', ['images/signal-100.png']),
('images', ['images/wicd.png']),
('images', ['images/low-signal-lock.png']),
('images', ['images/wicd-blue.png']),
('images', ['images/bad-signal.png']),
('images', ['images/bad-signal-lock.png']),
('images', ['images/wicd-orange.png']),
('images', ['images/signal-75.png']),
('images', ['images/high-signal.png']),
('images', ['images/wicd-red.png']),
('images', ['images/high-signal-lock.png']),
('encryption/templates', ['encryption/templates/peap']),
('encryption/templates', ['encryption/templates/wep-hex']),
('encryption/templates', ['encryption/templates/wpa']),
('encryption/templates', ['encryption/templates/wep-passphrase']),
('encryption/templates', ['encryption/templates/wep-shared']),
('encryption/templates', ['encryption/templates/ttls']),
('encryption/templates', ['encryption/templates/leap']),
('encryption/templates', ['encryption/templates/peap-tkip']),
('encryption/templates', ['encryption/templates/eap']),
('encryption/templates', ['encryption/templates/active']),
('data', ['data/wicd.png']),
('data', ['data/wicd.glade']),
('translations', ['translations/wicd.pot']),
('translations', ['translations/ids']),
('translations/de_DE/LC_MESSAGES', ['translations/de_DE/LC_MESSAGES/wicd.mo']),
('translations/zh_HK/LC_MESSAGES', ['translations/zh_HK/LC_MESSAGES/wicd.mo']),
('translations/fr_FR/LC_MESSAGES', ['translations/fr_FR/LC_MESSAGES/wicd.mo']),
('translations/ca_ES/LC_MESSAGES', ['translations/ca_ES/LC_MESSAGES/wicd.mo']),
('translations/ko_KR/LC_MESSAGES', ['translations/ko_KR/LC_MESSAGES/wicd.mo']),
('translations/gl_GL/LC_MESSAGES', ['translations/gl_GL/LC_MESSAGES/wicd.mo']),
('translations/no_NO/LC_MESSAGES', ['translations/no_NO/LC_MESSAGES/wicd.mo']),
('translations/bg_PHO/LC_MESSAGES', ['translations/bg_PHO/LC_MESSAGES/wicd.mo']),
('translations/po', ['translations/po/bg_PHO.po']),
('translations/po', ['translations/po/ja_JA.po']),
('translations/po', ['translations/po/de_DE.po']),
('translations/po', ['translations/po/zh_CN.po']),
('translations/po', ['translations/po/fr_FR.po']),
('translations/po', ['translations/po/ar_EG.po']),
('translations/po', ['translations/po/it_IT.po']),
('translations/po', ['translations/po/fi_FI.po']),
('translations/po', ['translations/po/sl_SI.po']),
('translations/po', ['translations/po/es_ES.po']),
('translations/po', ['translations/po/da_DK.po']),
('translations/po', ['translations/po/sv_SE.po']),
('translations/po', ['translations/po/ca_ES.po']),
('translations/po', ['translations/po/nl_NL.po']),
('translations/po', ['translations/po/no_NO.po']),
('translations/po', ['translations/po/gl_GL.po']),
('translations/po', ['translations/po/pl_PL.po']),
('translations/po', ['translations/po/ru_RU.po']),
('translations/po', ['translations/po/en_US.po']),
('translations/po', ['translations/po/pt_BR.po']),
('translations/po', ['translations/po/cs_CZ.po']),
('translations/po', ['translations/po/tr_TR.po']),
('translations/po', ['translations/po/zh_HK.po']),
('translations/po', ['translations/po/hu_HU.po']),
('translations/po', ['translations/po/ko_KR.po']),
('translations/sl_SI/LC_MESSAGES', ['translations/sl_SI/LC_MESSAGES/wicd.mo']),
('translations/da_DK/LC_MESSAGES', ['translations/da_DK/LC_MESSAGES/wicd.mo']),
('translations/ja_JA/LC_MESSAGES', ['translations/ja_JA/LC_MESSAGES/wicd.mo']),
('translations/zh_CN/LC_MESSAGES', ['translations/zh_CN/LC_MESSAGES/wicd.mo']),
('translations/ru_RU/LC_MESSAGES', ['translations/ru_RU/LC_MESSAGES/wicd.mo']),
('translations/it_IT/LC_MESSAGES', ['translations/it_IT/LC_MESSAGES/wicd.mo']),
('translations/es_ES/LC_MESSAGES', ['translations/es_ES/LC_MESSAGES/wicd.mo']),
('translations/pt_BR/LC_MESSAGES', ['translations/pt_BR/LC_MESSAGES/wicd.mo']),
('translations/cs_CZ/LC_MESSAGES', ['translations/cs_CZ/LC_MESSAGES/wicd.mo']),
('translations/sv_SE/LC_MESSAGES', ['translations/sv_SE/LC_MESSAGES/wicd.mo']),
('translations/ar_EG/LC_MESSAGES', ['translations/ar_EG/LC_MESSAGES/wicd.mo']),
('translations/tr_TR/LC_MESSAGES', ['translations/tr_TR/LC_MESSAGES/wicd.mo']),
('translations/en_US/LC_MESSAGES', ['translations/en_US/LC_MESSAGES/wicd.mo']),
('translations/fi_FI/LC_MESSAGES', ['translations/fi_FI/LC_MESSAGES/wicd.mo']),
('translations/pl_PL/LC_MESSAGES', ['translations/pl_PL/LC_MESSAGES/wicd.mo']),
('translations/hu_HU/LC_MESSAGES', ['translations/hu_HU/LC_MESSAGES/wicd.mo']),
('translations/nl_NL/LC_MESSAGES', ['translations/nl_NL/LC_MESSAGES/wicd.mo'])
]
) )

View File

@@ -87,6 +87,8 @@ def GetDefaultGateway():
for line in lines: for line in lines:
words = line.split() words = line.split()
print words print words
if not words:
continue
if words[0] == '0.0.0.0': if words[0] == '0.0.0.0':
gateway = words[1] gateway = words[1]
break break
@@ -146,6 +148,12 @@ class Interface(object):
""" """
self.iface = str(iface) self.iface = str(iface)
def _client_found(self, client):
output = misc.Run("which " + client)
if output and not ("no " + client) in output:
return True
return False
def CheckDHCP(self): def CheckDHCP(self):
""" Check for a valid DHCP client. """ Check for a valid DHCP client.
@@ -158,9 +166,10 @@ class Interface(object):
if self.DHCP_CLIENT: if self.DHCP_CLIENT:
DHCP_CLIENT = self.DHCP_CLIENT DHCP_CLIENT = self.DHCP_CLIENT
else: else:
DHCP_CLIENT = None
dhcpclients = ["dhclient", "dhcpcd", "pump"] dhcpclients = ["dhclient", "dhcpcd", "pump"]
for client in dhcpclients: for client in dhcpclients:
if misc.Run("which " + client): if self._client_found(client):
DHCP_CLIENT = client DHCP_CLIENT = client
break break
@@ -187,12 +196,12 @@ class Interface(object):
def CheckWiredTools(self): def CheckWiredTools(self):
""" Check for the existence of ethtool and mii-tool. """ """ Check for the existence of ethtool and mii-tool. """
if misc.Run("which mii-tool"): if self._client_found("mii-tool"):
self.MIITOOL_FOUND = True self.MIITOOL_FOUND = True
else: else:
self.MIITOOL_FOUND = False self.MIITOOL_FOUND = False
if misc.Run("which ethtool"): if self._client_found("ethtool"):
self.ETHTOOL_FOUND = True self.ETHTOOL_FOUND = True
else: else:
self.ETHTOOL_FOUND = False self.ETHTOOL_FOUND = False
@@ -203,7 +212,7 @@ class Interface(object):
self.CheckDHCP() self.CheckDHCP()
self.CheckWiredTools() self.CheckWiredTools()
if misc.Run("which ip"): if self._client_found("ip"):
self.IP_FOUND = True self.IP_FOUND = True
else: else:
self.IP_FOUND = False self.IP_FOUND = False