qubesadmin.events package


qubesadmin.events.utils module

Utilities for common events-based actions

exception qubesadmin.events.utils.Interrupt[source]

Bases: Exception

Interrupt events processing

qubesadmin.events.utils.interrupt_on_vm_shutdown(vms, subject, event)[source]

Interrupt events processing when given VM was shutdown


Helper function to wait for domain shutdown.

This function wait for domain shutdown, but do not initiate the shutdown itself.

Parameters:vms – QubesVM object collection to wait for shutdown on

Module contents

Event handling implementation, require Python >=3.5.2 for asyncio.

class qubesadmin.events.EventsDispatcher(app, api_method='admin.Events')[source]

Bases: object

Events dispatcher, responsible for receiving events and calling appropriate handlers

add_handler(event, handler)[source]

Register handler for event

Use ‘*’ as event to register a handler for all events.

Handler function is called with:
  • subject (VM object or None)
  • event name (str)
  • keyword arguments related to the event, if any - all values as str

:param event Event name, or ‘*’ for all events :param handler Handler function

app = None

Qubes() object

handle(subject, event, **kwargs)[source]

Call handlers for given event

handlers = None

event handlers - dict of event -> handlers

listen_for_events(vm=None, reconnect=True)[source]

Listen for events and call appropriate handlers. This function do not exit until manually terminated.

This is coroutine.

  • vm – Listen for events only for this VM, use None to listen for events about all VMs and not related to any particular VM.
  • reconnect – should reconnect to qubesd if connection is interrupted?
Return type:


remove_handler(event, handler)[source]

Remove previously registered event handler

:param event Event name :param handler Handler function