qubes: disable events by default not to interfere with loading from XML
This commit is contained in:
parent
f2d9d628c4
commit
7f16e0a73b
@ -450,6 +450,7 @@ class VMCollection(object):
|
|||||||
'name={!r} ({!r})'.format(value.name, self[value.name]))
|
'name={!r} ({!r})'.format(value.name, self[value.name]))
|
||||||
|
|
||||||
self._dict[value.qid] = value
|
self._dict[value.qid] = value
|
||||||
|
value.events_enabled = True
|
||||||
self.app.fire_event('domain-added', value)
|
self.app.fire_event('domain-added', value)
|
||||||
|
|
||||||
|
|
||||||
@ -799,6 +800,7 @@ class PropertyHolder(qubes.events.Emitter):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, xml, **kwargs):
|
def __init__(self, xml, **kwargs):
|
||||||
|
super(PropertyHolder, self).__init__()
|
||||||
self.xml = xml
|
self.xml = xml
|
||||||
|
|
||||||
for key, value in kwargs.items():
|
for key, value in kwargs.items():
|
||||||
@ -810,8 +812,6 @@ class PropertyHolder(qubes.events.Emitter):
|
|||||||
continue
|
continue
|
||||||
setattr(self, key, kwargs.pop(key))
|
setattr(self, key, kwargs.pop(key))
|
||||||
|
|
||||||
super(PropertyHolder, self).__init__(**kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def property_list(cls, load_stage=None):
|
def property_list(cls, load_stage=None):
|
||||||
@ -1141,6 +1141,8 @@ class Qubes(PropertyHolder):
|
|||||||
if load:
|
if load:
|
||||||
self.load()
|
self.load()
|
||||||
|
|
||||||
|
self.events_enabled = True
|
||||||
|
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
'''Open qubes.xml
|
'''Open qubes.xml
|
||||||
|
@ -93,13 +93,16 @@ class EmitterMeta(type):
|
|||||||
|
|
||||||
class Emitter(object):
|
class Emitter(object):
|
||||||
'''Subject that can emit events.
|
'''Subject that can emit events.
|
||||||
|
|
||||||
|
By default all events are disabled not to interfere with loading from XML.
|
||||||
|
To enable event dispatch, set :py:attr:`events_enabled` to :py:obj:`True`.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
__metaclass__ = EmitterMeta
|
__metaclass__ = EmitterMeta
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Emitter, self).__init__(*args, **kwargs)
|
super(Emitter, self).__init__(*args, **kwargs)
|
||||||
self.events_enabled = True
|
self.events_enabled = False
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -37,6 +37,7 @@ class TC_00_Emitter(qubes.tests.QubesTestCase):
|
|||||||
|
|
||||||
emitter = qubes.events.Emitter()
|
emitter = qubes.events.Emitter()
|
||||||
emitter.add_handler('testevent', on_testevent)
|
emitter.add_handler('testevent', on_testevent)
|
||||||
|
emitter.events_enabled = True
|
||||||
emitter.fire_event('testevent')
|
emitter.fire_event('testevent')
|
||||||
self.assertTrue(testevent_fired[0])
|
self.assertTrue(testevent_fired[0])
|
||||||
|
|
||||||
@ -53,5 +54,6 @@ class TC_00_Emitter(qubes.tests.QubesTestCase):
|
|||||||
self.testevent_fired = True
|
self.testevent_fired = True
|
||||||
|
|
||||||
emitter = TestEmitter()
|
emitter = TestEmitter()
|
||||||
|
emitter.events_enabled = True
|
||||||
emitter.fire_event('testevent')
|
emitter.fire_event('testevent')
|
||||||
self.assertTrue(emitter.testevent_fired)
|
self.assertTrue(emitter.testevent_fired)
|
||||||
|
@ -148,8 +148,6 @@ class BaseVM(qubes.PropertyHolder):
|
|||||||
def __init__(self, app, xml, services=None, devices=None, tags=None,
|
def __init__(self, app, xml, services=None, devices=None, tags=None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
# pylint: disable=redefined-outer-name
|
# pylint: disable=redefined-outer-name
|
||||||
|
|
||||||
self.events_enabled = False
|
|
||||||
super(BaseVM, self).__init__(xml, **kwargs)
|
super(BaseVM, self).__init__(xml, **kwargs)
|
||||||
|
|
||||||
#: mother :py:class:`qubes.Qubes` object
|
#: mother :py:class:`qubes.Qubes` object
|
||||||
|
Loading…
Reference in New Issue
Block a user