Accessing Windows from Linux
Project description
Accessing Windows from Linux
Retrieve a file (from Windows to Linux)
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)
Retrieve a file description (from Windows to Linux)
import pyndows
with pyndows.connect(...) as machine:
description = pyndows.get_file_desc(machine, "shared_folder_name", "/folder/requested_file_name")
Move a file (from Linux to Windows)
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.
Rename a file
import pyndows
with pyndows.connect(...) as machine:
pyndows.rename(machine, "shared_folder_name", "/folder/previous_file_name", "/folder/new_file_name")
Ensure connectivity
import pyndows
with pyndows.connect(...) as machine:
details = pyndows.check("connection identifier", machine)
Testing
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:
Simulate a file that can be retrieved
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"
Ensure the content of a file that was moved or renamed
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")]
How to install
- python 3.6+ must be installed
- Use pip to install module:
python -m pip install pyndows
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyndows-3.3.1.tar.gz
(6.7 kB
view details)
Built Distribution
File details
Details for the file pyndows-3.3.1.tar.gz
.
File metadata
- Download URL: pyndows-3.3.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22b5a55c23283394184302b9fd2723f7c134e344f54c56c1587657dbf9139b03 |
|
MD5 | 775bc249a55c4b48fc2719b999f88029 |
|
BLAKE2b-256 | b7abe70001f74f50a33cf19c39b0e37e70bf1b1d63d44ab3785de5aa5f3cf80e |
Provenance
File details
Details for the file pyndows-3.3.1-py3-none-any.whl
.
File metadata
- Download URL: pyndows-3.3.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee7383641043933e80a2c9ef5de7e402588d0e0be203f247ba1b04e59dc8f917 |
|
MD5 | 8665e669e6f0a56dbd3ba463d60c015b |
|
BLAKE2b-256 | b1a4e55d7be80264eb040f1c3ec3e139a6ecd2066a1fb2f08d17284a1ba2c257 |