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
# 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(
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's ID:", docker_container.container.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
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
brenthy_docker-0.3.1.tar.gz
(5.0 kB
view hashes)