22# -*- coding: utf-8 -*-
33# pylint: disable=wrong-import-position,import-error
44import argparse
5+ import asyncio
56import logging
67import sys
78import time
2223import qui .updater .utils
2324
2425gi .require_version ("Gtk" , "3.0" ) # isort:skip
26+ from gi .events import GLibEventLoopPolicy
2527from gi .repository import Gtk , Gdk , Gio # isort:skip
28+
29+ asyncio .set_event_loop_policy (GLibEventLoopPolicy )
30+
2631from qubesadmin import Qubes
32+ import qubesadmin .events
2733import qubesadmin .exc
2834
2935# using locale.gettext is necessary for Gtk.Builder translation support to work
@@ -45,7 +51,7 @@ class QubesUpdater(Gtk.Application):
4551 LOGPATH = "/var/log/qubes/qui.updater.log"
4652 LOG_FORMAT = "%(asctime)s %(message)s"
4753
48- def __init__ (self , qapp , cliargs ):
54+ def __init__ (self , qapp , cliargs , future ):
4955 super ().__init__ (
5056 application_id = "org.gnome.example" ,
5157 flags = Gio .ApplicationFlags .FLAGS_NONE ,
@@ -64,6 +70,7 @@ def __init__(self, qapp, cliargs):
6470 self .log = logging .getLogger ("vm-update.agent.PackageManager" )
6571 self .log .addHandler (log_handler )
6672 self .log .setLevel (self .cliargs .log )
73+ asyncio .ensure_future (future )
6774
6875 def do_activate (self , * _args , ** _kwargs ):
6976 if not self .primary :
@@ -513,8 +520,9 @@ def skip_intro_if_args(args):
513520
514521def main (args = None ):
515522 qapp = Qubes ()
523+ dispatcher = qubesadmin .events .EventDispatcher (qapp )
516524 cliargs = parse_args (args , qapp )
517- app = QubesUpdater (qapp , cliargs )
525+ app = QubesUpdater (qapp , cliargs , dispatcher )
518526 app .run ()
519527 if app .retcode == 100 and not app .cliargs .signal_no_updates :
520528 app .retcode = 0
0 commit comments