mirror of
https://github.com/gryf/wicd.git
synced 2026-01-10 15:54:13 +01:00
Merged r366 of mainline 1.6.
This commit is contained in:
15
setup.py
15
setup.py
@@ -24,23 +24,26 @@ import subprocess
|
||||
|
||||
# Be sure to keep this updated!
|
||||
# VERSIONNUMBER
|
||||
VERSION_NUM = '1.6.0a1'
|
||||
VERSION_NUM = '1.6.0a2'
|
||||
# REVISION_NUM is automatically updated
|
||||
REVISION_NUM = 'unknown'
|
||||
CURSES_REVNO = 'uimod'
|
||||
|
||||
# change to the directory setup.py is contained in
|
||||
os.chdir(os.path.abspath(os.path.split(__file__)[0]))
|
||||
|
||||
try:
|
||||
try:
|
||||
os.system('bzr version-info --python > vcsinfo.py')
|
||||
except:
|
||||
pass
|
||||
if os.path.exists('.bzr') and os.system('bzr') == 0:
|
||||
try:
|
||||
os.system('bzr version-info --python > vcsinfo.py')
|
||||
except:
|
||||
pass
|
||||
import vcsinfo
|
||||
REVISION_NUM = vcsinfo.version_info['revno']
|
||||
except Exception, e:
|
||||
print 'failed to find revision number:'
|
||||
print e
|
||||
|
||||
|
||||
class configure(Command):
|
||||
description = "configure the paths that Wicd will be installed to"
|
||||
|
||||
|
||||
@@ -149,6 +149,7 @@ class appGui(object):
|
||||
gladefile = os.path.join(wpath.share, "wicd.glade")
|
||||
self.wTree = gtk.glade.XML(gladefile)
|
||||
self.window = self.wTree.get_widget("window1")
|
||||
self.window.set_icon_from_file(wpath.icons +'scalable/apps/wicd-client.svg')
|
||||
size = daemon.ReadWindowSize("main")
|
||||
width = size[0]
|
||||
height = size[1]
|
||||
|
||||
@@ -45,7 +45,7 @@ daemon = dbus_dict["daemon"]
|
||||
wired = dbus_dict["wired"]
|
||||
wireless = dbus_dict["wireless"]
|
||||
|
||||
monitor = to_time = update_callback = mainloop = None
|
||||
mainloop = None
|
||||
|
||||
def diewithdbus(func):
|
||||
def wrapper(self, *__args, **__kargs):
|
||||
@@ -86,11 +86,42 @@ class ConnectionStatus(object):
|
||||
self.iwconfig = ""
|
||||
self.trigger_reconnect = False
|
||||
self.__lost_dbus_count = 0
|
||||
|
||||
self._to_time = daemon.GetBackendUpdateInterval()
|
||||
|
||||
self.add_poll_callback()
|
||||
bus = dbusmanager.get_bus()
|
||||
bus.add_signal_receiver(self._force_update_connection_status,
|
||||
"UpdateState", "org.wicd.daemon")
|
||||
bus.add_signal_receiver(self._update_timeout_interval,
|
||||
"SignalBackendChanged", "org.wicd.daemon")
|
||||
|
||||
def _update_timeout_interval(self, interval):
|
||||
""" Update the callback interval when signaled by the daemon. """
|
||||
self._to_time = interval
|
||||
gobject.source_remove(self.update_callback)
|
||||
self.add_poll_callback()
|
||||
|
||||
def _force_update_connection_status(self):
|
||||
""" Run a connection status update on demand.
|
||||
|
||||
Removes the scheduled update_connection_status()
|
||||
call, explicitly calls the function, and reschedules
|
||||
it.
|
||||
|
||||
"""
|
||||
gobject.source_remove(self.update_callback)
|
||||
self.update_connection_status()
|
||||
self.add_poll_callback()
|
||||
|
||||
def add_poll_callback(self):
|
||||
""" Registers a polling call at a predetermined interval.
|
||||
|
||||
The polling interval is determined by the backend in use.
|
||||
|
||||
"""
|
||||
self.update_callback = misc.timeout_add(self._to_time,
|
||||
self.update_connection_status)
|
||||
|
||||
def check_for_wired_connection(self, wired_ip):
|
||||
""" Checks for a wired connection.
|
||||
|
||||
@@ -229,19 +260,6 @@ class ConnectionStatus(object):
|
||||
self.auto_reconnect(from_wireless)
|
||||
return self.update_state(state)
|
||||
|
||||
def _force_update_connection_status(self):
|
||||
""" Run a connection status update on demand.
|
||||
|
||||
Removes the scheduled update_connection_status()
|
||||
call, explicitly calls the function, and reschedules
|
||||
it.
|
||||
|
||||
"""
|
||||
global update_callback
|
||||
gobject.source_remove(update_callback)
|
||||
self.update_connection_status()
|
||||
add_poll_callback()
|
||||
|
||||
def update_state(self, state, wired_ip=None, wifi_ip=None):
|
||||
""" Set the current connection state. """
|
||||
# Set our connection state/info.
|
||||
@@ -333,12 +351,6 @@ def err_handle(error):
|
||||
""" Just a dummy function needed for asynchronous dbus calls. """
|
||||
pass
|
||||
|
||||
def add_poll_callback():
|
||||
global monitor, to_time, update_callback
|
||||
|
||||
update_callback = misc.timeout_add(to_time,
|
||||
monitor.update_connection_status)
|
||||
|
||||
def main():
|
||||
""" Starts the connection monitor.
|
||||
|
||||
@@ -346,11 +358,8 @@ def main():
|
||||
an amount of time determined by the active backend.
|
||||
|
||||
"""
|
||||
global monitor, to_time, mainloop
|
||||
|
||||
global mainloop
|
||||
monitor = ConnectionStatus()
|
||||
to_time = daemon.GetBackendUpdateInterval()
|
||||
add_poll_callback()
|
||||
mainloop = gobject.MainLoop()
|
||||
mainloop.run()
|
||||
|
||||
|
||||
@@ -660,7 +660,7 @@ def setup_dbus(force=True):
|
||||
misc.PromptToStartDaemon()
|
||||
try:
|
||||
dbusmanager.connect_to_dbus()
|
||||
except dbusmanager.DBusException:
|
||||
except DBusException:
|
||||
error(None, "Could not connect to wicd's D-Bus interface. " +
|
||||
"Check the wicd log for error messages.")
|
||||
return False
|
||||
|
||||
@@ -37,6 +37,8 @@ import sys
|
||||
import time
|
||||
import getopt
|
||||
import signal
|
||||
import atexit
|
||||
from subprocess import Popen
|
||||
|
||||
# DBUS
|
||||
import gobject
|
||||
@@ -206,6 +208,7 @@ class WicdDaemon(dbus.service.Object):
|
||||
self.suspended = True
|
||||
self.wifi.LoadBackend(backend)
|
||||
self.wired.LoadBackend(backend)
|
||||
self.SignalBackendChanged(self.GetBackendUpdateInterval())
|
||||
self.SetSuspend(False)
|
||||
|
||||
@dbus.service.method('org.wicd.daemon')
|
||||
@@ -822,6 +825,11 @@ class WicdDaemon(dbus.service.Object):
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
@dbus.service.signal(dbus_interface='org.wicd.daemon', signature='i')
|
||||
def SignalBackendChanged(self, interval):
|
||||
""" Emits a signal when the current backend changes. """
|
||||
pass
|
||||
|
||||
def ReadConfig(self):
|
||||
""" Reads the manager-settings.conf file.
|
||||
@@ -1601,8 +1609,6 @@ def daemonize():
|
||||
os.dup2(0, 2)
|
||||
|
||||
|
||||
child_pid = None
|
||||
|
||||
def main(argv):
|
||||
""" The main daemon program.
|
||||
|
||||
@@ -1610,7 +1616,6 @@ def main(argv):
|
||||
argv -- The arguments passed to the script.
|
||||
|
||||
"""
|
||||
global child_pid
|
||||
do_daemonize = True
|
||||
redirect_stderr = True
|
||||
redirect_stdout = True
|
||||
@@ -1667,9 +1672,10 @@ def main(argv):
|
||||
wicd_bus = dbus.service.BusName('org.wicd.daemon', bus=bus)
|
||||
daemon = WicdDaemon(wicd_bus, auto_connect=auto_connect)
|
||||
if not no_poll:
|
||||
(child_pid, x, y, z) = gobject.spawn_async(
|
||||
[misc.find_path("python"), "-O", os.path.join(wpath.lib, "monitor.py")])
|
||||
signal.signal(signal.SIGTERM, sigterm_caught)
|
||||
child_pid = Popen([misc.find_path("python"), "-O",
|
||||
os.path.join(wpath.lib, "monitor.py")],
|
||||
shell=False, close_fds=True).pid
|
||||
atexit.register(on_exit, child_pid)
|
||||
|
||||
# Enter the main loop
|
||||
mainloop = gobject.MainLoop()
|
||||
@@ -1678,11 +1684,9 @@ def main(argv):
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
daemon.DaemonClosing()
|
||||
sigterm_caught()
|
||||
|
||||
def sigterm_caught(sig=None, frame=None):
|
||||
def on_exit(child_pid):
|
||||
""" Called when a SIGTERM is caught, kills monitor.py before exiting. """
|
||||
global child_pid
|
||||
if child_pid:
|
||||
print 'Daemon going down, killing wicd-monitor...'
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user