Skip to content

Commit 70c63f8

Browse files
committed
devices widget: open file manager on dispvm block attach
- Use wait=False so run_service is non-blocking - Log exception with logger.warning + exc_info=True instead of silent pass - Apply same fix to DetachAndAttachDisposableWidget - Fix import ordering, add logging setup - Run black to satisfy CI Fixes QubesOS/qubes-issues#10709
1 parent d56bb9e commit 70c63f8

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

qui/devices/actionable_widgets.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import asyncio
2727
import functools
2828
import pathlib
29+
import logging
2930
from typing import Iterable, Callable, Optional, List
3031

3132
import qubesadmin
@@ -40,6 +41,8 @@
4041
from . import backend
4142
import time
4243

44+
logger = logging.getLogger(__name__)
45+
4346

4447
def load_icon(icon_name: str, backup_name: str, size: int = 24):
4548
"""Load icon from provided name/path, if available. If not, load backup
@@ -324,6 +327,18 @@ async def widget_action(self, *_args):
324327

325328
self.device.attach_to_vm(backend.VM(new_dispvm))
326329

330+
if self.device.device_class == "block":
331+
try:
332+
new_dispvm.run_service(
333+
"qubes.StartApp+qubes-open-file-manager",
334+
wait=False,
335+
)
336+
except Exception: # pylint: disable=broad-except
337+
logger.exception(
338+
"Failed to open file manager in %s",
339+
new_dispvm.name,
340+
)
341+
327342

328343
class DetachAndAttachDisposableWidget(ActionableWidget, VMWithIcon):
329344
"""Detach from all current attachments and attach to new disposable"""
@@ -340,6 +355,18 @@ async def widget_action(self, *_args):
340355

341356
self.device.attach_to_vm(backend.VM(new_dispvm))
342357

358+
if self.device.device_class == "block":
359+
try:
360+
new_dispvm.run_service(
361+
"qubes.StartApp+qubes-open-file-manager",
362+
wait=False,
363+
)
364+
except Exception: # pylint: disable=broad-except
365+
logger.exception(
366+
"Failed to open file manager in %s",
367+
new_dispvm.name,
368+
)
369+
343370

344371
class ToggleFeatureItem(ActionableWidget, SimpleActionWidget):
345372
def __init__(

0 commit comments

Comments
 (0)