mini_buildd.call module

mini_buildd.call.taint_env(taint)
class mini_buildd.call.Call(call, run_as_root=False, **kwargs)

Bases: object

Wrapper around python subprocess

When supplying stdout or stderr, provide raw and ‘seekable’ file-like object; i.e., use “w+” and standard python open like:

mystdout = open(myoutputfile, "w+")
>>> Call(["echo", "-n", "hallo"]).check().stdout
'hallo'
>>> Call(["ls", "__no_such_file__"]).check()  
Traceback (most recent call last):
...
util.HTTPBadRequest: Internal call failed (HTTP 400 Bad request syntax or unsupported method)
>>> Call(["printf stdin; printf stderr >&2"], stderr=subprocess.STDOUT, shell=True).stdout
'stdinstderr'
property stdout

Stdout value (empty string if none)

property stderr

Stderr value (empty string if none)

log(level=None)

Log calls output to mini-buildd’s logging for debugging

Per default, this logs to level error on failure, debug on success.

success()
check(public_message='Internal call failed')

Raise on unsuccessful (returncode != 0) call

mini_buildd.call.call_sequence(calls, run_as_root=False, rollback_only=False, **kwargs)

Run sequences of calls with rollback support

>>> call_sequence([(["echo", "-n", "cmd0"], ["echo", "-n", "rollback cmd0"])])
>>> call_sequence([(["echo", "cmd0"], ["echo", "rollback cmd0"])], rollback_only=True)
mini_buildd.call.call_with_retry(call, retry_max_tries=5, retry_sleep=1, retry_failed_cleanup=None, **kwargs)

Run call repeatedly until it succeeds (retval 0)

In case retry_max_tries is reached, the error from the last try is raised.

>>> call_with_retry(["/bin/true"])
>>> call_with_retry(["/bin/false"])  
Traceback (most recent call last):
  ...
util.HTTPBadRequest: Internal call failed (HTTP 400 Bad request syntax or unsupported method)