Skip to content

Commit

Permalink
multiple: set attr.s(cmp=False)
Browse files Browse the repository at this point in the history
We don't need the compare functionality of attrs. Disable it to fall back to
object id hashes.

Fixes #106

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
  • Loading branch information
Emantor committed Jul 18, 2017
1 parent 60538b6 commit 824a6ab
Show file tree
Hide file tree
Showing 29 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion labgrid/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BindingState(enum.Enum):
active = 2


@attr.s
@attr.s(cmp=False)
class BindingMixin:
"""
Handles the binding and activation of drivers and their supplying resources
Expand Down
2 changes: 1 addition & 1 deletion labgrid/driver/bareboxdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class BareboxDriver(CommandMixin, Driver, CommandProtocol, LinuxBootProtocol):
"""BareboxDriver - Driver to control barebox via the console.
BareboxDriver binds on top of a ConsoleProtocol.
Expand Down
2 changes: 1 addition & 1 deletion labgrid/driver/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .exception import ExecutionError


@attr.s
@attr.s(cmp=False)
class Driver(BindingMixin):
"""
Represents a driver which is used externally or by other drivers. It
Expand Down
2 changes: 1 addition & 1 deletion labgrid/driver/externalconsoledriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class ExternalConsoleDriver(ConsoleExpectMixin, Driver, ConsoleProtocol):
"""
Driver implementing the ConsoleProtocol interface using a subprocess
Expand Down
8 changes: 4 additions & 4 deletions labgrid/driver/fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class FakeConsoleDriver(ConsoleExpectMixin, Driver, ConsoleProtocol):
txdelay = attr.ib(default=0.0, validator=attr.validators.instance_of(float))

Expand All @@ -32,7 +32,7 @@ def close(self):


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class FakeCommandDriver(CommandMixin, Driver, CommandProtocol):
@Driver.check_active
def run(self, *args):
Expand All @@ -48,7 +48,7 @@ def get_status(self):


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class FakeFileTransferDriver(Driver, FileTransferProtocol):
@Driver.check_active
def get(self, *args):
Expand All @@ -59,7 +59,7 @@ def put(self, *args):
pass

@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class FakePowerDriver(Driver, PowerProtocol):
@Driver.check_active
def on(self, *args):
Expand Down
2 changes: 1 addition & 1 deletion labgrid/driver/fastbootdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class AndroidFastbootDriver(Driver):
bindings = {
"fastboot": {AndroidFastboot, NetworkAndroidFastboot},
Expand Down
2 changes: 1 addition & 1 deletion labgrid/driver/infodriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .common import Driver

@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class InfoDriver(Driver, InfoProtocol):
"""
InfoDriver implementing the InfoProtocol on top of CommandProtocol drivers
Expand Down
2 changes: 1 addition & 1 deletion labgrid/driver/onewiredriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .common import Driver

@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class OneWirePIODriver(Driver, DigitalOutputProtocol):

bindings = {"port": OneWirePIO, }
Expand Down
2 changes: 1 addition & 1 deletion labgrid/driver/openocddriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class OpenOCDDriver(Driver, BootstrapProtocol):
bindings = {
"interface": {AlteraUSBBlaster, NetworkAlteraUSBBlaster},
Expand Down
8 changes: 4 additions & 4 deletions labgrid/driver/powerdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class ManualPowerDriver(Driver, PowerProtocol):
"""ManualPowerDriver - Driver to tell the user to control a target's power"""
name = attr.ib(validator=attr.validators.instance_of(str))
Expand Down Expand Up @@ -43,7 +43,7 @@ def cycle(self):


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class ExternalPowerDriver(Driver, PowerProtocol):
"""ExternalPowerDriver - Driver using an external command to control a target's power"""
cmd_on = attr.ib(validator=attr.validators.instance_of(str))
Expand Down Expand Up @@ -78,7 +78,7 @@ def cycle(self):
self.on()

@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class NetworkPowerDriver(Driver, PowerProtocol):
"""NetworkPowerDriver - Driver using a networked power switch to control a target's power"""
bindings = {"port": NetworkPowerPort, }
Expand Down Expand Up @@ -115,7 +115,7 @@ def get(self):
return self.backend.get(self.port.host, self.port.index)

@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class DigitalOutputPowerDriver(Driver, PowerProtocol):
"""DigitalOutputPowerDriver - Driver using a DigitalOutput to reset the target and
subprocesses to turn it on and off"""
Expand Down
2 changes: 1 addition & 1 deletion labgrid/driver/qemudriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class QEMUDriver(ConsoleExpectMixin, Driver, PowerProtocol, ConsoleProtocol):
"""
The QEMUDriver implements an interface to start targets as qemu instances.
Expand Down
2 changes: 1 addition & 1 deletion labgrid/driver/serialdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class SerialDriver(ConsoleExpectMixin, Driver, ConsoleProtocol):
"""
Driver implementing the ConsoleProtocol interface over a SerialPort connection
Expand Down
2 changes: 1 addition & 1 deletion labgrid/driver/shelldriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class ShellDriver(CommandMixin, Driver, CommandProtocol, FileTransferProtocol):
"""ShellDriver - Driver to execute commands on the shell
ShellDriver binds on top of a ConsoleProtocol.
Expand Down
2 changes: 1 addition & 1 deletion labgrid/driver/sshdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class SSHDriver(CommandMixin, Driver, CommandProtocol, FileTransferProtocol):
"""SSHDriver - Driver to execute commands via SSH"""
bindings = {"networkservice": NetworkService, }
Expand Down
2 changes: 1 addition & 1 deletion labgrid/driver/ubootdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class UBootDriver(CommandMixin, Driver, CommandProtocol, LinuxBootProtocol):
"""UBootDriver - Driver to control uboot via the console.
UBootDriver binds on top of a ConsoleProtocol.
Expand Down
4 changes: 2 additions & 2 deletions labgrid/driver/usbloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class MXSUSBDriver(Driver, BootstrapProtocol):
bindings = {
"loader": {MXSUSBLoader, NetworkMXSUSBLoader},
Expand Down Expand Up @@ -48,7 +48,7 @@ def load(self, filename=None):


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class IMXUSBDriver(Driver, BootstrapProtocol):
bindings = {
"loader": {IMXUSBLoader, NetworkIMXUSBLoader},
Expand Down
2 changes: 1 addition & 1 deletion labgrid/driver/usbstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class USBStorageDriver(Driver):
bindings = {"storage": USBMassStorage, }

Expand Down
2 changes: 1 addition & 1 deletion labgrid/external/usbstick.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class USBStatus(enum.Enum):
mounted = 2


@attr.s
@attr.s(cmp=False)
class USBStick(object):
"""The USBStick class provides an easy to use interface to describe a
target as an USB Stick."""
Expand Down
4 changes: 2 additions & 2 deletions labgrid/resource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .common import Resource


@attr.s
@attr.s(cmp=False)
class SerialPort(Resource):
"""The basic SerialPort describes port and speed
Expand All @@ -14,7 +14,7 @@ class SerialPort(Resource):
speed = attr.ib(default=115200, validator=attr.validators.instance_of(int))


@attr.s
@attr.s(cmp=False)
class EthernetInterface(Resource):
"""The basic EthernetInterface contains an interfacename
Expand Down
6 changes: 3 additions & 3 deletions labgrid/resource/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ..binding import BindingMixin


@attr.s
@attr.s(cmp=False)
class Resource(BindingMixin):
"""
Represents a resource which is used by drivers. It only stores information
Expand All @@ -24,7 +24,7 @@ def command_prefix(self):
return []


@attr.s
@attr.s(cmp=False)
class NetworkResource(Resource):
"""
Represents a remote Resource available on another computer.
Expand Down Expand Up @@ -71,7 +71,7 @@ def poll(self):
pass


@attr.s
@attr.s(cmp=False)
class ManagedResource(Resource):
"""
Represents a resource which can appear and disappear at runtime. Every
Expand Down
2 changes: 1 addition & 1 deletion labgrid/resource/networkservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@target_factory.reg_resource
@attr.s
@attr.s(cmp=False)
class NetworkService(Resource):
address = attr.ib(validator=attr.validators.instance_of(str))
username = attr.ib(validator=attr.validators.instance_of(str))
2 changes: 1 addition & 1 deletion labgrid/resource/onewireport.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@target_factory.reg_resource
@attr.s
@attr.s(cmp=False)
class OneWirePIO(Resource):
"""This resource describes a Onewire PIO Port.
Expand Down
2 changes: 1 addition & 1 deletion labgrid/resource/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@target_factory.reg_resource
@attr.s
@attr.s(cmp=False)
class NetworkPowerPort(Resource):
"""The NetworkPowerPort describes a remotely switchable PowerPort
Expand Down
4 changes: 2 additions & 2 deletions labgrid/resource/serialport.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


@target_factory.reg_resource
@attr.s
@attr.s(cmp=False)
class RawSerialPort(SerialPort, Resource):
"""RawSerialPort describes a serialport which is vailable on the local computer."""
def __attrs_post_init__(self):
Expand All @@ -16,7 +16,7 @@ def __attrs_post_init__(self):

# This does not derive from SerialPort because it is not directly accessible
@target_factory.reg_resource
@attr.s
@attr.s(cmp=False)
class NetworkSerialPort(NetworkResource):
"""A NetworkSerialPort is a remotely accessable serialport, usually
accessed via rfc2217.
Expand Down
16 changes: 8 additions & 8 deletions labgrid/resource/udev.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def poll(self):
break


@attr.s
@attr.s(cmp=False)
class USBResource(ManagedResource):
manager_cls = UdevManager

Expand Down Expand Up @@ -144,7 +144,7 @@ def read_attr(self, attribute):


@target_factory.reg_resource
@attr.s
@attr.s(cmp=False)
class USBSerialPort(SerialPort, USBResource):
def __attrs_post_init__(self):
self.match['SUBSYSTEM'] = 'tty'
Expand All @@ -158,7 +158,7 @@ def update(self):
self.port = None

@target_factory.reg_resource
@attr.s
@attr.s(cmp=False)
class USBMassStorage(USBResource):
def __attrs_post_init__(self):
self.match['SUBSYSTEM'] = 'block'
Expand All @@ -171,7 +171,7 @@ def path(self):
return self.device.device_node

@target_factory.reg_resource
@attr.s
@attr.s(cmp=False)
class IMXUSBLoader(USBResource):
def filter_match(self, device):
if device.get('ID_VENDOR_ID') != "15a2":
Expand All @@ -182,7 +182,7 @@ def filter_match(self, device):


@target_factory.reg_resource
@attr.s
@attr.s(cmp=False)
class MXSUSBLoader(USBResource):
def filter_match(self, device):
if device.get('ID_VENDOR_ID') != "066f":
Expand All @@ -192,7 +192,7 @@ def filter_match(self, device):
return super().filter_match(device)

@target_factory.reg_resource
@attr.s
@attr.s(cmp=False)
class AndroidFastboot(USBResource):
def filter_match(self, device):
if device.get('ID_VENDOR_ID') != "1d6b":
Expand All @@ -202,7 +202,7 @@ def filter_match(self, device):
return super().filter_match(device)

@target_factory.reg_resource
@attr.s
@attr.s(cmp=False)
class USBEthernetInterface(EthernetInterface, USBResource):
def __attrs_post_init__(self):
self.match['SUBSYSTEM'] = 'net'
Expand All @@ -224,7 +224,7 @@ def if_state(self):
return value

@target_factory.reg_resource
@attr.s
@attr.s(cmp=False)
class AlteraUSBBlaster(USBResource):
def filter_match(self, device):
if device.get('ID_VENDOR_ID') != "09fb":
Expand Down
2 changes: 1 addition & 1 deletion labgrid/strategy/bareboxstrategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Status(enum.Enum):


@target_factory.reg_driver
@attr.s
@attr.s(cmp=False)
class BareboxStrategy(Strategy):
"""BareboxStrategy - Strategy to switch to barebox or shell"""
bindings = {
Expand Down
Loading

0 comments on commit 824a6ab

Please sign in to comment.