Skip to content

Commit f7a000f

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 f7a000f

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

qui/devices/actionable_widgets.py

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

3132
import qubesadmin
3233
import qubesadmin.devices
3334
import qubesadmin.vm
35+
from qubesadmin import exc
3436

3537
import gi
3638

@@ -40,6 +42,8 @@
4042
from . import backend
4143
import time
4244

45+
logger = logging.getLogger(__name__)
46+
4347

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

325329
self.device.attach_to_vm(backend.VM(new_dispvm))
326330

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

328344
class DetachAndAttachDisposableWidget(ActionableWidget, VMWithIcon):
329345
"""Detach from all current attachments and attach to new disposable"""
@@ -340,6 +356,18 @@ async def widget_action(self, *_args):
340356

341357
self.device.attach_to_vm(backend.VM(new_dispvm))
342358

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

344372
class ToggleFeatureItem(ActionableWidget, SimpleActionWidget):
345373
def __init__(

0 commit comments

Comments
 (0)