コード例 #1
0
ファイル: gtkui.py プロジェクト: orther/Deluge
                    def on_connect_fail(reason, try_counter, host, port, user,
                                        passwd):
                        if not try_counter:
                            return

                        if reason.check(deluge.error.AuthenticationRequired,
                                        deluge.error.BadLoginError):
                            log.debug("PasswordRequired exception")
                            dialog = dialogs.AuthenticationDialog(
                                reason.value.message, reason.value.username)

                            def dialog_finished(response_id, host, port):
                                if response_id == gtk.RESPONSE_OK:
                                    reactor.callLater(0.5, do_connect,
                                                      try_counter - 1, host,
                                                      port,
                                                      dialog.get_username(),
                                                      dialog.get_password())

                            dialog.run().addCallback(dialog_finished, host,
                                                     port)
                            return

                        log.error("Connection to host failed..")
                        log.info("Retrying connection.. Retries left: "
                                 "%s", try_counter)
                        reactor.callLater(0.5, update_connection_manager)
                        reactor.callLater(0.5, do_connect, try_counter - 1,
                                          host, port, user, passwd)
コード例 #2
0
    def __on_connected_failed(self, reason, host_id, host, port, user, passwd,
                              try_counter):
        log.debug("Failed to connect: %s", reason.value)

        if reason.check(AuthenticationRequired, BadLoginError):
            log.debug("PasswordRequired exception")
            dialog = dialogs.AuthenticationDialog(reason.value.message,
                                                  reason.value.username)

            def dialog_finished(response_id, host, port, user):
                if response_id == gtk.RESPONSE_OK:
                    self.__connect(host_id, host, port, user and user
                                   or dialog.get_username(),
                                   dialog.get_password())

            d = dialog.run().addCallback(dialog_finished, host, port, user)
            return d

        elif reason.trap(IncompatibleClient):
            dialog = dialogs.ErrorDialog(_("Incompatible Client"),
                                         reason.value.message)
            return dialog.run()

        if try_counter:
            log.info("Retrying connection.. Retries left: %s", try_counter)
            return reactor.callLater(0.5,
                                     self.__connect,
                                     host_id,
                                     host,
                                     port,
                                     user,
                                     passwd,
                                     try_counter=try_counter - 1)

        msg = str(reason.value)
        if not self.builder.get_object("chk_autostart").get_active():
            msg += '\n' + _("Auto-starting the daemon locally is not enabled. "
                            "See \"Options\" on the \"Connection Manager\".")
        dialogs.ErrorDialog(_("Failed To Connect"), msg).run()