Logo Search packages:      
Sourcecode: ubuntuone-client version File versions

def ubuntuone::syncdaemon::dbus_interface::DBusInterface::__init__ (   self,
  bus,
  main,
  system_bus = None 
)

Create the instance and add the exposed object to the
specified bus.

Definition at line 574 of file dbus_interface.py.

00574                                                   :
        """ Create the instance and add the exposed object to the
        specified bus.
        """
        self.log = logging.getLogger("ubuntuone.SyncDaemon.DBus")
        self.bus = bus
        self.main = main
        self.event_queue = main.event_q
        self.action_queue = main.action_q
        self.fs_manager = main.fs
        self.volume_manager = main.vm
        self.busName = dbus.service.BusName(DBUS_IFACE_NAME, bus=self.bus)
        self.status = Status(self.busName, self)
        self.events = Events(self.busName, self.event_queue)
        self.event_listener = EventListener(self)
        self.sync = SyncDaemon(self.busName, self)
        self.fs = FileSystem(self.busName, self.fs_manager)
        self.shares = Shares(self.busName, self.fs_manager,
                             self.volume_manager)
        if system_bus is None and not DBusInterface.test:
            self.log.debug('using the real system bus')
            self.system_bus = self.bus.get_system()
        elif system_bus is None and DBusInterface.test:
            # this is just for the case when test_sync instatiate Main for
            # running it's tests as pqm don't have a system bus running
            self.log.debug('using the session bus as system bus')
            self.system_bus = self.bus
        else:
            self.system_bus = system_bus
        if self.event_queue:
            self.event_queue.subscribe(self.event_listener)
            # on initialization, fake a SYS_NET_CONNECTED if appropriate
            if DBusInterface.test:
                # testing under sync; just do it
                self.log.debug('using the fake NetworkManager')
                self.connection_state_changed(NM_STATE_CONNECTED)
            else:
                def error_handler(error):
                    """
                    Handle errors from NM
                    """
                    self.log.error(
                        "Error while getting the NetworkManager state %s",
                        error)
                    # If we get an error back from NetworkManager, we should
                    # just try to connect anyway; it probably means that
                    # NetworkManager is down or broken or something.
                    self.connection_state_changed(NM_STATE_CONNECTED)
                try:
                    nm = self.system_bus.get_object(
                        'org.freedesktop.NetworkManager',
                        '/org/freedesktop/NetworkManager')
                except dbus.DBusException, e:
                    if e.get_dbus_name() == \
                        'org.freedesktop.DBus.Error.ServiceUnknown':
                        # NetworkManager isn't running.
                        self.log.warn("Unable to connect to NetworkManager. "
                                      "Assuming we have network.")
                        self.connection_state_changed(NM_STATE_CONNECTED)
                    else:
                        raise
                else:
                    nm.Get('org.freedesktop.NetworkManager', 'State',
                           reply_handler=self.connection_state_changed,
                           error_handler=error_handler,
                           dbus_interface='org.freedesktop.DBus.Properties')
        # register a handler to NM StateChanged signal
        self.system_bus.add_signal_receiver(self.connection_state_changed,
                               signal_name='StateChanged',
                               dbus_interface='org.freedesktop.NetworkManager',
                               path='/org/freedesktop/NetworkManager')


    def shutdown(self):


Generated by  Doxygen 1.6.0   Back to index