cabrita.abc

Cabrita base package.

Contains abstract classes and general purpose code.

cabrita.abc.base

Base Module.

ConfigTemplate

Base class for the config template object. This template will process the YAML files. Subclasses are: Config and Compose classes

InspectTemplate

Base class for the Inspector template object. This template will process docker and git status for compose services Subclasses are: DockerInspect and GitInspect

class cabrita.abc.base.ConfigTemplate → None

Bases: abc.ABC

Abstract class for processing yaml files.

add_path(path: str, base_path: str = '/home/docs/checkouts/readthedocs.org/user_builds/cabrita/checkouts/stable/source') → None

Add new path for list for each yaml file.

base_path

Return base path for yaml file.

is_valid

Check if yaml is valid.

load_file_data() → None

Load data from yaml file.

First file will be the main file. Every other file will override data, on reversed order list:

Example:
  1. docker-compose.yml (main file)
  2. docker-compose-dev.yml (override main)
  3. docker-compose-pycharm.yml (override dev)
version

Return version value inside yaml file.

class cabrita.abc.base.InspectTemplate(compose, interval: int) → None

Bases: abc.ABC

Abstract class for compose service inspectors.

can_update

Check if inspector can inspect again.

inspect(service: str) → None

Run inspect code.

status(service)

Return service status.

If can update, start fetching new data calling self.inspect method.

Parameters:service – docker service name
Returns:dict or dashing obj. If not fetch data yet send default widget.

cabrita.abc.utils

Base utils module.

cabrita.abc.utils.format_color(text: str, style: str, theme: str = None) → str

Format string with color using formatStr method.

cabrita.abc.utils.get_path(path: str, base_path: str) → str

Return real path from string.

Converts environment variables to path Converts relative path to full path

cabrita.abc.utils.get_sentry_client() → Union[raven.base.Client, NoneType]

Return synchronous Sentry client if DSN is available.

cabrita.abc.utils.run_command(task, get_stdout=False)

Run subprocess command.

The function will attempt to run the task informed and return a boolean for the exit code or the captured std from console.

Arg:task (string): the command to run
Arg:get_stdout (bool, optional): capture stdout
Arg:run_stdout (bool, optional): capture and run stdout
Returns:bool or string