From 66a6502cdfe6dfea74f6008ae4712aededb5f413 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 28 Feb 2013 12:25:05 +0100 Subject: [PATCH 1/5] fixed bug #1116528 (Song Import Wizzard does not work in trunk) Fixes: https://launchpad.net/bugs/1116528 --- openlp/plugins/songs/forms/songimportform.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index b635b309b..8e812f00e 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -35,7 +35,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Settings, UiStrings, translate +from openlp.core.lib import Registry, Settings, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect @@ -489,6 +489,16 @@ class SongImportForm(OpenLPWizard): self.formatWidgets[this_format][u'importWidget'] = importWidget return importWidget + def _get_main_window(self): + """ + Adds the main window to the class dynamically + """ + if not hasattr(self, u'_main_window'): + self._main_window = Registry().get(u'main_window') + return self._main_window + + main_window = property(_get_main_window) + class SongImportSourcePage(QtGui.QWizardPage): """ From dfa2eb1afe3749090a8aec08d06543617caafcb8 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 28 Feb 2013 15:15:17 +0100 Subject: [PATCH 2/5] fixed exception form not shown --- openlp/core/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 3ad0e1348..adc4a250d 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -184,10 +184,10 @@ class OpenLP(QtGui.QApplication): ``traceback`` A traceback object with the details of where the exception occurred. """ - if not hasattr(self, u'mainWindow'): + if not hasattr(self, u'main_window'): log.exception(''.join(format_exception(exctype, value, traceback))) return - if not hasattr(self, u'exceptionForm'): + if not hasattr(self, u'exception_form'): self.exception_form = ExceptionForm(self.main_window) self.exception_form.exceptionTextEdit.setPlainText(''.join(format_exception(exctype, value, traceback))) self.set_normal_cursor() From 7feab25c3f8615e970d3de85375d1a080e39e712 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 28 Feb 2013 15:43:14 +0100 Subject: [PATCH 3/5] always log the exception --- openlp/core/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index adc4a250d..d1112ab5c 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -184,9 +184,7 @@ class OpenLP(QtGui.QApplication): ``traceback`` A traceback object with the details of where the exception occurred. """ - if not hasattr(self, u'main_window'): - log.exception(''.join(format_exception(exctype, value, traceback))) - return + log.exception(''.join(format_exception(exctype, value, traceback))) if not hasattr(self, u'exception_form'): self.exception_form = ExceptionForm(self.main_window) self.exception_form.exceptionTextEdit.setPlainText(''.join(format_exception(exctype, value, traceback))) From 550dfe12fabb5e5f93ba8cb4cfc8568a46e248d5 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 1 Mar 2013 17:18:50 +0100 Subject: [PATCH 4/5] fixed/extended test --- tests/functional/openlp_core_utils/test_applocation.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_utils/test_applocation.py b/tests/functional/openlp_core_utils/test_applocation.py index d823b077c..23e7c008c 100644 --- a/tests/functional/openlp_core_utils/test_applocation.py +++ b/tests/functional/openlp_core_utils/test_applocation.py @@ -83,7 +83,10 @@ class TestAppLocation(TestCase): mocked_listdir.return_value = copy.deepcopy(FILE_LIST) # When: Get the list of files. - result = AppLocation.get_files(u'section', u'.mp3') + result = AppLocation.get_files(u'sectidon', u'.mp3') + + # Then: Check if the section parameter was used correctly. + mocked_listdir.assert_called_with(u'test/dir/section') # Then: check if the file lists are identical. assert result == [u'file5.mp3', u'file6.mp3'], u'The file lists should be identical.' From fe251f96a0e054f1b12b62a23b27f4287273ad9c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 1 Mar 2013 17:30:13 +0100 Subject: [PATCH 5/5] fixed test --- tests/functional/openlp_core_utils/test_applocation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_utils/test_applocation.py b/tests/functional/openlp_core_utils/test_applocation.py index 23e7c008c..5473da8c0 100644 --- a/tests/functional/openlp_core_utils/test_applocation.py +++ b/tests/functional/openlp_core_utils/test_applocation.py @@ -83,7 +83,7 @@ class TestAppLocation(TestCase): mocked_listdir.return_value = copy.deepcopy(FILE_LIST) # When: Get the list of files. - result = AppLocation.get_files(u'sectidon', u'.mp3') + result = AppLocation.get_files(u'section', u'.mp3') # Then: Check if the section parameter was used correctly. mocked_listdir.assert_called_with(u'test/dir/section')