kentauros package

Subpackages

Submodules

kentauros.bootstrap module

This module contains functions that cover the bare necessity of setting up the directories kentauros expects to exist. This happens after CLI arguments and environment variables have been parsed to determine which directories those should be.

kentauros.bootstrap.LOG_PREFIX = 'ktr/bootstrap'

This string specifies the prefix for log and error messages printed to stdout or stderr from inside this subpackage.

kentauros.bootstrap.ktr_bootstrap() → bool[source]

This function has to be called before any other actions are attempted on packages. It ensures that the required directory structure is present. If it fails, kentauros execution will be aborted.

Returns:bool – success (or not)
kentauros.bootstrap.ktr_mkdirp(path: str) → bool[source]

This function checks for directory existence and the ability to write to it. If the directory does not exist, it will be created.

Parameters:path (str) – path of directory to check and create
Returns:bool – success (or not)

kentauros.conntest module

This module contains a simple function which is used for basic connectivity checks before actions that require internet access / access to a specific URL.

kentauros.conntest.is_connected(host_url: str) → bool[source]

This function tries to create a connection to the hostname specified by the URL argument. If any error occurs during connecting, False is returned.

Parameters:host_url (str) – URL of the host connectivity will checked to
Returns:boolTrue if connection setup successful, False if not
kentauros.conntest.trial(address: str) → bool[source]

This helper function attempts to connect to a remote host exactly once.

Parameters:address (str) – URL string
Returns:boolTrue if successful, False if not

kentauros.definitions module

This module contains all definitions of types and global variables that are used by nearly every other module / subpackage.

It includes these globally used variables:

  • KTR_SYSTEM_DATADIR: directory where kentauros data is installed to resides when installed
  • KTR_VERSION: this version string is used when installing and packaging kentauros

The following Enums are defined here:

  • KtrConfType: types of kentauros configuration source
  • ActionType: types of actions that can be executed
  • BuilderType: types of supported binary package builders
  • ConstructorType: types of supported source package constructors
  • SourceType: types of supported package sources
  • UploaderType: types of supported package upload modules
class kentauros.definitions.ActionType[source]

Bases: enum.Enum

This Enum defines the different types of actions that are supported by kentauros. This includes a default NONE type.

BUILD = 22
CHAIN = 40
CLEAN = 30
CONSTRUCT = 21
IMPORT = 10
NONE = 0
PREPARE = 20
STATUS = 11
UPLOAD = 23
VERIFY = 12
class kentauros.definitions.BuilderType[source]

Bases: enum.Enum

This Enum defines the different types of binary package builders that are supported by kentauros. It also includes a default NONE type.

MOCK = 1
NONE = 0
class kentauros.definitions.ConstructorType[source]

Bases: enum.Enum

This Enum defines the different types of source package builders that are supported by kentauros. It also includes a default NONE type.

NONE = 0
SRPM = 1
kentauros.definitions.KTR_SYSTEM_DATADIR = '/usr/share/kentauros/'

This string represents the absolute path which kentauros data files are copied to at installation and where they are expected to be when running ktr.

kentauros.definitions.KTR_VERSION = '1.0.8'

This string represents the version string used by setup.py at install time and make-srpm.sh when building an srpm package. The version in kentauros.spec has to be set manually yet.

class kentauros.definitions.PkgModuleType[source]

Bases: enum.Enum

This Enum defines the types of package submodules there can be.

BUILDER = 3
CONSTRUCTOR = 2
SOURCE = 1
UPLOADER = 4
class kentauros.definitions.SourceType[source]

Bases: enum.Enum

This Enum defines the different types of package source sources that are supported by kentauros. It also includes a default NONE type.

BZR = 21
GIT = 20
LOCAL = 30
NONE = 0
URL = 10
class kentauros.definitions.UploaderType[source]

Bases: enum.Enum

This Enum defines the different types of (source) package uploader modules that are supported by kentauros. It also includes a default NONE type.

COPR = 1
NONE = 0

kentauros.instance module

This sub-module contains the Kentauros class, which holds configuration values parsed from CLI arguments, environment variables and configuration files. The implementation makes sure that command line arguments, environment variables and configuration files are parsed only once per program run. Additionally, this subpackage holds logging and error printing functions.

class kentauros.instance.Kentauros[source]

Bases: object

This class stores settings and variables that must be the same during the execution of code from the “kentauros” package. This is accomplished by storing the critical data in a class variable, which is initialised only once per execution.

add_package(conf_name: str, package)[source]

This method adds a package to the list of packages known to the kentauros instance.

Parameters:
  • conf_name – package configuration name
  • package – Package object
Returns:

bool – successful addition to package list

cli = None
conf = None
debug = None
get_basedir() → str[source]

This method tries to parse the kentauros configuration file for a specified base directory. If it is not specified, it returns the current directory as a fallback value.

Returns:str – kentauros base directory
get_confdir() → str[source]

Returns the string “configs” appended to the base directory.

get_datadir() → str[source]

Returns the string “sources” appended to the base directory.

get_expodir() → str[source]

Returns the string “exports” appended to the base directory.

get_package(conf_name: str)[source]

This method gets a package from the list of packages known to the kentauros instance.

Parameters:conf_name – package configuration name
Returns:Package – package object
get_package_names()[source]

This method gets the list of known package configuration names.

Returns:list – list of package configurations active in this instance
get_packdir() → str[source]

Returns the string “packages” appended to the base directory.

get_specdir() → str[source]

Returns the string “specs” appended to the base directory.

initialised = False
packages = None
state_delete(conf_name: str) → int[source]

This method deletes the entries for the given package from the database and returns its ID.

Parameters:conf_name (str) – package configuration name
Returns:int – ID of the removed entry
state_read(conf_name: str) → dict[source]

This method reads the entries for the given package from the database and returns them as an ordered dictionary.

Parameters:conf_name (str) – package configuration name
Returns:dict – result of the query
state_write(conf_name: str, entries: dict) → int[source]

This method inserts or updates a package’s entry in the state database with the dictionary entries given.

Parameters:
  • package (str) – package configuration name
  • entries (dict) – dict containing the key-value pairs to insert or update in the db
Returns:

int – ID of the package in the database

verby = None
workdir = '/home/docs/checkouts/readthedocs.org/user_builds/kentauros/checkouts/stable/docs/source'
kentauros.instance.LOG_PREFIX = 'ktr/instance'

This string specifies the prefix for log and error messages printed to stdout or stderr from inside this subpackage.

kentauros.logger module

This sub-module contains the KtrLogger class, which provides methods for logging messages to file or standard outputs.

class kentauros.logger.KtrLogger(log_prefix: str = None)[source]

Bases: object

This class provides methods for printing messages to standard outputs.

Parameters:log_prefix – specifies a custom prefix for log messages
Variables:log_prefix – stores a custom prefix for log messages
dbg(msg: str, prefix: str = None)[source]

This method prints messages with a “DEBUG: ” prefix to stdout, but only if the KTR_DEBUG environment variable has been set or the –debug or -d flag has been supplied at the command line.

Parameters:msg (str) – debug message to be printed
err(msg: str, prefix: str = None)[source]

This method prints messages with an “ERROR: ” prefix to standard error output, regardless of environment variables and CLI settings supplied.

Parameters:msg (str) – error message to be printed
log(msg: str, pri: int = 2, prefix: str = None, outfile=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, sep: str = ':')[source]

This method prints messages to standard output, depending on the priority argument and the verbosity level determined from environment variables and CLI switches.

Invocation with

  • pri=2 (which is the default) will always print the attached message
  • pri=1 will print messages when verbosity is set to 1
  • pri=0 will print messages when verbosity is set to 0 or when debugging is enabled
Parameters:
  • msg (str) – message that will be printed
  • pri (int) – message priority (0-2, where 0 is lowest and 2 is highest)
log_command(cmd_list: list, pri: int = 2, prefix: str = None)[source]

This method prints commands that are then executed by use of the subprocess.call() or subprocess.check_output() functions. Its priority behaviour is the same as the Kentauros.log() function’s.

Parameters:
  • cmd_list (list) – list of strings, as passed to subprocess functions
  • pri (int) – message priority (0-2, where 0 is lowest and 2 is highest)
  • prefix (str) – custom module-wide prefix string
log_list(header: str, lst: list, pri: int = 2, prefix: str = None)[source]

This method prints lists, with one element on each line. Its priority behaviour is the same as the Kentauros.log() function’s.

Parameters:
  • header (str) – header for the list
  • lst (list) – list of objects that are parse-able to str()s by python
  • pri (int) – message priority (0-2, where 0 is lowest and 2 is highest)
  • prefix (str) – custom module-wide prefix string
kentauros.logger.LOG_PREFIX = 'ktr/logger'

This string specifies the prefix for log and error messages printed to stdout or stderr from inside this subpackage.

kentauros.logger.print_flush(*args, **kwargs)[source]

This function serves as a wrapper around the built-in print function. Calling it instead of the standard print ensures that output buffers are flushed after every call.

kentauros.package module

This sub-package contains the Package class, which holds package configuration parsed from the corresponding package.conf file. After parsing the package configuration, package sub-modules are added according to configuration.

kentauros.package.LOG_PREFIX = 'ktr/package'

This string specifies the prefix for log and error messages printed to stdout or stderr from inside this subpackage.

class kentauros.package.Package(conf_name: str)[source]

Bases: object

This class envelops all things necessary to perform actions on a specific “package” of software.

Parameters:

conf_name (str) – name of the configuration file, without the “.conf” suffix

Variables:
  • file (str) – configuration file path
  • conf (ConfigParser) – parser for package.conf file
Raises:

PackageError – error if package.conf file is invalid

get_conf_name() → str[source]
Returns:str – package configuration name
get_module(module_type: str)[source]

This method gets a specific package module from the module dictionary.

Parameters:module_type (str) – module type string (abstract class name, lower-case)
Returns:PkgModule – corresponding package module, if it is found
get_modules()[source]

This method gets all a package’s modules.

Returns:list – package module list
get_name() → str[source]
Returns:str – package name
get_version() → str[source]
Returns:str – package version string
replace_vars(input_str: str) → str[source]

This method replaces variables in configuration file values with the appropriate values set elsewhere. For example, this can be used to specify the name and version inside a URL.

Parameters:input_str (str) – string where variables should be replaced
Returns:str – string where variables have been replaced
status() → dict[source]

This method returns statistics describing this Package object and its associated source.

Returns:dict – key-value pairs (property: value)
status_string() → str[source]

This method returns a string containing statistics describing this Package object and its associated source.

Returns:str – package information
verify() → bool[source]

This method verifies that the absolute minimum for proceeding with package initialisation is set. This also ensures the validity of some entries.

Returns:boolTrue if configuration is minimally valid, False if entries are missing
exception kentauros.package.PackageError(value: str = '')[source]

Bases: Exception

This custom exception will be raised when errors occur during parsing of a package .conf file.

Parameters:value (str) – informational string accompanying the exception

kentauros.run module

This module contains the run() function that is called as entry point from the ktr script.

kentauros.run.LOG_PREFIX = 'ktr'

This string specifies the prefix for log and error messages printed to stdout or stderr from inside this subpackage.

kentauros.run.do_import_action(name: str)[source]

This function executes the Import action for the given package configuration.

Parameters:name (str) – package configuration name
kentauros.run.do_process_packages() -> (<class 'list'>, <class 'list'>)[source]

This function processes all packages and executes the specified action on them.

Returns:list, list – list of successful package actions, list of unsuccessful package actions
kentauros.run.do_verify_action(name: str) → bool[source]

This function executes the Verify action for the given package configuration.

Parameters:name (str) – package configuration name
kentauros.run.get_packages() → list[source]

This function returns the set of all packages that are specified as command line arguments or all packages that have configuration files present, depending on whether the –all CLI flag has been set.

Returns:list – list of package configuration names
kentauros.run.get_packages_all() → list[source]

This function parses the content of the package configuration files directory and returns the package configuration names.

Returns:list – list of strings of package configuration names
kentauros.run.get_packages_cli() → list[source]

This function parses the package configuration names supplied via CLI arguments, removes any that do not match with a present configuration file in the respective directory, and returns the checked list.

Returns:list – list of strings of package configuration names
kentauros.run.init_package_objects(packages: list)[source]

This function parses the list of package configuration names and initialises the Package objects. If no errors occur during initialisation, the Package instance is added to the kentauros instance’s list of packages.

kentauros.run.print_no_package_error()[source]

This function prints an error and helpful information if no action is specified.

kentauros.run.print_package_header(name: str)[source]

This function prints a small banner to indicate which package actions are executed for next.

Parameters:name (str) – package configuration name
kentauros.run.print_parameters()[source]

This function prints the kentauros program parameters.

kentauros.run.run() → int[source]

This function is corresponding to (one of) the “main” function of the kentauros package and is the entry point used by the ktr.py script from git and the script installed at installation.

Module contents

kentauros is an automated build system.

at the moment, the following actions are supported:

  • getting source code from:
    • local tarball
    • tarball at URL
    • git repository
    • bzr repository
  • building source packages:
    • RPM format (.spec necessary, but in theory an unmodified spec should work)
  • building binary packages:
    • RPM format (mock necessary)
  • uploading source packages to cloud build service:
    • copr for fedora, RHEL/EPEL and Mageia packages