From ab8e65924d64c44c797197ea7fdd02338bd65e7e Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Thu, 8 Oct 2015 17:50:23 +0200 Subject: [PATCH] Fix popup when no theme present --- butterfly/routes.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/butterfly/routes.py b/butterfly/routes.py index 219ac31..60f41b6 100644 --- a/butterfly/routes.py +++ b/butterfly/routes.py @@ -321,11 +321,16 @@ class ThemesList(Route): themes_dir = os.path.join( self.application.butterfly_dir, 'themes') self.set_header('Content-Type', 'application/json') + if os.path.exists(themes_dir): + themes = [ + theme + for theme in os.listdir(themes_dir) + if os.path.isdir(os.path.join(themes_dir, theme)) and + not theme.startswith('.')] + else: + themes = [] + self.write(tornado.escape.json_encode({ - 'themes': sorted( - [theme - for theme in os.listdir(themes_dir) - if os.path.isdir(os.path.join(themes_dir, theme)) and - not theme.startswith('.')]), + 'themes': sorted(themes), 'dir': themes_dir }))