From aff94e1b8d6dcbed33db4fdd63684fb41810814e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 Mar 2011 16:38:26 +0100 Subject: [PATCH 1/3] fixed Bug #738207 Fixes: https://launchpad.net/bugs/738207 --- openlp/core/ui/thememanager.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 407d0cfa8..30196b12f 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -424,12 +424,12 @@ class ThemeManager(QtGui.QWidget): unicode(translate('OpenLP.ThemeManager', 'OpenLP Themes (*.theme *.otz)'))) log.info(u'New Themes %s', unicode(files)) + if not files: + return Receiver.send_message(u'cursor_busy') - if files: - for file in files: - SettingsManager.set_last_dir( - self.settingsSection, unicode(file)) - self.unzipTheme(file, self.path) + for file in files: + SettingsManager.set_last_dir(self.settingsSection, unicode(file)) + self.unzipTheme(file, self.path) self.loadThemes() Receiver.send_message(u'cursor_normal') @@ -502,16 +502,16 @@ class ThemeManager(QtGui.QWidget): def unzipTheme(self, filename, dir): """ Unzip the theme, remove the preview file if stored - Generate a new preview fileCheck the XML theme version and upgrade if + Generate a new preview file. Check the XML theme version and upgrade if necessary. """ log.debug(u'Unzipping theme %s', filename) filename = unicode(filename) zip = None outfile = None + filexml = None try: zip = zipfile.ZipFile(filename) - filexml = None themename = None for file in zip.namelist(): ucsfile = file_is_unicode(file) @@ -562,7 +562,9 @@ class ThemeManager(QtGui.QWidget): if filexml: theme = self._createThemeFromXml(filexml, self.path) self.generateAndSaveImage(dir, themename, theme) - else: + # Only show the error message, when IOError was not raised (in this + # case the error message has already been show). + elif zip is not None: critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), translate('OpenLP.ThemeManager', From 4c4dfcc6c557c4324b9927fb5d7608fa3ee0205c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 Mar 2011 16:43:25 +0100 Subject: [PATCH 2/3] fixed BadZipfile exception --- openlp/core/ui/thememanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 30196b12f..39e72f763 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -547,7 +547,7 @@ class ThemeManager(QtGui.QWidget): else: outfile = open(fullpath, u'wb') outfile.write(zip.read(file)) - except (IOError, NameError): + except (IOError, NameError, zipfile.BadZipfile): critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), translate('OpenLP.ThemeManager', 'File is not a valid theme.')) From a12dd5722cf9ddb333d4342929fe7ed6e5110028 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 Mar 2011 16:51:03 +0100 Subject: [PATCH 3/3] typo --- openlp/core/ui/thememanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 39e72f763..487798f5b 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -563,7 +563,7 @@ class ThemeManager(QtGui.QWidget): theme = self._createThemeFromXml(filexml, self.path) self.generateAndSaveImage(dir, themename, theme) # Only show the error message, when IOError was not raised (in this - # case the error message has already been show). + # case the error message has already been shown). elif zip is not None: critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'),