Skip to content

Commit

Permalink
driver/usbstoragedriver: use udisk2 only when calling write_file
Browse files Browse the repository at this point in the history
Otherwise, udisks2 and gi are needed for all installations, even if
write_files is never used.

Fixes: labgrid-project#1219
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
  • Loading branch information
jluebbe committed Apr 9, 2024
1 parent 722838b commit fbca8a0
Showing 1 changed file with 11 additions and 2 deletions.
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()

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

Expand Down

0 comments on commit fbca8a0

Please sign in to comment.