Skip to content

Samba connection

Bases: FileConnection

Samba file connection. support hooks

Based on pysmb library.

Added in 0.9.4

Warning

To use Samba connector you should install package as follows:

pip install "onetl[samba]"

# or
pip install "onetl[files]"
See File connections install 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 SMB or NetBIOS. Affects the default port and the is_direct_tcp flag in SMBConnection.

  • port (int, default: 445 ) –

    Port of Samba source.

  • domain (str, default: ` ) –

    Domain name for the Samba connection. Empty strings means use host as domain name.

  • auth_type (str, default: NTLMv2 ) –

    The authentication type to use. Either NTLMv2 or NTLMv1``. Affects theuse_ntlm_v2flag inSMBConnection`.

  • user (str, default: None ) –

    User, which have access to the file source. Can be None for anonymous connection.

  • password (str, default: None ) –

    Password for file source connection. Can be None for anonymous connection.

Examples:

Create and check Samba connection:

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:

  • self

    Connection itself.

Raises:

  • RuntimeError

    If the connection is not available

Examples:

connection.check()

path_exists(path)

Check if specified path exists on remote filesystem. support hooks.

Added in 0.8.0

Parameters:

  • path (str | PathLike) –

    Path to check

Returns:

  • bool

    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