Skip to content

Подключение к FTPS

Bases: FTP

FTPS file connection. |support_hooks|

Based on FTPUtil library <https://pypi.org/project/ftputil/>_.

.. warning::

Since onETL v0.7.0 to use FTPS connector you should install package as follows:

.. code:: bash

    pip install "onetl[ftps]"

    # or
    pip install "onetl[files]"

See :ref:`install-files` installation instruction for more details.

.. versionadded:: 0.1.0

Parameters

host : str Host of FTPS source. For example: ftps.domain.com

int, default: 21

Port of FTPS source

str, default: None

User, which have access to the file source. For example: someuser.

None means that the user is anonymous.

str, default: None

Password for file source connection.

None means that the user is anonymous.

Examples

Create and check FTPS connection:

.. code:: python

from onetl.connection import FTPS

ftps = FTPS(
    host="ftps.domain.com",
    user="someuser",
    password="*****",
).check()
Source code in onetl/connection/file_connection/ftps.py
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
class FTPS(FTP):
    """FTPS file connection. |support_hooks|

    Based on `FTPUtil library <https://pypi.org/project/ftputil/>`_.

    .. warning::

        Since onETL v0.7.0 to use FTPS connector you should install package as follows:

        .. code:: bash

            pip install "onetl[ftps]"

            # or
            pip install "onetl[files]"

        See :ref:`install-files` installation instruction for more details.

    .. versionadded:: 0.1.0

    Parameters
    ----------
    host : str
        Host of FTPS source. For example: ``ftps.domain.com``

    port : int, default: ``21``
        Port of FTPS source

    user : str, default: ``None``
        User, which have access to the file source. For example: ``someuser``.

        ``None`` means that the user is anonymous.

    password : str, default: ``None``
        Password for file source connection.

        ``None`` means that the user is anonymous.

    Examples
    --------

    Create and check FTPS connection:

    .. code:: python

        from onetl.connection import FTPS

        ftps = FTPS(
            host="ftps.domain.com",
            user="someuser",
            password="*****",
        ).check()
    """

    def _get_client(self) -> FTPHost:
        """
        Returns a FTPS connection object
        """

        session_factory = ftp_session.session_factory(
            base_class=TLSfix,
            port=self.port,
            encrypt_data_channel=True,
            debug_level=0,
        )

        return FTPHost(
            self.host,
            self.user,
            self.password.get_secret_value() if self.password else None,
            session_factory=session_factory,
        )