Skip to main content

1 Tsaotun - Python based Assistance for Docker

Q: I can’t figure out why I would need this

A:

In traditional ways, we make aliases ourselves all over the Docker commands.

The reason why I develop this project is to encourage people to contribute and share their ideas and thoughts into plugins, which would give Tsaotun ability to do those things. And, the aboved thing is just one of things that Tsaotun can achieve, you will be able to load variety of plugins in the future as well.

Besides, if you are doing some projects involved running containers, Tsaotun has provide the higher level API for you. That is another helpful functionality.

Currently, I’m moving my previous project VWGen into one of Tsaotun’s plugin. Once I finish, everyone can just load the plugin and extend the power of Tsaotun.

Higher level API

Latest version released on PyPi Compatible on Linux Compatible on Mac Compatible on Windows

1.1 Main features

  • Run any commands docker can run on Tsaotun

  • All written in Python with love of API of docker

  • Simplify the process making your own implementation of docker command line tool

  • Many Addons are upcoming

1.2 Installation (All platforms)

1.2.1 pip

A universal installation method (that works on Windows, Mac OS X, Linux, and always provides the latest version) is to use pip:

# Make sure we have an up-to-date version of pip and setuptools:
$ pip install --upgrade pip setuptools

$ pip install --upgrade tsaotun

(If pip installation fails for some reason, you can try easy_install tsaotun as a fallback.)

1.2.2 Docker hub

Pull from dockerhub, or build it yourself:

$ docker build -t tsaotun .

Verify that now we have installed the latest version, for example:

$ tsaotun version
Client:
    Version:         0.8.1
    Python version:  2.7.13
    OS/Arch:         Darwin/x86_64

Server:
    Version:         1.13.0-rc7
    API version:     1.25 (minimum version 1.12)
    Go version:      go1.7.3
    Git commit:      48a9e53
    Built:           5 days ago
    OS/Arch:         linux/amd64
    Kernel version:  4.9.3-moby
    Experimental:    True

1.3 Usage

Hello World:

$ tsaotun [COMMAND]

Synopsis:

$ tsaotun [-h] [--console] [--color] [--debug] [--dry] [--host list]
          [--verbose]
          {version,info,inspect,container,image,network,volume,addon}
          ...

See also tsaotun --help.

1.4 Addon

Addon feature is testing right now, and each addon should has its own folder with __init__.py inside.

Addon folder struture shows like:

$HOME
└───Tsaotun
    └───addons
        ├── addon_A - __init__.py, ...
        ├── addon_B - __init__.py, ...
        └───__init__.py

1.4.1 Best practices (Sample addon to remove “ALL” containers at once, no matter it’s dead or alive)

__init__.py: To specify how to override the original command

"""Configuration file for this addon"""

from .Container import rm

__override__ = {'Container.rm': 'Rm'}
__argparse__ = [
    {
        'namespace': "Container",
        'position': "Child",
        'subcommand': "rm",
        'actions': [
            "add_argument('--clear',            \
                            action='store_true', \
                            dest='clear',        \
                            help='Remove all dead and alive containers. \
                                    You still need to give a whatever container ID.')",
        ],
    },
]

Container/rm.py

"""This module contains `docker container rm` class"""

from docker.errors import APIError
from tsaotun.lib.Docker.Container.command import Command
from tsaotun.cli import Tsaotun


class Rm(Command):
    """This class implements `docker container rm` command"""

    name = "container rm"
    require = []

    def __init__(self):
        Command.__init__(self)
        self.settings[self.name] = None

    def eval_command(self, args):
        try:
            containers = args["containers"]
            clear = args["clear"]
            del args["containers"]
            del args["clear"]
            Ids = []
            if clear:
                cli = Tsaotun()
                cli.send('ps -a --format {{Id}}')
                ress = cli.recv()
                if ress:
                    ress = ress.split('\n')
                    ress = [res[0:4] for res in ress]
                    for Id in ress:
                        Ids.append(Id)
                        args['container'] = Id
                        self.client.remove_container(**args)
            else:
                for Id in containers:
                    Ids.append(Id)
                    args['container'] = Id
                    self.client.remove_container(**args)
            self.settings[self.name] = '\n'.join(Ids)

        except APIError as e:
            raise e

    def final(self):
        return self.settings[self.name]

1.5 Licence

Apache License v2.0: LICENSE.

1.6 Author

Boik Su (@qazbnm456) created Tsaotun.

Metadata

Release files for tsaotun 0.9.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tsaotun 0.9.4
File Size Uploaded
tsaotun-0.9.4.tar.gz 54.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tsaotun 0.9.4
File Interpreter ABI Platform
tsaotun-0.9.4-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 123.9 kB

Release files / tsaotun-0.9.4.tar.gz

Download URL tsaotun-0.9.4.tar.gz
Size 54.2 kB
Tags Source
SHA-256 checksum
How to use checksums
43dab51e2e2ec9a8593655ae0bfeb6b82f9a0f7ce2bade226dbb95b3b56ce52e
BLAKE2b-256 checksum
How to use checksums
30a25f85137c990c875103da223418c1e23de35fd211f1bf080079e0bc4d8480
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / tsaotun-0.9.4-py2.py3-none-any.whl

Download URL tsaotun-0.9.4-py2.py3-none-any.whl
Size 69.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
1055c9eed53f8a9006e1d9c88571051f27bc1d72f149b7e3864f3d045d3ca86b
BLAKE2b-256 checksum
How to use checksums
276e0ad6dc5fa121e0794eee8a9d0d0011bd7f5e95749ed19285e1b2d4775366
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.9.4 This release

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page