Source code for labgrid.strategy.bareboxstrategy

import enum

import attr

from ..driver import BareboxDriver, ShellDriver
from ..factory import target_factory
from ..protocol import PowerProtocol
from ..step import step
from .common import Strategy, StrategyError

[docs]class Status(enum.Enum): unknown = 0 off = 1 barebox = 2 shell = 3
[docs]@target_factory.reg_driver @attr.s(eq=False) class BareboxStrategy(Strategy): """BareboxStrategy - Strategy to switch to barebox or shell""" bindings = { "power": PowerProtocol, "barebox": BareboxDriver, "shell": ShellDriver, } status = attr.ib(default=Status.unknown)
[docs] def __attrs_post_init__(self): super().__attrs_post_init__()
[docs] @step(args=['status']) def transition(self, status, *, step): if not isinstance(status, Status): status = Status[status] if status == Status.unknown: raise StrategyError("can not transition to {}".format(status)) elif status == self.status: step.skip("nothing to do") return # nothing to do elif status == elif status == Status.barebox: self.transition( # pylint: disable=missing-kwoa # cycle power self.power.cycle() # interrupt barebox elif status == # tansition to barebox self.transition(Status.barebox) # pylint: disable=missing-kwoa self.barebox.boot("") self.barebox.await_boot() else: raise StrategyError( "no transition found from {} to {}". format(self.status, status) ) self.status = status