buildtest.utils.shell

Module Contents

Classes

Shell

The Shell initializer takes an input shell and shell options and split

class buildtest.utils.shell.Shell(shell='bash')[source]

The Shell initializer takes an input shell and shell options and split string by shell name and options.

Parameters

shell (str) – Specify shell program and any options passed to shell. Defaults to bash

valid_shells = ['bash', 'sh', 'zsh', 'csh', 'tcsh', '/bin/bash', '/bin/csh', '/bin/sh', '/bin/tcsh',...
property opts(self)

retrieve the shell opts that are set on init, and updated with setter

property path(self)

This method returns the full path to shell program using shutil.which() If shell program is not found we raise an exception. The shebang is is updated assuming path is valid which is just adding character ‘#!’ in front of path. The return is full path to shell program. This method automatically updates the shell path when there is a change in attribute self.name

>>> shell = Shell("bash")
>>> shell.path
'/usr/bin/bash'
>>> shell.name="sh"
>>> shell.path
'/usr/bin/sh'
__str__(self)[source]

Return str(self).

__repr__(self)[source]

Return repr(self).

get(self)[source]

Return shell attributes as a dictionary