Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

driver/usbstoragedriver: use udisk2 only when calling write_file #1351

Merged
merged 1 commit into from
Apr 10, 2024
Merged
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
13 changes: 11 additions & 2 deletions labgrid/driver/usbstoragedriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,21 @@ class USBStorageDriver(Driver):
def __attrs_post_init__(self):
super().__attrs_post_init__()
self.wrapper = None
self.proxy = None

def on_activate(self):
def _start_wrapper(self):
if self.wrapper:
return
host = self.storage.host if isinstance(self.storage, RemoteUSBResource) else None
self.wrapper = AgentWrapper(host)
self.proxy = self.wrapper.load('udisks2')

def on_activate(self):
pass

def on_deactivate(self):
self.wrapper.close()
if self.wrapper:
self.wrapper.close()
self.wrapper = None
self.proxy = None

Expand All @@ -75,6 +82,8 @@ def write_files(self, sources, target, partition, target_is_directory=True):
target_is_directory (bool): Whether target is a directory
"""

self._start_wrapper()
Copy link
Member

Choose a reason for hiding this comment

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

I think another if self.wrapper: is required here, otherwise we restart a new AgentWrapper for every write_files() call.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added the check to _start_wrapper().


self.devpath = self._get_devpath(partition)
mount_path = self.proxy.mount(self.devpath)

Expand Down
Loading