quixote.inspection.exec package
Module contents
- class quixote.inspection.exec.CompletedProcess(completed_subprocess: subprocess.CompletedProcess)[source]
Class representing a completed process, and providing access to its arguments, its output, and its return code
- check_decode(message: str, *, error_kind: Type = <class 'quixote.inspection._errors.KOError'>, encoding: str = 'utf-8')[source]
Check whether the output of the process can be decoded according to a given encoding
- Parameters
message – message in case of failure to explain the reason of said failure
error_kind – exception to raise if the check failed
encoding – encoding to use to decode the data
- property stdout: str
- property stderr: str
- check(message: str, *, error_kind: Type = <class 'quixote.inspection._errors.KOError'>, allowed_status: Union[int, List[int]] = 0, stdout: bool = True, stderr: bool = True, exit_code: bool = True) quixote.inspection.exec.CompletedProcess [source]
Check whether the execution of the process failed
- Parameters
message – message in case of failure to explain the reason of said failure
allowed_status – status or list of statuses that are considered successful
error_kind – exception to raise if the check failed
stdout – if True add the output of the process to the assertion message
stderr – if True add the error output of the process to the assertion message
exit_code – if True add the exit_code of the process to the assertion message
- expect(message: str, *, allowed_status: Union[int, List[int]] = 0, stdout: bool = True, stderr: bool = True, exit_code: bool = True) quixote.inspection.exec.CompletedProcess [source]
Check whether the execution of the process failed
- Parameters
message – message in case of failure to explain the reason of said failure
allowed_status – status or list of statuses that are considered successful
stdout – if True add the output of the process to the requirement message
stderr – if True add the error output of the process to the requirement message
exit_code – if True add the exit_code of the process to the requirement message
- quixote.inspection.exec.command(cmd: Union[str, List[str]], *, timeout: Optional[int] = None, env: Optional[Mapping[str, str]] = None, as_user: Optional[str] = None) quixote.inspection.exec.CompletedProcess [source]
Run a single executable. It is not run in a shell.
- Parameters
cmd – command to be executed
timeout – the timeout in seconds. If it expires, the child process will be killed and waited for. Then TimeoutExpired exception will be raised after the child process has terminated.
env – the environment to use when running the command
as_user – the user as which the command should be executed
- Raises
quixote.inspection.TimeoutError – if timeout is not None and expires before the child process terminates
- quixote.inspection.exec.bash(cmd: str, *, timeout: Optional[int] = None, force_kill_on_timeout: bool = False, env: Optional[Mapping[str, str]] = None, as_user: Optional[str] = None) quixote.inspection.exec.CompletedProcess [source]
Run one or a sequence of commands using the Bash shell.
- Parameters
cmd – commands to be executed
timeout – the timeout in seconds. If it expires, the child process will be killed and waited for. Then TimeoutExpired exception will be raised after the child process has terminated.
force_kill_on_timeout – whether processes should be terminated or killed
env – the environment to use when running the command
as_user – the user as which the commands should be executed
- Raises
quixote.inspection.TimeoutError – if timeout is not None and expires before the child process terminates
- class quixote.inspection.exec.BackgroundProcess(proc, force_kill_on_scope_exit: bool)[source]
Class representing a process running in the background
- kill() quixote.inspection.exec.CompletedProcess [source]
Kill the process, returning a CompletedProcess
- quixote.inspection.exec.background_bash(cmd: str, *, force_kill_on_scope_exit: bool = False, env: Optional[Mapping[str, str]] = None, as_user: Optional[str] = None) quixote.inspection.exec.BackgroundProcess [source]
Run one or a sequence of commands using the Bash shell, in the background
- Parameters
cmd – commands to be executed
force_kill_on_scope_exit – whether processes should be terminated or killed
env – the environment to use when running the command
as_user – the user as which the commands should be executed
with background_bash("./my_http_server"): # Server is running in the background, we can make a request bash("curl http://localhost:8080") # Server is stopped when we reach the end of the `with` block
- quixote.inspection.exec.java(class_name: str, args: List[str] = [], timeout: Optional[int] = None, options: Optional[List[str]] = None, env: Optional[Mapping[str, str]] = None) quixote.inspection.exec.CompletedProcess [source]
Launch a java class
- Parameters
class_name – path of the Java class file to launch
args – list of arguments to pass to the launched class
timeout – time to wait before terminating the process
options – list of shell options to be passed to java (see java man page for more info)
env – environment to run the java command (by default use the current shell environment)
- Raises
quixote.inspection.TimeoutError – if timeout is not None and expires before the child process terminates
- quixote.inspection.exec.javajar(jar_path: str, args: List[str] = [], timeout: Optional[int] = None, options: Optional[List[str]] = None, env: Optional[Mapping[str, str]] = None) quixote.inspection.exec.CompletedProcess [source]
Launch a java archive
- Parameters
jar_path – path of the Java archive to launch
args – list of arguments to pass to the launched archive
timeout – time to wait before terminating the process
options – list of shell options to be passed to java (see java man page for more info)
env – environment to run the java command (by default use the current shell environnment)
- Raises
quixote.inspection.TimeoutError – if timeout is not None and expires before the child process terminates