labgrid.driver package

Submodules

labgrid.driver.bareboxdriver module

class labgrid.driver.bareboxdriver.BareboxDriver(target, prompt='')[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

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({}))
on_activate()[source]
on_deactivate()[source]
run(cmd, *, step)[source]

Runs the specified cmd on the shell and returns the output.

Arguments: cmd - cmd to run on the shell

run_check(cmd)[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

get_status()[source]

Returns the status of the barebox driver. 0 means not connected/found, 1 means shell

await_prompt()[source]

Await autoboot line and stop it to get to the prompt

await_boot()[source]
boot(name)[source]

labgrid.driver.commandmixin module

class labgrid.driver.commandmixin.CommandMixin[source]

Bases: object

CommandMixin implementing common functions for drivers which support the CommandProtocol

wait_for(cmd, pattern, timeout=30.0, sleepduration=1)[source]

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

class labgrid.driver.consoleexpectmixin.ConsoleExpectMixin[source]

Bases: object

Console driver mixin to implement the read, write, expect and sendline methods. It uses the internal _read and _write methods.

read()[source]
write(data)[source]
sendline(line)[source]
sendcontrol(char)[source]
expect(pattern, timeout=-1)[source]
resolve_conflicts(client)[source]

labgrid.driver.exception module

exception labgrid.driver.exception.ExecutionError(msg)[source]

Bases: Exception

msg = Attribute(name='msg', default=NOTHING, validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))
exception labgrid.driver.exception.CleanUpError(msg)[source]

Bases: Exception

msg = Attribute(name='msg', default=NOTHING, validator=<instance_of validator for type <class 'str'>>, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))

labgrid.driver.externalconsoledriver module

class labgrid.driver.externalconsoledriver.ExternalConsoleDriver(target, cmd)[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({}))
open()[source]

Starts the subprocess, does nothing if it is already closed

close()[source]

Stops the subprocess, does nothing if it is already closed

on_deactivate()[source]

labgrid.driver.fake module

class labgrid.driver.fake.FakeConsoleDriver(target)[source]

Bases: labgrid.driver.consoleexpectmixin.ConsoleExpectMixin, labgrid.driver.common.Driver, labgrid.protocol.consoleprotocol.ConsoleProtocol

open()[source]
close()[source]
class labgrid.driver.fake.FakeCommandDriver(target)[source]

Bases: labgrid.driver.commandmixin.CommandMixin, labgrid.driver.common.Driver, labgrid.protocol.commandprotocol.CommandProtocol

run(*args)[source]
run_check(*args)[source]
get_status()[source]
class labgrid.driver.fake.FakeFileTransferDriver(target)[source]

Bases: labgrid.driver.common.Driver, labgrid.protocol.filetransferprotocol.FileTransferProtocol

get(*args)[source]
put(*args)[source]

labgrid.driver.fastbootdriver module

class labgrid.driver.fastbootdriver.AndroidFastbootDriver(target, image=None)[source]

Bases: labgrid.driver.common.Driver

bindings = {'fastboot': {<class 'labgrid.resource.remote.NetworkAndroidFastboot'>, <class 'labgrid.resource.udev.AndroidFastboot'>}}
image = Attribute(name='image', default=None, validator=None, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))
on_activate()[source]
on_deactivate()[source]
boot(filename)[source]
flash(partition, filename)[source]

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'>}
get_ip(interface='eth0')[source]

Returns the IP of the supplied interface

get_service_status(service)[source]

Returns True if service is active, False in all other cases

get_hostname()[source]

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'>}
set(status)[source]
get()[source]

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({}))
on()[source]
off()[source]
cycle()[source]
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({}))
on()[source]
off()[source]
cycle()[source]
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({}))
on()[source]
off()[source]
cycle()[source]
get()[source]
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({}))
on()[source]
off()[source]
cycle()[source]
get()[source]

labgrid.driver.serialdriver module

class labgrid.driver.serialdriver.SerialDriver(target)[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.serialport.NetworkSerialPort'>, <class 'labgrid.resource.base.SerialPort'>}}
on_activate()[source]
open()[source]

Opens the serialport, does nothing if it is already closed

close()[source]

Closes the serialport, does nothing if it is already closed

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

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({}))
on_activate()[source]
on_deactivate()[source]
run(cmd, *, step)[source]

Runs the specified cmd on the shell and returns the output.

Arguments: cmd - cmd to run on the shell

await_login()[source]

Awaits the login prompt and logs the user in

run_check(cmd)[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

get_status()[source]

Returns the status of the shell-driver. 0 means not connected/found, 1 means shell

put_ssh_key(key)[source]

Upload an SSH Key to a target

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({}))
on_activate()[source]
on_deactivate()[source]
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)

run_check(cmd)[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

get_status()[source]

The SSHDriver is always connected, return 1

put(filename, remotepath=None)[source]
get(filename, destination='.')[source]

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

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]
on_deactivate()[source]
run(cmd)[source]

Runs the specified cmd on the shell and returns the output.

Arguments: cmd - cmd to run on the shell

run_check(cmd)[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

get_status()[source]

Returns the status of the uboot driver. 0 means not connected/found, 1 means shell

await_prompt()[source]

Await autoboot line and stop it to get to the prompt

await_boot()[source]

Wait for boot line of the linux kernel

boot(name)[source]

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.remote.NetworkMXSUSBLoader'>, <class 'labgrid.resource.udev.MXSUSBLoader'>}}
image = Attribute(name='image', default=None, validator=None, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))
on_activate()[source]
on_deactivate()[source]
load(filename=None)[source]
class labgrid.driver.usbloader.IMXUSBDriver(target, image=None)[source]

Bases: labgrid.driver.common.Driver, labgrid.protocol.bootstrapprotocol.BootstrapProtocol

bindings = {'loader': {<class 'labgrid.resource.remote.NetworkIMXUSBLoader'>, <class 'labgrid.resource.udev.IMXUSBLoader'>}}
image = Attribute(name='image', default=None, validator=None, repr=True, cmp=True, hash=True, init=True, convert=None, metadata=mappingproxy({}))
on_activate()[source]
on_deactivate()[source]
load(filename=None)[source]

labgrid.driver.usbstorage module

class labgrid.driver.usbstorage.USBStorageDriver(target)[source]

Bases: labgrid.driver.common.Driver

bindings = {'storage': <class 'labgrid.resource.udev.USBMassStorage'>}
on_activate()[source]
on_deactivate()[source]
write_image(filename)[source]
get_size()[source]