Skip to content

Commit

Permalink
q-dev: error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Oct 15, 2024
1 parent 2514885 commit 9f19108
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions qubes/ext/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# USA.
import asyncio
import subprocess
import sys

import qubes

Expand Down Expand Up @@ -138,11 +139,15 @@ def confirm_device_attachment(device, frontends) -> str:
guivm = 'dom0' # TODO
# TODO: guivm rpc?

proc = subprocess.Popen(
["attach-confirm", guivm,
device.backend_domain.name, device.port_id,
device.description,
*[f.name for f in frontends.keys()]],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(target_name, _) = proc.communicate()
return target_name.decode()
try:
proc = subprocess.Popen(
["attach-confirm", guivm,
device.backend_domain.name, device.port_id,
device.description,
*[f.name for f in frontends.keys()]],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(target_name, _) = proc.communicate()
return target_name.decode()
except Exception as exc:
print(exc, file=sys.stderr)
return ""

0 comments on commit 9f19108

Please sign in to comment.