import pyndows
path_to_retrieved_file = ""
with pyndows.connect(...) as machine:
pyndows.get(machine, "shared_folder_name", "/folder/requested_file_name", path_to_retrieved_file)import pyndows
with pyndows.connect(...) as machine:
description = pyndows.get_file_desc(machine, "shared_folder_name", "/folder/requested_file_name")import pyndows
file_to_move_path = ""
with pyndows.connect(...) as machine:
pyndows.move(machine, "shared_folder_name", "/folder/destination_file_name", file_to_move_path)You can also provide a custom suffix for the temporary file (.tmp is used by default) via the temp_file_suffix parameter.
import pyndows
with pyndows.connect(...) as machine:
pyndows.rename(machine, "shared_folder_name", "/folder/previous_file_name", "/folder/new_file_name")import pyndows
with pyndows.connect(...) as machine:
details = pyndows.check("connection identifier", machine)You can mock remote connections by using samba_mock pytest fixture.
You can simulate every Samba connection behavior such as:
- Exceptions being thrown
- Connectivity issue
- echo responses
And of course, the following usual operations:
from pyndows.testing import samba_mock, SMBConnectionMock
def test_file_retrieval(samba_mock: SMBConnectionMock):
samba_mock.files_to_retrieve[("shared_folder_name", "/folder/file_to_retrieve")] = "File content of path to a file"from pyndows.testing import samba_mock, SMBConnectionMock
def test_file_retrieval(samba_mock: SMBConnectionMock):
file_content = samba_mock.stored_files[("shared_folder_name", "/folder/file_that_was_stored")]- python 3.6+ must be installed
- Use pip to install module:
python -m pip install pyndows