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
orstderr
, provide raw and ‘seekable’ file-like object; i.e., use “w+” and standard pythonopen
like:mystdout = open(myoutputfile, "w+")
>>> Call(["echo", "-n", "hallo"]).check().stdout 'hallo' >>> Call(["ls", "__no_such_file__"]).check() Traceback (most recent call last): ... Exception: Call failed with returncode 2: 'ls __no_such_file__ ' >>> Call(["printf stdin; printf stderr >&2"], stderr=subprocess.STDOUT, shell=True).stdout 'stdinstderr'
-
stdout
¶ Stdout value (empty string if none).
-
stderr
¶ Stderr value (empty string if none).
-
log
()¶ Log calls output to mini-buildd’s logging for debugging.
On error, this logs with level
warning
. On sucesss, this logs with leveldebug
.
-
check
()¶ 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): ... Exception: Call failed with returncode 1: '/bin/false '