Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions labgrid/driver/usbstoragedriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,22 @@ class USBStorageDriver(Driver):
"NetworkUSBSDWireDevice",
},
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray newline, please remove it.

image = attr.ib(
default=None,
validator=attr.validators.optional(attr.validators.instance_of(str))
)
WAIT_FOR_MEDIUM_TIMEOUT = 10.0 # s
timeout = attr.ib(
default=10.0,
validator=attr.validators.instance_of(float)
)

WAIT_FOR_MEDIUM_SLEEP = 0.5 # s
MOUNT_RETRIES = 5

def __attrs_post_init__(self):
if self.timeout < 0.0:
raise ValueError("timeout must be positive")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved into the validation function for attrs.

super().__attrs_post_init__()
self.wrapper = None
self.proxy = None
Expand Down Expand Up @@ -208,7 +215,7 @@ def _get_devpath(self, partition):

@Driver.check_active
def _wait_for_medium(self, partition):
timeout = Timeout(self.WAIT_FOR_MEDIUM_TIMEOUT)
timeout = Timeout(self.timeout)
while not timeout.expired:
if self.get_size(partition) > 0:
break
Expand Down