iot-samba-client 1.0.5

Last updated:

0 purchases

iot-samba-client 1.0.5 Image
iot-samba-client 1.0.5 Images
Add to Cart

Description:

iotsambaclient 1.0.5

iot-samba-client

This package is a wrapper around the smbprotocol SDK to provide a synchronous client for interacting with file shares from IoT edge devices.
Official Documentation | Source code | Package PyPI
Table of Contents

Versioning
Getting Started

Prerequisites
Basic Examples



Versioning
This repository adheres to Semantic Versioning. It will be maintained through the CHANGELOG.md and in GitHub Releases. It's important to note that you must maintain the version with your releases in iot/samba/client/_version.py, otherwise a new package version will fail to get published.
Getting Started
This section provides basic examples with the iot-samba-client.
Prerequisites


Python 3.7 or later is required to use this package.


You must have a Samba Windows File Share server to use this package.


Basic Examples


Install via pip:
pip install iot-samba-client



Import and say hello:
from iot.samba.client import __version__


print(f"hello world from iot-samba-client version: {__version__}")



Basic usage:
import tempfile

from iot.samba.client import IoTSambaClient

# instantiate client
samba_client = IoTSambaClient(
smb_server="windows-samba-s",
smb_host="1.2.3.456",
smb_port=445,
smb_user="mySambaUserName",
smb_pass="mySambaPass***"
)

# print info w/ repr
print(f"{samba_client.__repr__()}")

# download blob to tempfile
temp_file = tempfile.NamedTemporaryFile()
download_result = samba_client.download_file(
share="MY_SAMBA_SHARE",
path="path\\to\\blob\\parent\\dir",
file="blob.txt",
dest=temp_file.name,
)
if not download_result:
print("unable to download file")
temp_file.close()
samba_client.disconnect()
raise

# upload tempfile to blob
upload_result = samba_client.upload_file(
share="MY_SAMBA_SHARE",
path="path\\to\\new\\parent\\dir",
file="newBlob.txt",
source=temp_file.name,
)
if not upload_result:
print("unable to upload file")
temp_file.close()
samba_client.disconnect()
raise

# clean-up local memory and disconnect from smb session
temp_file.close()
samba_client.disconnect()

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.