diff --git a/MANIFEST.in b/MANIFEST.in
index 77fabca..6d6ab9e 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -4,3 +4,4 @@ recursive-include other *
recursive-include encryption *
recursive-include images *
recursive-include translations *
+include launchdaemon.sh
diff --git a/daemon.py b/daemon.py
index a39d8f5..287a1fc 100644
--- a/daemon.py
+++ b/daemon.py
@@ -172,6 +172,7 @@ class ConnectionWizard(dbus.service.Object):
print "autoconnecting...", str(self.GetWirelessInterface())
self.AutoConnect(True)
else:
+ self.Scan()
print "--no-scan detected, not autoconnecting..."
########## DAEMON FUNCTIONS
@@ -440,8 +441,8 @@ class ConnectionWizard(dbus.service.Object):
def GetAutoReconnect(self):
""" Returns the value of self.auto_reconnect. See SetAutoReconnect. """
do = bool(self.auto_reconnect)
- return self.__printReturn('returning automatically reconnect when\
- connection drops', do)
+ return self.__printReturn('returning automatically reconnect when ' \
+ + 'connection drops', do)
@dbus.service.method('org.wicd.daemon')
def SetAutoReconnect(self, value):
@@ -567,7 +568,7 @@ class ConnectionWizard(dbus.service.Object):
state - info contents:
NOT_CONNECTED - info[0] = ""
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
WIRELESS - info[0] = IP Address
info[1] = essid
@@ -719,8 +720,8 @@ class ConnectionWizard(dbus.service.Object):
""" Sets property to value in network specified. """
# We don't write script settings here.
if (property.strip()).endswith("script"):
- print "Setting script properties through the daemon is not \
- permitted."
+ print "Setting script properties through the daemon is not" \
+ + " permitted."
return False
self.LastScan[networkid][property] = misc.Noneify(value)
#end function SetProperty
@@ -729,7 +730,10 @@ class ConnectionWizard(dbus.service.Object):
def DetectWirelessInterface(self):
""" Returns an automatically detected wireless interface. """
iface = self.wifi.DetectWirelessInterface()
- print 'automatically detected wireless interface ' + iface
+ if iface:
+ print 'automatically detected wireless interface ' + iface
+ else:
+ print "Couldn't detect a wireless interface."
return str(iface)
@dbus.service.method('org.wicd.daemon.wireless')
@@ -877,7 +881,7 @@ class ConnectionWizard(dbus.service.Object):
@dbus.service.method('org.wicd.daemon.wired')
def CheckWiredConnectingMessage(self):
- """ Returns the wired interface\'s status message. """
+ """ Returns the wired interface's status message. """
if self.wired.connecting_thread:
return self.wired.connecting_thread.GetStatus()
else:
@@ -887,8 +891,8 @@ class ConnectionWizard(dbus.service.Object):
def SetWiredProperty(self, property, value):
if self.WiredNetwork:
if (property.strip()).endswith("script"):
- print "Setting script properties through the daemon \
- is not permitted."
+ print "Setting script properties through the daemon" \
+ + " is not permitted."
return False
self.WiredNetwork[property] = misc.Noneify(value)
return True
@@ -1404,10 +1408,11 @@ Arguments:
\t-f\t--no-daemon\tDon't daemonize (run in foreground).
\t-e\t--no-stderr\tDon't redirect stderr.
\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.
"""
-def daemonize():
+def daemonize(write_pid, pidfile):
""" Disconnect from the controlling terminal.
Fork twice, once to disconnect ourselves from the parent terminal and a
@@ -1436,7 +1441,10 @@ def daemonize():
try:
pid = os.fork()
if pid > 0:
- print "wicd daemon: pid " + str(pid)
+ if not write_pid:
+ print "wicd daemon: pid " + str(pid)
+ else:
+ print >> open(pidfile,'wt'), str(pid)
sys.exit(0)
except OSError, e:
print >> sys.stderr, "Fork #2 failed: %d (%s)" % (e.errno, e.strerror)
@@ -1456,13 +1464,16 @@ def main(argv):
auto_scan = True
try:
- opts, args = getopt.getopt(sys.argv[1:], 'feos',
- ['help', 'no-daemon', 'no-stderr', 'no-stdout', 'no-scan'])
+ opts, args = getopt.getopt(sys.argv[1:], 'feosP:',
+ ['help', 'no-daemon', 'no-stderr', 'no-stdout', 'no-scan',
+ 'pidfile:'])
except getopt.GetoptError:
# Print help information and exit
usage()
sys.exit(2)
-
+
+ write_pid = False
+ pid_file = None
for o, a in opts:
if o in ('-h', '--help'):
usage()
@@ -1475,12 +1486,16 @@ def main(argv):
do_daemonize = False
if o in ('-s', '--no-scan'):
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_stdout: sys.stdout = output
if redirect_stderr: sys.stderr = output
+ time.sleep(1)
print '---------------------------'
print 'wicd initializing...'
diff --git a/misc.py b/misc.py
index 91d842f..3a5f073 100644
--- a/misc.py
+++ b/misc.py
@@ -253,7 +253,8 @@ def get_gettext():
if (osLanguage):
langs += osLanguage.split(":")
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
return _
@@ -276,63 +277,4 @@ def error(parent, message):
gtk.BUTTONS_OK)
dialog.set_markup(message)
dialog.run()
- 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')])
+ dialog.destroy()
\ No newline at end of file
diff --git a/monitor.py b/monitor.py
index 5bf27d5..f899686 100755
--- a/monitor.py
+++ b/monitor.py
@@ -1,5 +1,13 @@
#!/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 Dan O'Reilly
@@ -19,7 +27,6 @@
import dbus
import gobject
-import os
import sys
import time
from dbus.mainloop.glib import DBusGMainLoop
@@ -34,8 +41,8 @@ if sys.platform == 'linux2':
libc = dl.open('/lib/libc.so.6')
libc.call('prctl', 15, 'wicd-monitor\0', 0, 0, 0) # 15 is PR_SET_NAME
except:
- pass
-
+ print 'Failed to set the process name'
+
if __name__ == '__main__':
wpath.chdir(__file__)
@@ -244,13 +251,16 @@ class ConnectionStatus():
self.reconnecting = False
def reply_handle():
- pass
+ """ Just a dummy function needed for asynchronous dbus calls. """
+ pass
-def err_handle(e):
- pass
+def err_handle(error):
+ """ Just a dummy function needed for asynchronous dbus calls. """
+ pass
def main():
+ """ Start the connection monitor and set the updater to run every 2 sec. """
monitor = ConnectionStatus()
gobject.timeout_add(3000, monitor.update_connection_status)
diff --git a/networking.py b/networking.py
index 810c67c..bae3385 100644
--- a/networking.py
+++ b/networking.py
@@ -56,14 +56,6 @@ if __name__ == '__main__':
class Controller(object):
""" 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):
""" Initialise the class. """
self.global_dns_1 = None
@@ -74,6 +66,13 @@ class Controller(object):
self._dhcp_client = None
self._flush_tool = 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):
self._wireless_interface = value
diff --git a/other/50-wicd-suspend.sh b/other/50-wicd-suspend.sh
new file mode 100755
index 0000000..2e3a6ab
--- /dev/null
+++ b/other/50-wicd-suspend.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+# Bring wifi network interface back up.
+/opt/wicd/suspend.py
diff --git a/other/80-wicd-connect.sh b/other/80-wicd-connect.sh
new file mode 100755
index 0000000..6d56084
--- /dev/null
+++ b/other/80-wicd-connect.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+# Bring wifi network interface back up.
+
+/opt/wicd/autoconnect.py
diff --git a/other/hammer-00186ddbac.desktop b/other/hammer-00186ddbac.desktop
new file mode 100755
index 0000000..491f275
--- /dev/null
+++ b/other/hammer-00186ddbac.desktop
@@ -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
diff --git a/other/initscripts/arch/wicd b/other/initscripts/arch/wicd
new file mode 100644
index 0000000..b440ddf
--- /dev/null
+++ b/other/initscripts/arch/wicd
@@ -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 .
+#
+
+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
+
diff --git a/other/initscripts/debian/wicd b/other/initscripts/debian/wicd
new file mode 100755
index 0000000..11d3900
--- /dev/null
+++ b/other/initscripts/debian/wicd
@@ -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
+#
+# 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
+
diff --git a/other/initscripts/gentoo/wicd b/other/initscripts/gentoo/wicd
new file mode 100644
index 0000000..609ab54
--- /dev/null
+++ b/other/initscripts/gentoo/wicd
@@ -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
+}
+
diff --git a/other/initscripts/redhat/wicd b/other/initscripts/redhat/wicd
new file mode 100644
index 0000000..35d1e00
--- /dev/null
+++ b/other/initscripts/redhat/wicd
@@ -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
+
diff --git a/other/initscripts/slackware/wicd b/other/initscripts/slackware/wicd
new file mode 100644
index 0000000..cd7e2a0
--- /dev/null
+++ b/other/initscripts/slackware/wicd
@@ -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
+
diff --git a/other/initscripts/suse/wicd b/other/initscripts/suse/wicd
new file mode 100644
index 0000000..a1b7dc0
--- /dev/null
+++ b/other/initscripts/suse/wicd
@@ -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
+
diff --git a/other/wicd.conf b/other/wicd.conf
new file mode 100755
index 0000000..cc905e3
--- /dev/null
+++ b/other/wicd.conf
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/other/wicd.png b/other/wicd.png
new file mode 100755
index 0000000..460b80f
Binary files /dev/null and b/other/wicd.png differ
diff --git a/setup.py b/setup.py
index 1e27a79..ad1116e 100755
--- a/setup.py
+++ b/setup.py
@@ -16,6 +16,78 @@
#
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",
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",
scripts=['configscript.py', 'autoconnect.py', 'gui.py', 'wicd.py', 'daemon.py', 'suspend.py', 'monitor.py'],
py_modules=['networking', 'misc', 'wnettools', 'wpath'],
- data_files=[
- ('/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'])
- ]
+ data_files=data
)
diff --git a/wnettools.py b/wnettools.py
index ee94636..17d887c 100644
--- a/wnettools.py
+++ b/wnettools.py
@@ -87,6 +87,8 @@ def GetDefaultGateway():
for line in lines:
words = line.split()
print words
+ if not words:
+ continue
if words[0] == '0.0.0.0':
gateway = words[1]
break
@@ -145,6 +147,12 @@ class Interface(object):
"""
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):
""" Check for a valid DHCP client.
@@ -158,9 +166,10 @@ class Interface(object):
if self.DHCP_CLIENT:
DHCP_CLIENT = self.DHCP_CLIENT
else:
+ DHCP_CLIENT = None
dhcpclients = ["dhclient", "dhcpcd", "pump"]
for client in dhcpclients:
- if misc.Run("which " + client):
+ if self._client_found(client):
DHCP_CLIENT = client
break
@@ -187,12 +196,12 @@ class Interface(object):
def CheckWiredTools(self):
""" 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
else:
self.MIITOOL_FOUND = False
- if misc.Run("which ethtool"):
+ if self._client_found("ethtool"):
self.ETHTOOL_FOUND = True
else:
self.ETHTOOL_FOUND = False
@@ -203,7 +212,7 @@ class Interface(object):
self.CheckDHCP()
self.CheckWiredTools()
- if misc.Run("which ip"):
+ if self._client_found("ip"):
self.IP_FOUND = True
else:
self.IP_FOUND = False