Skip to main content

Interact with docker containers running IPFS and Brenthy.

Project description

Brenthy Docker Python Package

This package contains a BrenthyDocker class for interacting with docker containers running IPFS and Brenthy. It contains useful methods for managing containers, transferring files into them and running python and bash code in them.

The main use-case for this class is for automated tests of Brenthy's blockchains and the applications built on them.

Usage

Simplest

from brenthy_docker import BrenthyDocker, delete_containers
docker_container = BrenthyDocker()

By default, BrenthyDocker creates a container based on the emendir/brenthy_testing image. You can, however, specify a custom image name, using:

docker_container = BrenthyDocker(image="local/MyWalytisApp")

Features Demo

The following python snippet demonstrates most of BrenthyDocker's features.

from brenthy_docker import BrenthyDocker, delete_containers

# remove any uncleanedup containers
delete_containers(container_name_substr="Brenthy-Demo")

print("Creating docker container, waiting to connect to it via IPFS...")
docker_container = BrenthyDocker(
    image="emendir/brenthy_testing"
    container_name="Brenthy-Demo",
    # await_brenthy=False,  # don't wait till Brenthy has fully initialised
    # await_ipfs=False,    # don't wait till we've established an IPFS connection to the docker container
)

print("Container ID:", docker_container.container.id)
print("Container's IPFS ID:", docker_container.ipfs_id)

# Execute shell command on the container
shell_output = docker_container.run_shell_command(
    "systemctl status brenthy",
    print_output=False
)

print("Output of Shell command:", shell_output)

# Execute Python command on the container
python_output = docker_container.run_python_command(
    "import walytis_beta_api;print(walytis_beta_api.get_walytis_beta_version())",
    print_output=True,
    colour="green"
)
print("Output of Python command:", python_output)

docker_container.transfer_file("brenthy_docker.py", "/tmp/test/wad.py")
docker_container.run_shell_command("ls /tmp/test/")

remote_tempfile = docker_container.write_to_tempfile("Hello there!")
docker_container.run_shell_command(f"cat {remote_tempfile}")
# Stop the container
docker_container.stop()

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

brenthy_docker-0.4.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brenthy_docker-0.4.1-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file brenthy_docker-0.4.1.tar.gz.

File metadata

  • Download URL: brenthy_docker-0.4.1.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for brenthy_docker-0.4.1.tar.gz
Algorithm Hash digest
SHA256 a1fa1052ac3920bc1722385a82eeee0e3584b0bca6b2862419f71409a0777c76
MD5 57a7482ec1a7897b9dc0620a1c6b0df0
BLAKE2b-256 987c2e908ce60744cc94275bf42cc3d2a846f381524266ee59b594c70c490057

See more details on using hashes here.

File details

Details for the file brenthy_docker-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: brenthy_docker-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for brenthy_docker-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 01d48d789ff8f8c9bd3d16a8a33c9e3ddcf1aa8428fde7596520eb37886bc2b5
MD5 ad9a809199a906172f64f435d077241d
BLAKE2b-256 4d3adb3d08803dc13eb896baa1c722a2abcd881370574593f079f7b6672736bb

See more details on using hashes here.

Supported by

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