diff --git a/examples/deditec-relais8/deditec.py b/examples/deditec-relais8/deditec.py index 189cbefe8..0a47982ca 100644 --- a/examples/deditec-relais8/deditec.py +++ b/examples/deditec-relais8/deditec.py @@ -1,24 +1,19 @@ -import sys -import labgrid import logging import time -from labgrid import Environment, StepReporter -from labgrid.strategy.bareboxstrategy import Status -from labgrid.driver.deditecrelaisdriver import DeditecRelaisDriver +from labgrid import Target +from labgrid.logging import basicConfig, StepLogger +from labgrid.resource.udev import DeditecRelais8 +from labgrid.driver import DeditecRelaisDriver -# enable debug logging -logging.basicConfig( - level=logging.DEBUG, - format='%(levelname)7s: %(message)s', - stream=sys.stderr, -) +# enable info logging +basicConfig(level=logging.INFO) -# show labgrid steps on the console -StepReporter.start() +# log labgrid steps +StepLogger.start() -t = labgrid.Target('main') -r = labgrid.resource.udev.DeditecRelais8(t, name=None, index=1) +t = Target('main') +r = DeditecRelais8(t, name=None, index=1) d = DeditecRelaisDriver(t, name=None) p = t.get_driver("DigitalOutputProtocol") diff --git a/examples/deditec-relais8/deditec_remote.py b/examples/deditec-relais8/deditec_remote.py index b9f2ca16c..53a860ed3 100644 --- a/examples/deditec-relais8/deditec_remote.py +++ b/examples/deditec-relais8/deditec_remote.py @@ -1,23 +1,16 @@ -import sys -import labgrid import logging import time -from labgrid import Environment, StepReporter -from labgrid.strategy.bareboxstrategy import Status -from labgrid.driver.deditecrelaisdriver import DeditecRelaisDriver +from labgrid import Environment +from labgrid.logging import basicConfig, StepLogger -# enable debug logging -logging.basicConfig( - level=logging.DEBUG, - format='%(levelname)7s: %(message)s', - stream=sys.stderr, -) +# enable info logging +basicConfig(level=logging.INFO) # show labgrid steps on the console -StepReporter.start() +StepLogger.start() -e = labgrid.Environment('import-dedicontrol.yaml') +e = Environment('import-dedicontrol.yaml') t = e.get_target() p = t.get_driver("DigitalOutputProtocol") diff --git a/examples/library/test.py b/examples/library/test.py index f0b060218..9870e1670 100755 --- a/examples/library/test.py +++ b/examples/library/test.py @@ -4,19 +4,16 @@ import sys import logging -from labgrid import Environment, StepReporter +from labgrid import Environment +from labgrid.logging import basicConfig, StepLogger from labgrid.strategy.bareboxstrategy import Status -# enable debug logging -logging.basicConfig( - level=logging.DEBUG, - format='%(levelname)7s: %(message)s', - stream=sys.stderr, -) +# enable info logging +basicConfig(level=logging.INFO) -# show labgrid steps on the console -StepReporter.start() +# log labgrid steps +StepLogger.start() def run_once(target): s = target.get_driver('BareboxStrategy') diff --git a/examples/networkmanager/nm.py b/examples/networkmanager/nm.py index 587e39085..e2e9f8876 100644 --- a/examples/networkmanager/nm.py +++ b/examples/networkmanager/nm.py @@ -1,18 +1,15 @@ -import logging, sys +import logging from pprint import pprint -from labgrid import * +from labgrid import Environment +from labgrid.logging import basicConfig, StepLogger # enable debug logging -logging.basicConfig( - level=logging.DEBUG, - format='%(levelname)7s: %(message)s', - stream=sys.stderr, -) +basicConfig(level=logging.DEBUG) # show labgrid steps on the console -StepReporter.start() +StepLogger.start() e = Environment('nm.env') diff --git a/examples/qemu-networking/qemunetworkstrategy.py b/examples/qemu-networking/qemunetworkstrategy.py index 995223494..48becd0da 100644 --- a/examples/qemu-networking/qemunetworkstrategy.py +++ b/examples/qemu-networking/qemunetworkstrategy.py @@ -17,7 +17,7 @@ import attr from labgrid import target_factory, step -from labgrid.strategy import Strategy +from labgrid.strategy import Strategy, StrategyError from labgrid.util import get_free_port @@ -75,7 +75,7 @@ def update_network_service(self): networkservice.port = local_port else: networkservice.address = new_address - networkserivce.port = self.__remote_port + networkservice.port = self.__remote_port @step(args=["state"]) def transition(self, state, *, step): @@ -83,7 +83,7 @@ def transition(self, state, *, step): state = Status[state] if state == Status.unknown: - raise StrategyError(f"can not transition to {new_status}") + raise StrategyError(f"can not transition to {state}") elif self.status == state: step.skip("nothing to do") @@ -99,4 +99,4 @@ def transition(self, state, *, step): self.target.activate(self.shell) self.update_network_service() - self.status = status + self.status = state diff --git a/examples/sigrok/main.py b/examples/sigrok/main.py index a213232d6..3b107863f 100755 --- a/examples/sigrok/main.py +++ b/examples/sigrok/main.py @@ -6,13 +6,10 @@ import logging from labgrid import Environment +from labgrid.logging import basicConfig -# enable debug logging -logging.basicConfig( - level=logging.DEBUG, - format='%(levelname)7s: %(message)s', - stream=sys.stderr, -) +# enable info logging +basicConfig(level=logging.INFO) env = Environment(sys.argv[1]) target = env.get_target('main') diff --git a/examples/strategy/bareboxrebootstrategy.py b/examples/strategy/bareboxrebootstrategy.py index f909635f6..22bb93489 100644 --- a/examples/strategy/bareboxrebootstrategy.py +++ b/examples/strategy/bareboxrebootstrategy.py @@ -2,11 +2,10 @@ import attr +from labgrid import target_factory, step from labgrid.driver import BareboxDriver, ShellDriver from labgrid.protocol import PowerProtocol -from labgrid.factory import target_factory -from labgrid.step import step -from labgrid.strategy.common import Strategy +from labgrid.strategy import Strategy @attr.s(eq=False) diff --git a/examples/strategy/quartusstrategy.py b/examples/strategy/quartusstrategy.py index 47d346a74..d5f65ccff 100644 --- a/examples/strategy/quartusstrategy.py +++ b/examples/strategy/quartusstrategy.py @@ -2,11 +2,10 @@ import attr +from labgrid import target_factory, step from labgrid.driver import QuartusHPSDriver, SerialDriver -from labgrid.factory import target_factory from labgrid.protocol import PowerProtocol -from labgrid.step import step -from labgrid.strategy.common import Strategy +from labgrid.strategy import Strategy @attr.s(eq=False) diff --git a/examples/strategy/test_barebox_strategy.py b/examples/strategy/test_barebox_strategy.py index d64431757..6d950145e 100644 --- a/examples/strategy/test_barebox_strategy.py +++ b/examples/strategy/test_barebox_strategy.py @@ -1,7 +1,5 @@ import pytest -from labgrid.exceptions import NoDriverFoundError - @pytest.fixture(scope="function") def in_bootloader(strategy, capsys): diff --git a/examples/sysfsgpio/sysfsgpio.py b/examples/sysfsgpio/sysfsgpio.py index d915d7e8b..494c87eee 100644 --- a/examples/sysfsgpio/sysfsgpio.py +++ b/examples/sysfsgpio/sysfsgpio.py @@ -1,23 +1,19 @@ -import sys -import labgrid import logging import time -from labgrid import Environment, StepReporter -from labgrid.driver.gpiodriver import GpioDigitalOutputDriver +from labgrid import Target +from labgrid.logging import basicConfig, StepLogger +from labgrid.driver import GpioDigitalOutputDriver +from labgrid.resource import SysfsGPIO -# enable debug logging -logging.basicConfig( - level=logging.DEBUG, - format='%(levelname)7s: %(message)s', - stream=sys.stderr, -) +# enable info logging +basicConfig(level=logging.INFO) # show labgrid steps on the console -StepReporter.start() +StepLogger.start() -t = labgrid.Target('main') -r = labgrid.resource.base.SysfsGPIO(t, name=None, index=60) +t = Target('main') +r = SysfsGPIO(t, name=None, index=60) d = GpioDigitalOutputDriver(t, name=None) p = t.get_driver("DigitalOutputProtocol") diff --git a/examples/sysfsgpio/sysfsgpio_remote.py b/examples/sysfsgpio/sysfsgpio_remote.py index b85807843..e5225dd48 100644 --- a/examples/sysfsgpio/sysfsgpio_remote.py +++ b/examples/sysfsgpio/sysfsgpio_remote.py @@ -1,22 +1,16 @@ -import sys -import labgrid import logging import time -from labgrid import Environment, StepReporter -from labgrid.driver.gpiodriver import GpioDigitalOutputDriver +from labgrid import Environment +from labgrid.logging import basicConfig, StepLogger -# enable debug logging -logging.basicConfig( - level=logging.DEBUG, - format='%(levelname)7s: %(message)s', - stream=sys.stderr, -) +# enable info logging +basicConfig(level=logging.INFO) # show labgrid steps on the console -StepReporter.start() +StepLogger.start() -e = labgrid.Environment('import-gpio.yaml') +e = Environment('import-gpio.yaml') t = e.get_target() p = t.get_driver("DigitalOutputProtocol") diff --git a/examples/usbpower/examplestrategy.py b/examples/usbpower/examplestrategy.py index accc6b89f..daf733f7a 100644 --- a/examples/usbpower/examplestrategy.py +++ b/examples/usbpower/examplestrategy.py @@ -3,9 +3,8 @@ import attr from labgrid.driver import BareboxDriver, ShellDriver, USBSDMuxDriver -from labgrid.factory import target_factory +from labgrid import step, target_factory from labgrid.protocol import PowerProtocol -from labgrid.step import step from labgrid.strategy import Strategy diff --git a/examples/usbpower/test_example.py b/examples/usbpower/test_example.py index ea2b9dcdc..fe07d0cbf 100644 --- a/examples/usbpower/test_example.py +++ b/examples/usbpower/test_example.py @@ -1,7 +1,5 @@ import pytest -from labgrid.exceptions import NoDriverFoundError - @pytest.fixture(scope="function") def bootloader(target, strategy, capsys):