Name | brenthy-docker JSON |
Version |
0.3.6
JSON |
| download |
home_page | None |
Summary | Interact with docker containers running IPFS and Brenthy. |
upload_time | 2025-01-02 14:45:59 |
maintainer | None |
docs_url | None |
author | None |
requires_python | None |
license | None |
keywords |
brenthy
walytis
docker
test
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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
```python
from brenthy_docker import BrenthyDocker, delete_containers
docker_container = BrenthyDocker()
```
By default, `BrenthyDocker` creates a container based on the [`emendir/brenthy_testing`](https://hub.docker.com/r/emendir/brenthy_testing) image.
You can, however, specify a custom image name, using:
```python
docker_container = BrenthyDocker(image="local/MyWalytisApp")
```
### Features Demo
The following python snippet demonstrates most of `BrenthyDocker`'s features.
```python
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()
```
Raw data
{
"_id": null,
"home_page": null,
"name": "brenthy-docker",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "brenthy, walytis, docker, test",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/72/c3/201e67144bafcadf956b7dfcf40a232494ac29139948b2fc5a44ff204a91/brenthy_docker-0.3.6.tar.gz",
"platform": null,
"description": "# Brenthy Docker Python Package\n\nThis package contains a `BrenthyDocker` class for interacting with docker containers running IPFS and Brenthy.\nIt contains useful methods for managing containers, transferring files into them and running python and bash code in them.\n\nThe main use-case for this class is for automated tests of Brenthy's blockchains and the applications built on them.\n\n## Usage\n\n### Simplest\n\n```python\nfrom brenthy_docker import BrenthyDocker, delete_containers\ndocker_container = BrenthyDocker()\n```\n\nBy default, `BrenthyDocker` creates a container based on the [`emendir/brenthy_testing`](https://hub.docker.com/r/emendir/brenthy_testing) image.\nYou can, however, specify a custom image name, using:\n\n```python\ndocker_container = BrenthyDocker(image=\"local/MyWalytisApp\")\n```\n\n### Features Demo\n\nThe following python snippet demonstrates most of `BrenthyDocker`'s features.\n\n```python\nfrom brenthy_docker import BrenthyDocker, delete_containers\n\n# remove any uncleanedup containers\ndelete_containers(container_name_substr=\"Brenthy-Demo\")\n\nprint(\"Creating docker container, waiting to connect to it via IPFS...\")\ndocker_container = BrenthyDocker(\n image=\"emendir/brenthy_testing\"\n container_name=\"Brenthy-Demo\",\n # await_brenthy=False, # don't wait till Brenthy has fully initialised\n # await_ipfs=False, # don't wait till we've established an IPFS connection to the docker container\n)\n\nprint(\"Container ID:\", docker_container.container.id)\nprint(\"Container's IPFS ID:\", docker_container.ipfs_id)\n\n# Execute shell command on the container\nshell_output = docker_container.run_shell_command(\n \"systemctl status brenthy\",\n print_output=False\n)\n\nprint(\"Output of Shell command:\", shell_output)\n\n# Execute Python command on the container\npython_output = docker_container.run_python_command(\n \"import walytis_beta_api;print(walytis_beta_api.get_walytis_beta_version())\",\n print_output=True,\n colour=\"green\"\n)\nprint(\"Output of Python command:\", python_output)\n\ndocker_container.transfer_file(\"brenthy_docker.py\", \"/tmp/test/wad.py\")\ndocker_container.run_shell_command(\"ls /tmp/test/\")\n\nremote_tempfile = docker_container.write_to_tempfile(\"Hello there!\")\ndocker_container.run_shell_command(f\"cat {remote_tempfile}\")\n# Stop the container\ndocker_container.stop()\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Interact with docker containers running IPFS and Brenthy.",
"version": "0.3.6",
"project_urls": {
"Github": "https://github.com/emendir/BrenthyAndWalytis/tree/master/tests/brenthy_docker/brenthy_docker/ReadMe.md",
"Homepage": "https://ipfs.io/ipns/emendir.tech/#BrenthyAndWalytis/tests/brenthy_docker/brenthy_docker/ReadMe.md",
"IPNS": "https://ipfs.io/ipns/emendir.tech/#BrenthyAndWalytis/tests/brenthy_docker/brenthy_docker/ReadMe.md"
},
"split_keywords": [
"brenthy",
" walytis",
" docker",
" test"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0830ceab78d271a3b2a075390fccec8e548c2065dfca11db77ee59a7bef89885",
"md5": "af39ca22c9338851f7407433925e7e77",
"sha256": "ddb747d7bc812e52093900b58fbece9291b5eb2b8b8490b364e55422084eb806"
},
"downloads": -1,
"filename": "brenthy_docker-0.3.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "af39ca22c9338851f7407433925e7e77",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7280,
"upload_time": "2025-01-02T14:45:57",
"upload_time_iso_8601": "2025-01-02T14:45:57.491698Z",
"url": "https://files.pythonhosted.org/packages/08/30/ceab78d271a3b2a075390fccec8e548c2065dfca11db77ee59a7bef89885/brenthy_docker-0.3.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "72c3201e67144bafcadf956b7dfcf40a232494ac29139948b2fc5a44ff204a91",
"md5": "34ca2ab1b3f179cbe64475ebfb882150",
"sha256": "97dd25c015533cbf85d2f448238f616a8a4e5d47a0cd42678ad79542ce733d92"
},
"downloads": -1,
"filename": "brenthy_docker-0.3.6.tar.gz",
"has_sig": false,
"md5_digest": "34ca2ab1b3f179cbe64475ebfb882150",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5768,
"upload_time": "2025-01-02T14:45:59",
"upload_time_iso_8601": "2025-01-02T14:45:59.704015Z",
"url": "https://files.pythonhosted.org/packages/72/c3/201e67144bafcadf956b7dfcf40a232494ac29139948b2fc5a44ff204a91/brenthy_docker-0.3.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-02 14:45:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "emendir",
"github_project": "BrenthyAndWalytis",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "brenthy-docker"
}