Close and delete zip in case of exception

This commit is contained in:
Samuel Mehrbrodt 2014-06-30 09:30:19 +02:00
parent 39fbbf779d
commit 9702870afa

View File

@ -404,12 +404,17 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R
:param theme: The name of the theme to be exported
"""
theme_path = os.path.join(path, theme + '.otz')
try:
theme_zip = zipfile.ZipFile(theme_path, 'w')
source = os.path.join(self.path, theme)
for files in os.walk(source):
for name in files[2]:
theme_zip.write(os.path.join(source, name), os.path.join(theme, name))
except (IOError, OSError):
if theme_zip:
theme_zip.close()
shutil.rmtree(theme_path, True)
raise
def on_import_theme(self, field=None):
"""