Skip to main content

miarec_smbfs SMB filesystem for PyFilesystem2

Actions License

This is a fork of fs.smbfs

The code was modified by MiaRec team to fullfill our needs.

Notable differences between miarec_s3fs and fs-s3fs

  1. Requires Python 3.7+. A support of older version of Python was removed.

  2. The opener protocol prefix is msmb:// (instead of the original smb://)

Requirements

PyFilesystem2 PyPI fs Source fs License fs
six PyPI six Source six License six
PySMB PyPI pysmb Source pysmb License pysmb

miarec_smbfs supports Python versions 3.7+

Installation

Install directly from PyPI, using pip :

$ pip install miarec_smbfs

Usage

Opener

Use fs.open_fs to open a filesystem with an SMB FS URL:

import fs
smb_fs = fs.open_fs('msmb://username:password@SAMBAHOSTNAME:port/share')

The opener can use either an IPv4 address or a NetBIOS hostname, using the NetBIOS name service to find the other token. Otherwise, if NetBIOS is not available, a new SMB connection can be established by using the IPv4 address and giving the hostname with the hostname URL parameter.

The following parameters can be passed as URL parameters: timeout, name-port, direct-tcp, hostname, and domain.

Constructor

import miarec_smbfs
smb_fs = miarec_smbfs.SMBFS(
    host, username="guest", passwd="", timeout=15,
    port=139, name_port=137, direct_tcp=False, domain=""
)

with each argument explained below:

  • host: either the host name (not the FQDN) of the SMB server, its IP address, or both in a tuple. If either the IP address or the host name is not given, NETBIOS is queried to get the missing data.
  • user: the username to connect with, defaults to "guest" for anonymous connection.
  • passwd: an optional password to connect with, defaults to "" for anonymous connection.
  • timeout: the timeout, in seconds, for NetBIOS and TCP requests.
  • port: the port the SMB server is listening on.
  • name_port: the port the NetBIOS naming service is listening on.
  • direct_tcp: set to True if the server is accessible directly through TCP, leave as False for maximum compatibility.
  • domain: the network domain to connect with, i.e. the workgroup on Windows. Usually safe to leave as empty string, the default.

Once created, the SMBFS filesystem behaves like any other filesystem (see the Pyfilesystem2 documentation), except if it was open in the root directory of the server, in which case the root directory of the SMBFS instance will be read-only (since SMB clients cannot create new shares).

Testing

Automated unit tests are run on GitHub Actions

To run the tests locally, do the following.

Install Docker on local machine.

Create activate python virtual environment:

python -m vevn venv
source venv\bin\activate

Install the project and test dependencies:

pip install -e ".[test]"

Run tests:

pytest

Credits

miarec_smbfs is developed and maintained by MiaRec

The original code (fs.smbfs) was developed by:

Metadata

Release files for miarec-smbfs 2024.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for miarec-smbfs 2024.1.1
File Size Uploaded
miarec_smbfs-2024.1.1.tar.gz 18.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for miarec-smbfs 2024.1.1
File Interpreter ABI Platform
miarec_smbfs-2024.1.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 34.0 kB

Release files / miarec_smbfs-2024.1.1.tar.gz

Download URL miarec_smbfs-2024.1.1.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
272fa4e817c4abf670d19f1af27037f5bb590c1e2b484ea78784b2076b7440b4
BLAKE2b-256 checksum
How to use checksums
f5155b70bedc504e4090b2798c229a59614b5c69b299def4ed0c80d771f78da1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / miarec_smbfs-2024.1.1-py2.py3-none-any.whl

Download URL miarec_smbfs-2024.1.1-py2.py3-none-any.whl
Size 15.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c026cf131201e1240cd9e2c7622e06c352ee85a15c81ce045fceb91c9cdcb9e4
BLAKE2b-256 checksum
How to use checksums
e26cfb08e72db74493034ed7d82cc610c3519c0f9d4f4958ab2dd583f1a7a10f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

2024.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page