Skip to content

Commit

Permalink
Do not react to events when running in "offline mode"
Browse files Browse the repository at this point in the history
In practice, do not modify system state when running unit tests.
  • Loading branch information
marmarek committed May 15, 2024
1 parent dd34826 commit a42602f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions qubesappmenusext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,24 @@ async def remove_from_disk(self, vm, event):

@qubes.ext.handler('property-set:label')
def label_setter(self, vm, event, **kwargs):
if vm.app.vmm.offline_mode:
return
self.collect_done_tasks(vm)
self.vm_tasks[vm.name].append(
asyncio.ensure_future(self.update_appmenus(vm)))

@qubes.ext.handler('property-set:provides_network')
def provides_network_setter(self, vm, event, **kwargs):
if vm.app.vmm.offline_mode:
return
self.collect_done_tasks(vm)
self.vm_tasks[vm.name].append(
asyncio.ensure_future(self.update_appmenus(vm)))

@qubes.ext.handler('property-set:guivm')
def provides_network_setter(self, vm, event, name, newvalue, oldvalue=None):
if vm.app.vmm.offline_mode:
return
self.collect_done_tasks(vm)
if oldvalue and oldvalue != newvalue:
self.vm_tasks[vm.name].append(
Expand All @@ -178,33 +184,43 @@ def provides_network_setter(self, vm, event, name, newvalue, oldvalue=None):

@qubes.ext.handler('domain-feature-delete:appmenus-dispvm')
def on_feature_del_appmenus_dispvm(self, vm, event, feature):
if vm.app.vmm.offline_mode:
return
self.collect_done_tasks(vm)
self.vm_tasks[vm.name].append(
asyncio.ensure_future(self.update_appmenus(vm)))

@qubes.ext.handler('domain-feature-set:appmenus-dispvm')
def on_feature_set_appmenus_dispvm(self, vm, event, feature,
value, oldvalue=None):
if vm.app.vmm.offline_mode:
return
self.collect_done_tasks(vm)
self.vm_tasks[vm.name].append(
asyncio.ensure_future(self.update_appmenus(vm)))

@qubes.ext.handler('domain-feature-set:menu-items')
def on_feature_set_appmenus_dispvm(self, vm, event, feature,
value, oldvalue=None):
if vm.app.vmm.offline_mode:
return
self.collect_done_tasks(vm)
self.vm_tasks[vm.name].append(
asyncio.ensure_future(self.update_appmenus(vm)))

@qubes.ext.handler('domain-feature-delete:internal')
def on_feature_del_internal(self, vm, event, feature):
if vm.app.vmm.offline_mode:
return
self.collect_done_tasks(vm)
self.vm_tasks[vm.name].append(
asyncio.ensure_future(self.update_appmenus(vm)))

@qubes.ext.handler('domain-feature-set:internal')
def on_feature_set_internal(self, vm, event, feature, value,
oldvalue=None):
if vm.app.vmm.offline_mode:
return
self.collect_done_tasks(vm)
if value:
self.vm_tasks[vm.name].append(
Expand Down

0 comments on commit a42602f

Please sign in to comment.