labgrid.driver package¶
Subpackages¶
Submodules¶
labgrid.driver.bareboxdriver module¶
-
class
labgrid.driver.bareboxdriver.
BareboxDriver
(target, prompt='', autoboot='stop autoboot', interrupt='n')[source]¶ Bases:
labgrid.driver.commandmixin.CommandMixin
,labgrid.driver.common.Driver
,labgrid.protocol.commandprotocol.CommandProtocol
,labgrid.protocol.linuxbootprotocol.LinuxBootProtocol
- BareboxDriver - Driver to control barebox via the console.
- BareboxDriver binds on top of a ConsoleProtocol.
Parameters: prompt (str) – The default Barebox Prompt -
bindings
= {'console': <class 'labgrid.protocol.consoleprotocol.ConsoleProtocol'>}¶
-
prompt
= Attribute(name='prompt', default='', validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
autoboot
= Attribute(name='autoboot', default='stop autoboot', validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
interrupt
= Attribute(name='interrupt', default='\n', validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
on_activate
()[source]¶ Activate the BareboxDriver
This function checks for a prompt and awaits it if not already active
-
run
(cmd: str, *, step)[source]¶ Runs the specified command on the shell and returns the output.
Parameters: cmd (str) – command to run on the shell Returns: if successful, None otherwise Return type: Tuple[List[str],List[str], int]
-
run_check
(cmd: str)[source]¶ Runs the specified command on the shell and returns the output if successful, raises ExecutionError otherwise.
Parameters: cmd (str) – command to run on the shell Returns: stdout of the executed command Return type: List[str]
-
get_status
()[source]¶ Retrieve status of the BareboxDriver 0 means inactive, 1 means active.
Returns: status of the driver Return type: int
labgrid.driver.commandmixin module¶
labgrid.driver.common module¶
-
class
labgrid.driver.common.
Driver
(target)[source]¶ Bases:
labgrid.binding.BindingMixin
Represents a driver which is used externally or by other drivers. It implements functionality based on directly accessing the Resource or by building on top of other Drivers.
Life cycle: - create - bind (n times) - activate - usage - deactivate
labgrid.driver.consoleexpectmixin module¶
labgrid.driver.exception module¶
labgrid.driver.externalconsoledriver module¶
-
class
labgrid.driver.externalconsoledriver.
ExternalConsoleDriver
(target, cmd, txdelay=0.0)[source]¶ Bases:
labgrid.driver.consoleexpectmixin.ConsoleExpectMixin
,labgrid.driver.common.Driver
,labgrid.protocol.consoleprotocol.ConsoleProtocol
Driver implementing the ConsoleProtocol interface using a subprocess
-
cmd
= Attribute(name='cmd', default=NOTHING, validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
txdelay
= Attribute(name='txdelay', default=0.0, validator=<instance_of validator for type <class 'float'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
labgrid.driver.fake module¶
-
class
labgrid.driver.fake.
FakeConsoleDriver
(target, txdelay=0.0)[source]¶ Bases:
labgrid.driver.consoleexpectmixin.ConsoleExpectMixin
,labgrid.driver.common.Driver
,labgrid.protocol.consoleprotocol.ConsoleProtocol
-
txdelay
= Attribute(name='txdelay', default=0.0, validator=<instance_of validator for type <class 'float'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
-
class
labgrid.driver.fake.
FakeCommandDriver
(target)[source]¶ Bases:
labgrid.driver.commandmixin.CommandMixin
,labgrid.driver.common.Driver
,labgrid.protocol.commandprotocol.CommandProtocol
-
class
labgrid.driver.fake.
FakeFileTransferDriver
(target)[source]¶ Bases:
labgrid.driver.common.Driver
,labgrid.protocol.filetransferprotocol.FileTransferProtocol
-
class
labgrid.driver.fake.
FakePowerDriver
(target)[source]¶ Bases:
labgrid.driver.common.Driver
,labgrid.protocol.powerprotocol.PowerProtocol
labgrid.driver.fastbootdriver module¶
-
class
labgrid.driver.fastbootdriver.
AndroidFastbootDriver
(target, image=None)[source]¶ Bases:
labgrid.driver.common.Driver
-
bindings
= {'fastboot': {<class 'labgrid.resource.udev.AndroidFastboot'>, <class 'labgrid.resource.remote.NetworkAndroidFastboot'>}}¶
-
image
= Attribute(name='image', default=None, validator=None, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
labgrid.driver.infodriver module¶
-
class
labgrid.driver.infodriver.
InfoDriver
(target)[source]¶ Bases:
labgrid.driver.common.Driver
,labgrid.protocol.infoprotocol.InfoProtocol
InfoDriver implementing the InfoProtocol on top of CommandProtocol drivers
-
bindings
= {'command': <class 'labgrid.protocol.commandprotocol.CommandProtocol'>}¶
-
labgrid.driver.onewiredriver module¶
-
class
labgrid.driver.onewiredriver.
OneWirePIODriver
(target)[source]¶ Bases:
labgrid.driver.common.Driver
,labgrid.protocol.digitaloutputprotocol.DigitalOutputProtocol
-
bindings
= {'port': <class 'labgrid.resource.onewireport.OneWirePIO'>}¶
-
labgrid.driver.openocddriver module¶
-
class
labgrid.driver.openocddriver.
OpenOCDDriver
(target, config, search=None, image=None)[source]¶ Bases:
labgrid.driver.common.Driver
,labgrid.protocol.bootstrapprotocol.BootstrapProtocol
-
bindings
= {'interface': {<class 'labgrid.resource.udev.AlteraUSBBlaster'>, <class 'labgrid.resource.remote.NetworkAlteraUSBBlaster'>}}¶
-
config
= Attribute(name='config', default=NOTHING, validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
search
= Attribute(name='search', default=None, validator=<optional validator for <instance_of validator for type <class 'str'>> or None>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
image
= Attribute(name='image', default=None, validator=<optional validator for <instance_of validator for type <class 'str'>> or None>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
labgrid.driver.powerdriver module¶
-
class
labgrid.driver.powerdriver.
ManualPowerDriver
(target, name)[source]¶ Bases:
labgrid.driver.common.Driver
,labgrid.protocol.powerprotocol.PowerProtocol
ManualPowerDriver - Driver to tell the user to control a target’s power
-
name
= Attribute(name='name', default=NOTHING, validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
-
class
labgrid.driver.powerdriver.
ExternalPowerDriver
(target, cmd_on, cmd_off, cmd_cycle=None, delay=2.0)[source]¶ Bases:
labgrid.driver.common.Driver
,labgrid.protocol.powerprotocol.PowerProtocol
ExternalPowerDriver - Driver using an external command to control a target’s power
-
cmd_on
= Attribute(name='cmd_on', default=NOTHING, validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
cmd_off
= Attribute(name='cmd_off', default=NOTHING, validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
cmd_cycle
= Attribute(name='cmd_cycle', default=None, validator=<optional validator for <instance_of validator for type <class 'str'>> or None>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
delay
= Attribute(name='delay', default=2.0, validator=<instance_of validator for type <class 'float'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
-
class
labgrid.driver.powerdriver.
NetworkPowerDriver
(target, delay=2.0)[source]¶ Bases:
labgrid.driver.common.Driver
,labgrid.protocol.powerprotocol.PowerProtocol
NetworkPowerDriver - Driver using a networked power switch to control a target’s power
-
bindings
= {'port': <class 'labgrid.resource.power.NetworkPowerPort'>}¶
-
delay
= Attribute(name='delay', default=2.0, validator=<instance_of validator for type <class 'float'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
-
class
labgrid.driver.powerdriver.
DigitalOutputPowerDriver
(target, cmd_on, cmd_off, delay=1.0)[source]¶ Bases:
labgrid.driver.common.Driver
,labgrid.protocol.powerprotocol.PowerProtocol
DigitalOutputPowerDriver - Driver using a DigitalOutput to reset the target and subprocesses to turn it on and off
-
bindings
= {'output': <class 'labgrid.protocol.digitaloutputprotocol.DigitalOutputProtocol'>}¶
-
cmd_on
= Attribute(name='cmd_on', default=NOTHING, validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
cmd_off
= Attribute(name='cmd_off', default=NOTHING, validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
delay
= Attribute(name='delay', default=1.0, validator=<instance_of validator for type <class 'float'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
labgrid.driver.serialdriver module¶
-
class
labgrid.driver.serialdriver.
SerialDriver
(target, txdelay=0.0)[source]¶ Bases:
labgrid.driver.consoleexpectmixin.ConsoleExpectMixin
,labgrid.driver.common.Driver
,labgrid.protocol.consoleprotocol.ConsoleProtocol
Driver implementing the ConsoleProtocol interface over a SerialPort connection
-
bindings
= {'port': {<class 'labgrid.resource.base.SerialPort'>, <class 'labgrid.resource.serialport.NetworkSerialPort'>}}¶
-
txdelay
= Attribute(name='txdelay', default=0.0, validator=<instance_of validator for type <class 'float'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
labgrid.driver.shelldriver module¶
The ShellDriver provides the CommandProtocol, ConsoleProtocol and InfoProtocol on top of a SerialPort.
-
class
labgrid.driver.shelldriver.
ShellDriver
(target, prompt, login_prompt, username, password='', keyfile='')[source]¶ Bases:
labgrid.driver.commandmixin.CommandMixin
,labgrid.driver.common.Driver
,labgrid.protocol.commandprotocol.CommandProtocol
ShellDriver - Driver to execute commands on the shell ShellDriver binds on top of a ConsoleProtocol.
Parameters: - prompt (regex) – The Linux Prompt to detect
- login_prompt (regex) – The Login Prompt to detect
- username (str) – username to login with
- password (str) – password to login with
- keyfile (str) – keyfile to bind mount over users authorized keys
-
bindings
= {'console': <class 'labgrid.protocol.consoleprotocol.ConsoleProtocol'>}¶
-
prompt
= Attribute(name='prompt', default=NOTHING, validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
login_prompt
= Attribute(name='login_prompt', default=NOTHING, validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
username
= Attribute(name='username', default=NOTHING, validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
password
= Attribute(name='password', default='', validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
keyfile
= Attribute(name='keyfile', default='', validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
run_check
(cmd, timeout=30)[source]¶ Runs the specified cmd on the shell and returns the output if successful, raises ExecutionError otherwise.
Arguments: cmd - cmd to run on the shell
labgrid.driver.sshdriver module¶
The SSHDriver uses SSH as a transport to implement CommandProtocol and FileTransferProtocol
-
class
labgrid.driver.sshdriver.
SSHDriver
(target, keyfile='')[source]¶ Bases:
labgrid.driver.commandmixin.CommandMixin
,labgrid.driver.common.Driver
,labgrid.protocol.commandprotocol.CommandProtocol
,labgrid.protocol.filetransferprotocol.FileTransferProtocol
SSHDriver - Driver to execute commands via SSH
-
bindings
= {'networkservice': <class 'labgrid.resource.networkservice.NetworkService'>}¶
-
keyfile
= Attribute(name='keyfile', default='', validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
run
(cmd)[source]¶ Execute cmd on the target.
This method runs the specified cmd as a command on its target. It uses the ssh shell command to run the command and parses the exitcode. cmd - command to be run on the target
returns: (stdout, stderr, returncode)
-
labgrid.driver.ubootdriver module¶
The U-Boot Module contains the UBootDriver
-
class
labgrid.driver.ubootdriver.
UBootDriver
(target, prompt='', password='', init_commands=NOTHING)[source]¶ Bases:
labgrid.driver.commandmixin.CommandMixin
,labgrid.driver.common.Driver
,labgrid.protocol.commandprotocol.CommandProtocol
,labgrid.protocol.linuxbootprotocol.LinuxBootProtocol
UBootDriver - Driver to control uboot via the console. UBootDriver binds on top of a ConsoleProtocol.
Parameters: - prompt (str) – The default UBoot Prompt
- password (str) – optional password to unlock UBoot
- init_commands (Tuple[str]) – a tuple of commands to run after unlock
-
bindings
= {'console': <class 'labgrid.protocol.consoleprotocol.ConsoleProtocol'>}¶
-
prompt
= Attribute(name='prompt', default='', validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
password
= Attribute(name='password', default='', validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
init_commands
= Attribute(name='init_commands', default=Factory(factory=<class 'tuple'>), validator=None, repr=True, cmp=True, hash=True, init=True, convert=<class 'tuple'>, metadata=mappingproxy({}))¶
-
on_activate
()[source]¶ Activate the UBootDriver
This function checks for a prompt and awaits it if not already active
-
run
(cmd)[source]¶ Runs the specified command on the shell and returns the output.
Parameters: cmd (str) – command to run on the shell Returns: if successful, None otherwise Return type: Tuple[List[str],List[str], int]
-
run_check
(cmd)[source]¶ Runs the specified command on the shell and returns the output if successful, raises ExecutionError otherwise.
Parameters: cmd (str) – command to run on the shell Returns: stdout of the executed command Return type: List[str]
-
get_status
()[source]¶ Retrieve status of the UBootDriver. 0 means inactive, 1 means active.
Returns: status of the driver Return type: int
labgrid.driver.usbloader module¶
-
class
labgrid.driver.usbloader.
MXSUSBDriver
(target, image=None)[source]¶ Bases:
labgrid.driver.common.Driver
,labgrid.protocol.bootstrapprotocol.BootstrapProtocol
-
bindings
= {'loader': {<class 'labgrid.resource.udev.MXSUSBLoader'>, <class 'labgrid.resource.remote.NetworkMXSUSBLoader'>}}¶
-
image
= Attribute(name='image', default=None, validator=None, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-
-
class
labgrid.driver.usbloader.
IMXUSBDriver
(target, image=None)[source]¶ Bases:
labgrid.driver.common.Driver
,labgrid.protocol.bootstrapprotocol.BootstrapProtocol
-
bindings
= {'loader': {<class 'labgrid.resource.udev.IMXUSBLoader'>, <class 'labgrid.resource.remote.NetworkIMXUSBLoader'>}}¶
-
image
= Attribute(name='image', default=None, validator=None, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))¶
-