From f6033cc6bbb4abf1458cc8b55ba701b754e40dd4 Mon Sep 17 00:00:00 2001
From: imdano <>
Date: Sat, 13 Sep 2008 22:52:01 +0000
Subject: [PATCH] experimental: - Add UPDATE_INTERVAL as a required attribute
for backends, and used by monitor.py - Update Copyright stuff in a few files
- Remove/update some scripts and configuration files.
---
other/50-wicd-suspend.sh | 3 ---
other/80-wicd-connect.sh | 4 ----
other/postinst | 35 +++++++++++++++++++++--------------
other/wicd.conf | 24 +++++++++++++++++++++---
scripts/wicd | 2 +-
wicd/backend.py | 27 +++++++++++++++------------
wicd/backends/be-external.py | 6 +++---
wicd/backends/be-ioctl.py | 6 +++---
wicd/configmanager.py | 4 ++--
wicd/configscript.py | 4 ++--
wicd/dbusmanager.py | 4 ++--
wicd/monitor.py | 5 +----
wicd/networking.py | 6 ++++++
wicd/wicd-daemon.py | 5 +++++
14 files changed, 82 insertions(+), 53 deletions(-)
delete mode 100755 other/50-wicd-suspend.sh
delete mode 100755 other/80-wicd-connect.sh
diff --git a/other/50-wicd-suspend.sh b/other/50-wicd-suspend.sh
deleted file mode 100755
index 2e3a6ab..0000000
--- a/other/50-wicd-suspend.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/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
deleted file mode 100755
index 6d56084..0000000
--- a/other/80-wicd-connect.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-# Bring wifi network interface back up.
-
-/opt/wicd/autoconnect.py
diff --git a/other/postinst b/other/postinst
index 8e40b17..a64d480 100755
--- a/other/postinst
+++ b/other/postinst
@@ -1,19 +1,26 @@
#!/bin/sh
-#stop daemon!
-/etc/init.d/wicd stop
-#remove because we changed stuff
-update-rc.d -f wicd remove
+# Stop daemon
+if [ -f /etc/init.d/wicd ]; then
+ /etc/init.d/wicd stop
+fi
+
+# Remove Wicd from the boot sequence
+if which update-rc.d &>/dev/null ; then
+ update-rc.d -f wicd remove
+fi
-#remove pyc files that screw things up sometimes
-#there shouldn't be any there, but it never hurts to check
-#they may exist if you are upgrading wicd
-rm -rf /opt/wicd/*.pyc
+# Remove pyc files
+# They may exist if you are upgrading Wicd
+rm -f /opt/wicd/*.pyc
-#add us to the startup
-#add us to 80 because sometimes dbus starts
-#later then 20, so that causes problems
-update-rc.d wicd start 80 2 3 4 5 . stop 20 0 1 6 .
+# Add Wicd to the startup sequence
+# 80 to make sure that dbus is running when Wicd starts
+if which update-rc.d &>/dev/null ; then
+ update-rc.d wicd start 80 2 3 4 5 . stop 20 0 1 6 .
+fi
-#start the daemon
-/etc/init.d/wicd start
+# Start the daemon
+if [ -f /etc/init.d/wicd ]; then
+ /etc/init.d/wicd start
+fi
diff --git a/other/wicd.conf b/other/wicd.conf
index b5807a6..05ab9ab 100755
--- a/other/wicd.conf
+++ b/other/wicd.conf
@@ -6,14 +6,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/scripts/wicd b/scripts/wicd
index d679bd7..dcac461 100755
--- a/scripts/wicd
+++ b/scripts/wicd
@@ -1,3 +1,3 @@
#!/bin/bash
-/usr/lib/wicd/wicd-daemon.py $@
+exec /usr/lib/wicd/wicd-daemon.py $@
diff --git a/wicd/backend.py b/wicd/backend.py
index 5221dda..dba57f7 100644
--- a/wicd/backend.py
+++ b/wicd/backend.py
@@ -7,9 +7,8 @@ Manages and loads the pluggable backends for wicd.
"""
#
-# Copyright (C) 2007 Adam Blackburn
-# Copyright (C) 2007 Dan O'Reilly
-# Copyright (C) 2007 Byron Hillis
+# Copyright (C) 2008 Adam Blackburn
+# Copyright (C) 2008 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
@@ -44,7 +43,7 @@ class BackendManager(object):
be_file.endswith(".py"))
def get_current_backend(self):
- if self.__loaded_backend and not self.__loaded_backend is None:
+ if self.__loaded_backend:
return self.__loaded_backend.NAME
else:
return None
@@ -68,7 +67,9 @@ class BackendManager(object):
"""
def fail(backend_name, reason):
print "Failed to load backend %s: %s" % (backend_name, reason)
-
+ return True
+
+ failed = False
print 'trying to load backend %s' % backend_name
backend_path = os.path.join(self.backend_dir,
'be-' + backend_name + '.py')
@@ -80,15 +81,17 @@ class BackendManager(object):
return None
if not backend.NAME:
- fail(backend_name, 'Missing NAME declaration.')
- return None
-
+ failed = fail(backend_name, 'Missing NAME attribute.')
+ if not backend.UPDATE_INTERVAL:
+ failed = fail(backend_name, "Missing UPDATE_INTERVAL attribute.")
+ if not backend.NeedsExternalCalls:
+ failed = fail(backend_name, "Missing NeedsExternalCalls method.")
if not backend.WiredInterface:
- fail(backend_name, "Missing WiredInterface class")
- return None
-
+ failed = fail(backend_name, "Missing WiredInterface class.")
if not backend.WirelessInterface:
- fail(backend_name, "Missing WirelessInterface class")
+ failed = fail(backend_name, "Missing WirelessInterface class.")
+
+ if failed:
return None
self.__loaded_backend = backend
diff --git a/wicd/backends/be-external.py b/wicd/backends/be-external.py
index b1c6fb8..93eea87 100644
--- a/wicd/backends/be-external.py
+++ b/wicd/backends/be-external.py
@@ -14,9 +14,8 @@ class WirelessInterface() -- Control a wireless network interface.
"""
#
-# Copyright (C) 2007 Adam Blackburn
-# Copyright (C) 2007 Dan O'Reilly
-# Copyright (C) 2007 Byron Hillis
+# Copyright (C) 2008 Adam Blackburn
+# Copyright (C) 2008 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
@@ -41,6 +40,7 @@ import time
NAME = "external"
+UPDATE_INTERVAL = 4
DESCRIPTION = """External app (slow) backend
This backend uses external program calls like ifconfig and
diff --git a/wicd/backends/be-ioctl.py b/wicd/backends/be-ioctl.py
index 3b53db0..d8a7629 100644
--- a/wicd/backends/be-ioctl.py
+++ b/wicd/backends/be-ioctl.py
@@ -15,9 +15,8 @@ class WirelessInterface() -- Control a wireless network interface.
"""
#
-# Copyright (C) 2007 Adam Blackburn
-# Copyright (C) 2007 Dan O'Reilly
-# Copyright (C) 2007 Byron Hillis
+# Copyright (C) 2008 Adam Blackburn
+# Copyright (C) 2008 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
@@ -49,6 +48,7 @@ import array
NAME = "ioctl"
+UPDATE_INTERVAL = 3
DESCRIPTION = """IOCTL (fast) backend
This backend uses IOCTL calls and python libraries to query
diff --git a/wicd/configmanager.py b/wicd/configmanager.py
index c049eae..9a16d64 100644
--- a/wicd/configmanager.py
+++ b/wicd/configmanager.py
@@ -8,8 +8,8 @@ reusable for other purposes as well.
"""
#
-# Copyright (C) 2007 Adam Blackburn
-# Copyright (C) 2007 Dan O'Reilly
+# Copyright (C) 2008 Adam Blackburn
+# Copyright (C) 2008 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
diff --git a/wicd/configscript.py b/wicd/configscript.py
index 590eb74..cc90144 100755
--- a/wicd/configscript.py
+++ b/wicd/configscript.py
@@ -10,8 +10,8 @@ run as the current user.
"""
#
-# Copyright (C) 2007 Adam Blackburn
-# Copyright (C) 2007 Dan O'Reilly
+# Copyright (C) 2007-2008 Adam Blackburn
+# Copyright (C) 2007-2008 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
diff --git a/wicd/dbusmanager.py b/wicd/dbusmanager.py
index e45a025..6ff8a5c 100644
--- a/wicd/dbusmanager.py
+++ b/wicd/dbusmanager.py
@@ -7,8 +7,8 @@ A module for storing wicd's dbus interfaces.
"""
#
-# Copyright (C) 2007 Adam Blackburn
-# Copyright (C) 2007 Dan O'Reilly
+# Copyright (C) 2008 Adam Blackburn
+# Copyright (C) 2008 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
diff --git a/wicd/monitor.py b/wicd/monitor.py
index fbc4449..31a314f 100755
--- a/wicd/monitor.py
+++ b/wicd/monitor.py
@@ -289,10 +289,7 @@ def main():
"""
monitor = ConnectionStatus()
- if daemon.GetCurrentBackend() == "ioctl":
- to_time = 3
- else:
- to_time = 4
+ to_time = daemon.GetBackendUpdateInterval()
try:
gobject.timeout_add_seconds(to_time, monitor.update_connection_status)
except:
diff --git a/wicd/networking.py b/wicd/networking.py
index 1783fd2..74f39bb 100644
--- a/wicd/networking.py
+++ b/wicd/networking.py
@@ -63,6 +63,12 @@ def get_backend_list():
else:
return BACKEND_MGR.get_available_backends()
+def get_backend_update_interval():
+ if not BACKEND_MGR:
+ return 4
+ else:
+ return BACKEND_MGR.UPDATE_INTERVAL
+
def get_current_backend():
if not BACKEND_MGR:
return None
diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py
index 87e7a60..b84267b 100644
--- a/wicd/wicd-daemon.py
+++ b/wicd/wicd-daemon.py
@@ -193,6 +193,11 @@ class WicdDaemon(dbus.service.Object):
""" Returns the currently loaded backend. """
return networking.get_current_backend()
+ @dbus.server.method('org.wicd.daemon')
+ def GetBackendUpdateInterval('org.wicd.daemon'):
+ """ Returns status update interval for the loaded backend. """
+ return networking.get_backend_update_interval()
+
@dbus.service.method('org.wicd.daemon')
def GetSavedBackend(self):
""" Returns the backend saved to disk. """