Samba connection¶
Bases: FileConnection
Samba file connection. |support_hooks|
Based on pysmb library <https://pypi.org/project/pysmb/>_.
.. versionadded:: 0.9.4
.. warning::
To use Samba connector you should install package as follows:
.. code:: bash
pip install "onetl[samba]"
# or
pip install "onetl[files]"
See :ref:`install-files` installation instruction for more details.
Parameters:
-
host(str) –Host of Samba source. For example:
mydomain.com. -
share(str) –The name of the share on the Samba server.
-
protocol(str, default:`SMB`) –The protocol to use for the connection. Either
SMBorNetBIOS. Affects the default port and theis_direct_tcpflag inSMBConnection. -
port(int, default:445) –Port of Samba source.
-
domain(str, default:``) –Domain name for the Samba connection. Empty strings means use
hostas domain name. -
auth_type(str, default:`NTLMv2`) –The authentication type to use. Either
NTLMv2orNTLMv1. Affects theuse_ntlm_v2flag inSMBConnection. -
user(str, default:None) –User, which have access to the file source. Can be
Nonefor anonymous connection. -
password(str, default:None) –Password for file source connection. Can be
Nonefor anonymous connection.
Examples:
Create and check Samba connection:
.. code:: python
from onetl.connection import Samba
samba = Samba(
host="mydomain.com",
share="share_name",
protocol="SMB",
port=445,
user="user",
password="password",
).check()
check()
¶
Check source availability. |support_hooks|
If not, an exception will be raised.
Returns:
-
Connection itself–
Raises:
-
RuntimeError–If the connection is not available
Examples:
.. code:: python
connection.check()
path_exists(path)
¶
Check if specified path exists on remote filesystem. |support_hooks|.
.. versionadded:: 0.8.0
Parameters:
-
path(str | :obj:os.PathLike) –Path to check
Returns:
-
``True`` if path exists, ``False`` otherwise–
Examples:
>>> connection.path_exists("/path/to/file.csv")
True
>>> connection.path_exists("/path/to/dir")
True
>>> connection.path_exists("/path/to/missing")
False