From 86ef6906adb9288634b071be54896cca8b343093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 15 Aug 2016 23:49:59 +0200 Subject: [PATCH] appmenus: don't crash on VM without files on disk Such VM can still trigger some appmenus-related action, for example label change. This may happen during tests, or backup restore. And probably some other cases. --- qubesappmenus/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qubesappmenus/__init__.py b/qubesappmenus/__init__.py index fa85e1e..1dc694b 100644 --- a/qubesappmenus/__init__.py +++ b/qubesappmenus/__init__.py @@ -142,7 +142,10 @@ class AppmenusExtension(qubes.ext.Extension): anything_changed = True templates_dir = self.templates_dir(vm) - appmenus = os.listdir(templates_dir) + if os.path.exists(templates_dir): + appmenus = os.listdir(templates_dir) + else: + appmenus = [] changed_appmenus = [] if os.path.exists(self.whitelist_path(vm)): whitelist = [x.rstrip() for x in open(self.whitelist_path(vm))]