Esempio n. 1
0
 def is_connected(self):
     """
     Return `True` if the filesystem client is connected to the data source, and
     `False` otherwise.
     """
     self.__assert_server_reachable()
     if self.remote and not is_port_bound(self.host, self.port):
         self.disconnect()
         return False
     return self._is_connected()
Esempio n. 2
0
 def __assert_server_reachable(self):
     if not is_port_bound(self.host, self.port):
         if self.remote and not self.remote.is_port_bound(self._host, self._port):
             self.disconnect()
             raise DuctServerUnreachable(
                 "Remote '{}' cannot connect to '{}:{}'. Please check your settings before trying again.".format(
                     self.remote.name, self._host, self._port))
         elif not self.remote:
             self.disconnect()
             raise DuctServerUnreachable(
                 "Cannot connect to '{}:{}' on your current connection. Please check your connection before trying again.".format(
                     self.host, self.port))
Esempio n. 3
0
    def is_connected(self):
        """
        Return `True` if the filesystem client is connected to the data source, and
        `False` otherwise.
        """
        if not self.__prepared:
            return False

        if self.remote:
            if not self.remote.has_port_forward(self._host, self._port):
                return False
            elif not is_port_bound(self.host, self.port):
                self.disconnect()
                return False

        return self._is_connected()
Esempio n. 4
0
    def __assert_server_reachable(self):
        if self.host is not None or self.port is not None:
            if self.host is None:
                raise ValueError("Port specified but no host provided.")
            if self.port is None:
                raise ValueError("Host specified but no port specified.")
        else:
            return

        if not is_port_bound(self.host, self.port):
            if self.remote and not self.remote.is_port_bound(self._host, self._port):
                self.disconnect()
                raise DuctServerUnreachable(
                    "Remote '{}' cannot connect to '{}:{}'. Please check your settings before trying again.".format(
                        self.remote.name, self._host, self._port))
            elif not self.remote:
                self.disconnect()
                raise DuctServerUnreachable(
                    "Cannot connect to '{}:{}' on your current connection. Please check your connection before trying again.".format(
                        self.host, self.port))
Esempio n. 5
0
    def __assert_server_reachable(self):
        if self.host is not None or self.port is not None:
            if self.host is None:
                raise ValueError("Port specified but no host provided.")
            if self.port is None:
                raise ValueError("Host specified but no port specified.")
        else:
            return

        if not is_port_bound(self.host, self.port):
            if self.remote and not self.remote.is_port_bound(self._host, self._port):
                self.disconnect()
                raise DuctServerUnreachable(
                    "Remote '{}' cannot connect to '{}:{}'. Please check your settings before trying again.".format(
                        self.remote.name, self._host, self._port))
            elif not self.remote:
                self.disconnect()
                raise DuctServerUnreachable(
                    "Cannot connect to '{}:{}' on your current connection. Please check your connection before trying again.".format(
                        self.host, self.port))
Esempio n. 6
0
    def is_connected(self):
        """
        This method checks to see whether a `Duct` instance is currently
        connected. This is performed by verifying that the remote host and port
        are still accessible, and then by calling `Duct._is_connected`, which
        should be implemented by subclasses.

        Returns:
            bool: Whether this `Duct` instance is currently connected.
        """
        if not self.__prepared:
            return False

        if self.remote:
            if not self.remote.has_port_forward(self._host, self._port):
                return False
            elif not is_port_bound(self.host, self.port):
                self.disconnect()
                return False

        return self._is_connected()
Esempio n. 7
0
    def is_connected(self):
        """
        This method checks to see whether a `Duct` instance is currently
        connected. This is performed by verifying that the remote host and port
        are still accessible, and then by calling `Duct._is_connected`, which
        should be implemented by subclasses.

        Returns:
            bool: Whether this `Duct` instance is currently connected.
        """
        if not self.__prepared:
            return False

        if self.remote:
            if not self.remote.has_port_forward(self._host, self._port):
                return False
            elif not is_port_bound(self.host, self.port):
                self.disconnect()
                return False

        return self._is_connected()