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