Conduct API

Build steps

Base classes

class conduct.buildsteps.base.BuildStep(name, paramValues, chain=None)[source]

Parameters

condition (str)

Precondition for this build step. Step will be skipped if not fulfilled. Default value: ''.

description (str)

Build step description. Default value: 'Undescribed'.

loglevel (one of ['debug', 'info', 'warning', 'error'])

Log level. Default value: 'info'.

retries (int)

Number of retries to execute the build step. Default value: 0.

class conduct.buildsteps.base.BuildStepMeta[source]

Bases: type

Meta class for merging parameters and outparameters within the inheritance tree.

Debian specific build steps

class conduct.buildsteps.deb.Debootstrap(name, paramValues, chain=None)[source]

Bases: BuildStep

This build step bootstraps a basic debian system to the given directory.

Parameters

arch (str, mandatory in setup)

Desired architecture.

destdir (str, mandatory in setup)

Destination directory.

distribution (str, mandatory in setup)

Desired distribution.

includes (a list of str)

Packages to include. Default value: [].

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.deb.InstallDebPkg(name, paramValues, chain=None)[source]

Bases: BuildStep

Parameters

chrootdir (str)

Chroot directory (if desired). Default value: ''.

depsonly (bool)

Install dependencies only. Default value: False.

pkg (str, mandatory in setup)

Package to install.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.deb.PBuilderExecCmds(name, paramValues, chain=None)[source]

Bases: BuildStep

Execute commands inside a pbuilder jail.

Parameters

cmds (a list of str, mandatory in setup)

List of commands to execute.

config (str)

Pbuilder config file (pbuilderrc). Default value: '/etc/pbuilderrc'.

save (bool)

Save jail after execution. Default value: False.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.deb.Pdebuild(name, paramValues, chain=None)[source]

Bases: BuildStep

Build debian package via pdebuild.

Parameters

config (str)

Pbuilder config file (pbuilderrc). Default value: '/etc/pbuilderrc'.

sourcedir (str, mandatory in setup)

Source directory.

Parameters inherited from the base classes: condition, description, loglevel, retries

Device file build steps

class conduct.buildsteps.dev.DevMapper(name, paramValues, chain=None)[source]

Bases: BuildStep

This build step uses kpartx (devmapper) to map the partitions of the given device to own device files.

Parameters

dev (str, mandatory in setup)

Path to the device file.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.dev.Partitioning(name, paramValues, chain=None)[source]

Bases: BuildStep

Parameters

dev (str, mandatory in setup)

Path to the device file.

partitions (a list of Referencer or int, mandatory in setup)

List of partition sizes (in MB).

Parameters inherited from the base classes: condition, description, loglevel, retries

File system build steps

class conduct.buildsteps.fs.CopyPath(name, paramValues, chain=None)[source]

Bases: BuildStep

This build step copies a path to a given destination path. Shell wildcards are supported!

Parameters

destination (str, mandatory in setup)

Destination path.

source (str, mandatory in setup)

Source path.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.fs.CreateFileSystem(name, paramValues, chain=None)[source]

Bases: BuildStep

This build step creates the desired file system on the given device. Used tool: mkfs

Parameters

dev (str, mandatory in setup)

Path to the device file.

fstype (one of 'bfs', 'cramfs', 'ext2', 'ext3', 'ext4', 'fat', 'ntfs', 'vfat', mandatory in setup)

Desired file system.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.fs.MakeDirs(name, paramValues, chain=None)[source]

Bases: BuildStep

This build step create the desired directories.

Parameters

dirs (a list of str, mandatory in setup)

List of directories.

removeoncleanup (bool)

Remove the directories on clenup. Default value: True.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.fs.Mount(name, paramValues, chain=None)[source]

Bases: BuildStep

This build step mounts given device to given mount point.

Parameters

dev (str, mandatory in setup)

Path to the device file.

mountpoint (str, mandatory in setup)

Path to the mount point.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.fs.MovePath(name, paramValues, chain=None)[source]

Bases: BuildStep

This build step moves/renames a path to a given destination path. Shell wildcards are supported!

Parameters

destination (str, mandatory in setup)

Destination path.

source (str, mandatory in setup)

Source path.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.fs.RmPath(name, paramValues, chain=None)[source]

Bases: BuildStep

Parameters

path (str, mandatory in setup)

Path to remove.

recursive (bool)

Remove recursive. Default value: True.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.fs.TmpDir(name, paramValues, chain=None)[source]

Bases: BuildStep

Parameters

parentdir (str)

Path to parent directory. Default value: '/tmp'.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.fs.WriteFile(name, paramValues, chain=None)[source]

Bases: BuildStep

Parameters

append (bool)

Append to the file (if existing). Default value: False.

content (str, mandatory in setup)

Content wo write.

path (str, mandatory in setup)

Path to target file.

Parameters inherited from the base classes: condition, description, loglevel, retries

Generic build steps

class conduct.buildsteps.generic.Calculation(name, paramValues, chain=None)[source]

Bases: BuildStep

Build step to do some calculation.

Parameters

formula (str, mandatory in setup)

Formula to calculate.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.generic.Config(name, paramValues, chain=None)[source]

Bases: BuildStep

Build step to read given configuration file.

Parameters

format (one of 'ini', 'py', 'auto')

Format of config file. Default value: 'auto'.

path (str)

Path to the configuration file. Default value: '.'.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.generic.Map(name, paramValues, chain=None)[source]

Bases: BuildStep

Maps a value to another one. Supports regex matching and priority matching by order.

Parameters

input (str, mandatory in setup)

Input to map.

mapping (OrderedDict, mandatory in setup)

Mapping ordered dict.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.generic.TriggerCleanup(name, paramValues, chain=None)[source]

Bases: BuildStep

Build step that triggers the cleanup of another step.

Parameters

step (str, mandatory in setup)

Step to clean up.

Parameters inherited from the base classes: condition, description, loglevel, retries

System call build steps

class conduct.buildsteps.syscall.ChrootedSystemCall(name, paramValues, chain=None)[source]

Bases: BuildStep

Build step to execute given shell command in a chroot environment.

Parameters

chrootdir (str)

Chroot directory. Default value: '.'.

command (str, mandatory in setup)

command to execute.

Parameters inherited from the base classes: condition, description, loglevel, retries

class conduct.buildsteps.syscall.SystemCall(name, paramValues, chain=None)[source]

Bases: BuildStep

Build step to execute given shell command.

Parameters

command (str, mandatory in setup)

command to execute.

workingdir (str)

Working directory for command execution. Default value: '.'.

Parameters inherited from the base classes: condition, description, loglevel, retries

Build chain

class conduct.chain.Chain(name, paramValues)[source]
build()[source]
parameters

Colorizing stuff

Console coloring handlers.

conduct.colors.colorcode(name)[source]
conduct.colors.colorize(name, text)[source]
conduct.colors.nocolor()[source]

Conduct configuration access

Custom logging

class conduct.loggers.ColoredConsoleHandler[source]

Bases: StreamHandler

A handler class that writes colorized records to standard output.

emit(record)[source]
class conduct.loggers.ConductLogger(*args, **kwargs)[source]

Bases: Logger

getChild(suffix, ownDir=False)[source]
maxLogNameLength = 0
class conduct.loggers.ConsoleFormatter(fmt=None, datefmt=None, colorize=None)[source]

Bases: Formatter

A lightweight formatter for the interactive console, with optional colored output.

format(record)[source]
formatException(exc_info)[source]
formatTime(record, datefmt=None)[source]
class conduct.loggers.LogfileFormatter(fmt=None, datefmt=None)[source]

Bases: Formatter

The standard Formatter does not support milliseconds with an explicit datestamp format. It also doesn’t show the full traceback for exceptions.

extended_traceback = True
formatException(ei)[source]
formatTime(record, datefmt=None)[source]
class conduct.loggers.LogfileHandler(directory, filenameprefix, dayfmt='%Y-%m-%d')[source]

Bases: StreamHandler

Logs to log files with a date stamp appended, and rollover on midnight.

close()[source]
doRollover()[source]
emit(record)[source]
enable(enabled)[source]
filter(record)[source]
getChild(name)[source]
class conduct.loggers.StreamHandler(stream=None)[source]

Bases: Handler

Reimplemented from logging: remove cruft, remove bare excepts.

emit(record)[source]
flush()[source]
conduct.loggers.format_extended_frame(frame)[source]
conduct.loggers.format_extended_traceback(etype, value, tb)[source]

Build step and chain parameters

class conduct.param.Dataholder(modelDict)[source]
class conduct.param.Parameter(type=<type 'str'>, description='Undescribed', default=None)[source]

Some kind of parameter.

No default means mandatory.

validate(value)[source]
class conduct.param.Referencer(fmt)[source]
evaluate(chain, valType=<type 'str'>)[source]
conduct.param.absolute_path(val='')[source]

an absolute file path

conduct.param.anytype(val=None)[source]

any value

conduct.param.callableobj(obj)[source]
conduct.param.convdoc(conv)[source]
class conduct.param.dictof(keyconv, valconv)[source]
conduct.param.expanded_path(val='')[source]
class conduct.param.floatrange(fr, to=None)[source]
conduct.param.host(val='')[source]

a host[:port] value

class conduct.param.intrange(fr, to)[source]
conduct.param.ipv4(val='0.0.0.0')[source]

a IP v4 address

conduct.param.limits(val=None)[source]

a tuple of lower and upper limit

class conduct.param.listof(conv)[source]
conduct.param.mailaddress(val=None)[source]

a valid mail address

class conduct.param.none_or(conv)[source]
class conduct.param.nonemptylistof(conv)[source]
conduct.param.nonemptystring(s)[source]

a non-empty string

class conduct.param.oneof(*vals)[source]
class conduct.param.oneofdict(vals)[source]
class conduct.param.referencer_or(conv)[source]
conduct.param.relative_path(val='')[source]

a relative path, may not use ../../.. tricks

conduct.param.subdir(val='')[source]

a relative subdir (a string NOT containing any path.sep)

class conduct.param.tupleof(*types)[source]

Utility stuff

class conduct.util.AttrStringifier[source]
class conduct.util.OrderedAttrDict(*args, **kwargs)[source]

Bases: OrderedDict

conduct.util.analyzeSystem()[source]
conduct.util.chainNameToPath(name)[source]
conduct.util.chainPathToName(path)[source]
conduct.util.chrootedSystemCall(chrootDir, cmd, sh=True, mountPseudoFs=True, log=None)[source]
conduct.util.ensureDirectory(dirpath)[source]
conduct.util.getDefaultConfigPath()[source]
conduct.util.importFromPath(import_name, prefixes=(), log=None)[source]

Imports an object based on a string.

The should be formatted like: imp.path.to.mod.objname

conduct.util.loadChainConfig(chainName)[source]
conduct.util.loadChainDefinition(chainName, app=None)[source]
conduct.util.loadPyFile(path, ns=None)[source]
conduct.util.logMultipleLines(strOrList, logFunc=None)[source]
conduct.util.mount(dev, mountpoint, flags='', log=None)[source]
conduct.util.systemCall(cmd, sh=True, log=None)[source]
conduct.util.umount(mountpoint, flags='', log=None)[source]