Skip to main content

Securely copy files to multiple destinations using source and destination verification.

Project description

o/COPY

PyPI version PyPI version GitHub license Code style: black codecov

A multi destination copy tool / library with source and destination verification using xxHash.

Installation / Update

With pip

If you have Python 3 installed you can just use pip:

pip3 install -U ocopy

Usage

CLI

cli

Python

import tempfile
from pathlib import Path
from time import sleep

from ocopy.copy import CopyJob


def simple_example():
    # For the sake of this example we will create temporary directory.
    # You will not be doing this in your code.
    with tempfile.TemporaryDirectory() as tmp:
        tmp = Path(tmp)

        # Define source and destination directories
        source = tmp / "source"
        destinations = [tmp / "destination_1", tmp / "destination_2", tmp / "destination_3"]

        # Create some test content
        source.mkdir(parents=True, exist_ok=True)
        (source / "testfile").write_text("Some test content")

        # Create the copy job and wait until it is finished
        job = CopyJob(source, destinations, overwrite=True, verify=True)
        while job.finished is not True:
            sleep(0.1)

        # Print errors
        for error in job.errors:
            print(f"Failed to copy {error.source.name}:\n{error.error_message}")

        # Show content of the mhl file
        mhl_file_content = list(destinations[0].glob("**/*.mhl"))[0].read_text()
        print(mhl_file_content)


if __name__ == "__main__":
    simple_example()

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

ocopy-0.7.1.tar.gz (29.1 kB view details)

Uploaded Source

File details

Details for the file ocopy-0.7.1.tar.gz.

File metadata

  • Download URL: ocopy-0.7.1.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.1

File hashes

Hashes for ocopy-0.7.1.tar.gz
Algorithm Hash digest
SHA256 022461f89cfbcaf1b74d3feac4893f1b8241a3e35ea9ec45ed708ce211e6ea03
MD5 73b68da5f629e015054687ec974e1d7d
BLAKE2b-256 bb4a2fc08c224f16d0ec3941e92b7a843e3cb4017d5ae85a61342a43ace048db

See more details on using hashes here.

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