Skip to main content

Accessing Windows from Linux

Project description

Accessing Windows from Linux

pypi version Build status Coverage Code style: black Number of tests Number of downloads

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

  1. python 3.6+ must be installed
  2. Use pip to install module:
python -m pip install pyndows

Project details


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.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

pyndows-3.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file pyndows-3.1.0.tar.gz.

File metadata

  • Download URL: pyndows-3.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.1

File hashes

Hashes for pyndows-3.1.0.tar.gz
Algorithm Hash digest
SHA256 090c104c08a4a5bc40e45d81b8cc489423218fb6a7e813d6a54ff0ee414bd8b9
MD5 1a47c0efcdf668ef1ce934bc1cba8dff
BLAKE2b-256 a7f1e2ce2426f5b632f5cc17237d5877f5b516aaaaa46f1785e32c43a355fe90

See more details on using hashes here.

Provenance

File details

Details for the file pyndows-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyndows-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 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/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.1

File hashes

Hashes for pyndows-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ddd7ee1448bded65030704fd85b5e6c74df77cc5a84ce69509a79b9e9d643210
MD5 9a3a9f7af9c8dfe9e3ed6ca59acdd2dc
BLAKE2b-256 f88b38217ec6c110487f1d8d2646ba47289d43e9d9d980694e115d0803900a5a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page