Skip to content

Commit

Permalink
q-dev: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Oct 14, 2024
1 parent ac9e490 commit 12dba6c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions qui/tools/attach_confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def main():

if ask_response.startswith("allow:"):
print(ask_response[len("allow:"):], end="")
exit(0)
sys.exit(0)
else:
exit(1)
sys.exit(1)


if __name__ == "__main__":
Expand Down
30 changes: 17 additions & 13 deletions qui/tools/qubes_device_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,8 @@
# pylint: disable=import-error,wrong-import-position
import gi

from qrexec.server import SocketService
from qrexec.utils import sanitize_domain_name
from qubesadmin.device_protocol import DeviceSerializer

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk
from qrexec.tools.qrexec_policy_agent import (
VMListModeler, RPCConfirmationWindow)
from gi.repository import Gtk

# pylint: enable=import-error

Expand All @@ -46,6 +40,13 @@

# pylint: enable=wrong-import-position

from qrexec.server import SocketService
from qrexec.utils import sanitize_domain_name
from qrexec.tools.qrexec_policy_agent import (
VMListModeler, RPCConfirmationWindow)
from qubesadmin.device_protocol import DeviceSerializer


DEVICE_AGENT_SOCKET_PATH = "/var/run/qubes/device-agent.GUI"


Expand Down Expand Up @@ -75,11 +76,10 @@ def _override_entries(self, options):

def apply_icon(self, entry, qube_name):
if isinstance(entry, Gtk.Entry):
for key, vm_info in self._entries.items():
for vm_info in self._entries.values():
if qube_name == vm_info['api_name']:
entry.set_icon_from_pixbuf(
Gtk.EntryIconPosition.PRIMARY,
self._entries[key]["icon"],
Gtk.EntryIconPosition.PRIMARY, vm_info["icon"],
)
break
else:
Expand Down Expand Up @@ -107,8 +107,12 @@ class AttachmentConfirmationWindow(RPCConfirmationWindow):
"error_message": "ErrorMessage",
}

# We reuse most parts of superclass, but we need custom init,
# so we DO NOT call super().__init__()
# pylint: disable=super-init-not-called
def __init__(
self, entries_info, source, device_name, argument, targets_list, target=None
self,
entries_info, source, device_name, argument, targets_list, target=None
):
# pylint: disable=too-many-arguments
sanitize_domain_name(source, assert_sanitized=True)
Expand Down Expand Up @@ -153,7 +157,7 @@ def __init__(

options = {name: " " + options for vm_data in targets_list
for name, _, options in (vm_data.partition(" "),)}
list_modeler = self._new_vm_list_modeler(options)
list_modeler = self._new_vm_list_modeler_overridden(options)

list_modeler.apply_model(
self._rpc_combo_box,
Expand All @@ -171,7 +175,7 @@ def __init__(

self._connect_events()

def _new_vm_list_modeler(self, options):
def _new_vm_list_modeler_overridden(self, options):
return VMAndPortListModeler(options, self._entries_info)


Expand Down

0 comments on commit 12dba6c

Please sign in to comment.