Exemplo n.º 1
0
 def update(self):
     self.setText(0, u"%s@%s:%d" % (self.username, self.host, self.port))
     if self.is_connected():
         self.version = yield client.daemon.info()
         self.setIcon(0, self._icon_connected)
         self.setText(1, self.version)
     else:
         c = Client()
         try:
             yield c.connect(self.host, self.port, self.username, self.password)
             self.version = yield c.daemon.info()
             self.setIcon(0, self._icon_alive)
         except Exception:
             log.debug("Connection failed", exc_info=True)
             self.version = ""
             self.setIcon(0, self._icon_dead)
         finally:
             if c.connected():
                 c.disconnect()
         self.setText(1, self.version)
Exemplo n.º 2
0
 def update(self):
     self.setText(0, u"%s@%s:%d" % (self.username, self.host, self.port))
     if self.is_connected():
         self.version = yield client.daemon.info()
         self.setIcon(0, self._icon_connected)
         self.setText(1, self.version)
     else:
         c = Client()
         try:
             yield c.connect(self.host, self.port, self.username,
                             self.password)
             self.version = yield c.daemon.info()
             self.setIcon(0, self._icon_alive)
         except Exception:
             log.debug("Connection failed", exc_info=True)
             self.version = ""
             self.setIcon(0, self._icon_dead)
         finally:
             if c.connected():
                 c.disconnect()
         self.setText(1, self.version)
Exemplo n.º 3
0
def started_deluge_client(tmpdir):
    # Set Up
    standalone_client = Client()

    if len(component._ComponentRegistry.components) != 0:
        warnings.warn("The component._ComponentRegistry.components"
                      " is not empty on test setup.\n"
                      "This is probably caused by another test"
                      " that did not clean up after finishing!:"
                      f" {component._ComponentRegistry.components}")

    configmanager.set_config_dir(tmpdir)
    standalone_client.start_standalone()

    pytest_twisted.blockon(component.start())
    yield standalone_client

    # Tear Down
    pytest_twisted.blockon(standalone_client.disconnect())
    pytest_twisted.blockon(component.shutdown())

    # There can be KeyErrors after pytest run about RPCServer
    # This errors are happening because of the next clear()
    #
    # It is so because plugins objects (that are based on CorePluginBase)
    # are still stored inside RPCServer's factory.methods
    # When RPCServer object is destroyed, it's dicts are cleared as well
    # That's when CorePluginBase.__del__ is called
    # And it tries to obtain RPCServer object from a list of components,
    # but this object already excluded from the list, so it fails to
    # deregister itself from RPCServer's dicts.
    #
    # Moreover, calling RPCServer's deregister_object is of no use, because:
    # def deregister_object(self, obj):
    #     """
    #     Deregisters an objects exported rpc methods.
    #
    #     :param obj: the object that was previously registered
    #
    #     """
    # >       for key, value in self.factory.methods.items():
    #             if value.__self__ == obj:
    #                 del self.factory.methods[key]
    # E       RuntimeError: dictionary changed size during iteration

    component._ComponentRegistry.components.clear()
    component._ComponentRegistry.dependents.clear()