From c6f24d8ba872cef73f7f8d5bb277ee6db4b0b272 Mon Sep 17 00:00:00 2001 From: Wojciech Zygmunt Porczyk Date: Wed, 7 May 2014 14:54:59 +0200 Subject: [PATCH] qubes-receive-appmenus: use old icons when retrieval fails (#836) --- appmenus-scripts/qubes-receive-appmenus | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/appmenus-scripts/qubes-receive-appmenus b/appmenus-scripts/qubes-receive-appmenus index dd856e0..3090645 100755 --- a/appmenus-scripts/qubes-receive-appmenus +++ b/appmenus-scripts/qubes-receive-appmenus @@ -231,14 +231,19 @@ def main(): # the following line is used for time comparison # del new_appmenus[appmenu_file]['Icon'] + icondest = os.path.join(vm.appmenus_template_icons_dir, + os.path.splitext(appmenu_file)[0] + '.png') + try: qubes.imgconverter.Image.get_xdg_icon_from_vm(vm, - new_appmenus[appmenu_file]['Icon']).save( - os.path.join(vm.appmenus_template_icons_dir, - os.path.splitext(appmenu_file)[0] + '.png')) + new_appmenus[appmenu_file]['Icon']).save(icondest) except Exception, e: print >> sys.stderr, '----> Failed to get icon for {0}: {1!s}'.format(appmenu_file, e) - del new_appmenus[appmenu_file]['Icon'] + + if os.path.exists(icondest): + print >> sys.stderr, '-----> Found old icon, using it instead' + else: + del new_appmenus[appmenu_file]['Icon'] create_template(os.path.join(vm.appmenus_templates_dir, appmenu_file), new_appmenus[appmenu_file])