From c8fd1b8338df423abcc1612824360dd71df3bae3 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 11 Jan 2016 22:13:57 +0100 Subject: [PATCH 01/17] Fix taking screenshots while using powerpoint or impress. Fixes: https://launchpad.net/bugs/1532938 --- openlp/core/ui/slidecontroller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index f93c52c06..359ae341f 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -1138,8 +1138,9 @@ class SlideController(DisplayController, RegistryProperties): Creates an image of the current screen and updates the preview frame. """ win_id = QtWidgets.QApplication.desktop().winId() + screen = QtWidgets.QApplication.primaryScreen() rect = self.screens.current['size'] - win_image = QtGui.QScreen.grabWindow(win_id, rect.x(), rect.y(), rect.width(), rect.height()) + win_image = screen.grabWindow(win_id, rect.x(), rect.y(),rect.width(), rect.height()) win_image.setDevicePixelRatio(self.slide_preview.devicePixelRatio()) self.slide_preview.setPixmap(win_image) self.slide_image = win_image From cf7630d3e3066827e21f38091295907e73f90845 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 12 Jan 2016 21:14:04 +0100 Subject: [PATCH 02/17] Fix crash when sending Pdf live. --- openlp/plugins/presentations/lib/messagelistener.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 0f33abeb9..d8af1dd6b 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -349,16 +349,17 @@ class MessageListener(object): # When presenting PDF/XPS/OXPS, we are using the image presentation code, # so handler & processor is set to None, and we skip adding the handler. self.handler = None - if self.handler == self.media_item.automatic: - self.handler = self.media_item.find_controller_by_type(file) - if not self.handler: - return else: - # the saved handler is not present so need to use one based on file suffix. - if not self.controllers[self.handler].available: + if self.handler == self.media_item.automatic: self.handler = self.media_item.find_controller_by_type(file) if not self.handler: return + else: + # the saved handler is not present so need to use one based on file suffix. + if not self.controllers[self.handler].available: + self.handler = self.media_item.find_controller_by_type(file) + if not self.handler: + return if is_live: controller = self.live_handler else: From e3d7e436f15fdd7f954a95c2391f5e6ebe4b4fdd Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 12 Jan 2016 21:17:15 +0100 Subject: [PATCH 03/17] In _process_item, postpone check for _reset_blank, since the service_item can change type while being execute (Pdf->Image). For the same reason always use the serviceitem that might have been converted. --- openlp/core/ui/slidecontroller.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 359ae341f..e00804530 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -828,13 +828,13 @@ class SlideController(DisplayController, RegistryProperties): self.selected_row = 0 # take a copy not a link to the servicemanager copy. self.service_item = copy.copy(service_item) + if self.service_item.is_command(): + Registry().execute( + '%s_start' % service_item.name.lower(), [self.service_item, self.is_live, self.hide_mode(), slide_no]) # Reset blanking if needed if old_item and self.is_live and (old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay) or self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay)): self._reset_blank(self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay)) - if service_item.is_command(): - Registry().execute( - '%s_start' % service_item.name.lower(), [self.service_item, self.is_live, self.hide_mode(), slide_no]) self.info_label.setText(self.service_item.title) self.slide_list = {} if self.is_live: @@ -886,28 +886,28 @@ class SlideController(DisplayController, RegistryProperties): self.service_item.bg_image_bytes = \ self.image_manager.get_image_bytes(frame['path'], ImageSource.ImagePlugin) self.preview_widget.replace_service_item(self.service_item, width, slide_no) - self.enable_tool_bar(service_item) + self.enable_tool_bar(self.service_item) # Pass to display for viewing. # Postpone image build, we need to do this later to avoid the theme # flashing on the screen if not self.service_item.is_image(): self.display.build_html(self.service_item) - if service_item.is_media(): - self.on_media_start(service_item) + if self.service_item.is_media(): + self.on_media_start(self.service_item) self.slide_selected(True) - if service_item.from_service: + if self.service_item.from_service: self.preview_widget.setFocus() if old_item: # Close the old item after the new one is opened # This avoids the service theme/desktop flashing on screen # However opening a new item of the same type will automatically # close the previous, so make sure we don't close the new one. - if old_item.is_command() and not service_item.is_command() or \ - old_item.is_command() and not old_item.is_media() and service_item.is_media(): + if old_item.is_command() and not self.service_item.is_command() or \ + old_item.is_command() and not old_item.is_media() and self.service_item.is_media(): Registry().execute('%s_stop' % old_item.name.lower(), [old_item, self.is_live]) - if old_item.is_media() and not service_item.is_media(): + if old_item.is_media() and not self.service_item.is_media(): self.on_media_close() - Registry().execute('slidecontroller_%s_started' % self.type_prefix, [service_item]) + Registry().execute('slidecontroller_%s_started' % self.type_prefix, [self.service_item]) def on_slide_selected_index(self, message): """ From 3f3078c33aa9721a1d82a93d185bdb0d00b857d1 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 12 Jan 2016 22:29:20 +0100 Subject: [PATCH 04/17] Fix traceback when expanding and collapsing songs. Fixes: https://launchpad.net/bugs/1532169 --- openlp/core/ui/servicemanager.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 0a81686b8..e4a1b143a 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1131,7 +1131,9 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa :param item: The service item to be checked """ pos = item.data(0, QtCore.Qt.UserRole) - self.service_items[pos - 1]['expanded'] = False + # Only set root items as collapsed, and since we only have 2 levels we find them by checking for children + if item.childCount(): + self.service_items[pos - 1]['expanded'] = False def on_expand_all(self, field=None): """ @@ -1149,7 +1151,9 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa :param item: The service item to be checked """ pos = item.data(0, QtCore.Qt.UserRole) - self.service_items[pos - 1]['expanded'] = True + # Only set root items as expanded, and since we only have 2 levels we find them by checking for children + if item.childCount(): + self.service_items[pos - 1]['expanded'] = True def on_service_top(self, field=None): """ From b1660c05256cab276dc4d869d30882977f3894d5 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Wed, 13 Jan 2016 21:56:55 +0100 Subject: [PATCH 05/17] Added test --- .../presentations/test_messagelistener.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/functional/openlp_plugins/presentations/test_messagelistener.py b/tests/functional/openlp_plugins/presentations/test_messagelistener.py index e4e85e29f..0997f643a 100644 --- a/tests/functional/openlp_plugins/presentations/test_messagelistener.py +++ b/tests/functional/openlp_plugins/presentations/test_messagelistener.py @@ -104,3 +104,23 @@ class TestMessageListener(TestCase, TestMixin): # THEN: The controllers will be setup. self.assertTrue(len(controllers), 'We have loaded a controller') + + @patch('openlp.plugins.presentations.lib.mediaitem.MessageListener._setup') + def start_pdf_presentation_test(self, media_mock): + """ + Test the startup of pdf presentation succeed. + """ + # GIVEN: A sservice item with a pdf + mock_item = MagicMock() + mock_item.processor = 'Pdf' + mock_item.get_frame_path.return_value = "test.pdf" + self.media_item.generate_slide_data = MagicMock() + ml = MessageListener(self.media_item) + ml.media_item = self.media_item + ml.preview_handler = MagicMock() + + # WHEN: request the presentation to start + ml.startup([mock_item, False, False, False]) + + # THEN: The handler should be set to None + self.assertIsNone(ml.handler, 'The handler should be None') From e91520fa604b3509aabbca92d4ea2ca22ad18efd Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Wed, 13 Jan 2016 22:00:46 +0100 Subject: [PATCH 06/17] pep8 fixes --- openlp/core/ui/slidecontroller.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 6 +++--- tests/functional/openlp_core_lib/test_htmlbuilder.py | 3 +-- tests/functional/openlp_core_ui/test_mainwindow.py | 2 -- tests/resources/projector/data.py | 1 - 6 files changed, 6 insertions(+), 10 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index e00804530..37c4836b9 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -1140,7 +1140,7 @@ class SlideController(DisplayController, RegistryProperties): win_id = QtWidgets.QApplication.desktop().winId() screen = QtWidgets.QApplication.primaryScreen() rect = self.screens.current['size'] - win_image = screen.grabWindow(win_id, rect.x(), rect.y(),rect.width(), rect.height()) + win_image = screen.grabWindow(win_id, rect.x(), rect.y(), rect.width(), rect.height()) win_image.setDevicePixelRatio(self.slide_preview.devicePixelRatio()) self.slide_preview.setPixmap(win_image) self.slide_image = win_image diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 33b106aa0..4bc77c65c 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -515,7 +515,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): self.topics_list_view.addItem(topic_name) self.songbooks_list_view.clear() for songbook_entry in self.song.songbook_entries: - self.add_songbook_entry_to_list(songbook_entry.songbook.id, songbook_entry.songbook.name, + self.add_songbook_entry_to_list(songbook_entry.songbook.id, songbook_entry.songbook.name, songbook_entry.entry) self.audio_list_widget.clear() for media in self.song.media_files: diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index dfa967e22..82a2d6085 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -255,9 +255,9 @@ class SongMediaItem(MediaManagerItem): search_entry = re.sub(r'[^0-9]', '', search_keywords[2]) songbook_entries = (self.plugin.manager.session.query(SongBookEntry) - .join(Book) - .order_by(Book.name) - .order_by(SongBookEntry.entry)) + .join(Book) + .order_by(Book.name) + .order_by(SongBookEntry.entry)) for songbook_entry in songbook_entries: if songbook_entry.song.temporary: continue diff --git a/tests/functional/openlp_core_lib/test_htmlbuilder.py b/tests/functional/openlp_core_lib/test_htmlbuilder.py index 181c485f5..8ca98060d 100644 --- a/tests/functional/openlp_core_lib/test_htmlbuilder.py +++ b/tests/functional/openlp_core_lib/test_htmlbuilder.py @@ -363,9 +363,8 @@ class Htmbuilder(TestCase, TestMixin): """ Test the webkit_version() function """ - # GIVEN: Webkit + # GIVEN: Webkit webkit_ver = float(QtWebKit.qWebKitVersion()) # WHEN: Retrieving the webkit version # THEN: Webkit versions should match self.assertEquals(webkit_version(), webkit_ver, "The returned webkit version doesn't match the installed one") - diff --git a/tests/functional/openlp_core_ui/test_mainwindow.py b/tests/functional/openlp_core_ui/test_mainwindow.py index 5499a78a7..a49ded25c 100644 --- a/tests/functional/openlp_core_ui/test_mainwindow.py +++ b/tests/functional/openlp_core_ui/test_mainwindow.py @@ -189,5 +189,3 @@ class TestMainWindow(TestCase, TestMixin): # THEN: The media manager dock is made visible self.assertEqual(0, mocked_media_manager_dock.setVisible.call_count) mocked_widget.on_focus.assert_called_with() - - diff --git a/tests/resources/projector/data.py b/tests/resources/projector/data.py index fca9c0ca0..00d150cf2 100644 --- a/tests/resources/projector/data.py +++ b/tests/resources/projector/data.py @@ -59,4 +59,3 @@ TEST3_DATA = dict(ip='333.333.333.333', name='___TEST_THREE___', location='location three', notes='notes three') - From 9e8fe903a7b195af3bff5281f56b0ca6f96da83f Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 14 Jan 2016 22:25:58 +0200 Subject: [PATCH 07/17] attempt to fix some tests in windows --- tests/functional/openlp_core_utils/test_db.py | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/tests/functional/openlp_core_utils/test_db.py b/tests/functional/openlp_core_utils/test_db.py index 01ed9d0d5..b46e97a80 100644 --- a/tests/functional/openlp_core_utils/test_db.py +++ b/tests/functional/openlp_core_utils/test_db.py @@ -40,11 +40,18 @@ class TestUtilsDBFunctions(TestCase): Create temp folder for keeping db file """ self.tmp_folder = mkdtemp() + db_path = os.path.join(TEST_RESOURCES_PATH, 'songs', 'songs-1.9.7.sqlite') + db_tmp_path = os.path.join(self.tmp_folder, 'songs-1.9.7.sqlite') + shutil.copyfile(db_path, db_tmp_path) + db_url = 'sqlite:///' + db_tmp_path + self.session, metadata = init_db(db_url) + self.op = get_upgrade_op(self.session) def tearDown(self): """ Clean up """ + self.session.close() shutil.rmtree(self.tmp_folder) def delete_column_test(self): @@ -52,18 +59,12 @@ class TestUtilsDBFunctions(TestCase): Test deleting a single column in a table """ # GIVEN: A temporary song db - db_path = os.path.join(TEST_RESOURCES_PATH, 'songs', 'songs-1.9.7.sqlite') - db_tmp_path = os.path.join(self.tmp_folder, 'songs-1.9.7.sqlite') - shutil.copyfile(db_path, db_tmp_path) - db_url = 'sqlite:///' + db_tmp_path - session, metadata = init_db(db_url) - op = get_upgrade_op(session) # WHEN: Deleting a columns in a table - drop_column(op, 'songs', 'song_book_id') + drop_column(self.op, 'songs', 'song_book_id') # THEN: The column should have been deleted - meta = sqlalchemy.MetaData(bind=op.get_bind()) + meta = sqlalchemy.MetaData(bind=self.op.get_bind()) meta.reflect() columns = meta.tables['songs'].columns @@ -76,21 +77,16 @@ class TestUtilsDBFunctions(TestCase): Test deleting multiple columns in a table """ # GIVEN: A temporary song db - db_path = os.path.join(TEST_RESOURCES_PATH, 'songs', 'songs-1.9.7.sqlite') - db_tmp_path = os.path.join(self.tmp_folder, 'songs-1.9.7.sqlite') - shutil.copyfile(db_path, db_tmp_path) - db_url = 'sqlite:///' + db_tmp_path - session, metadata = init_db(db_url) - op = get_upgrade_op(session) # WHEN: Deleting a columns in a table - drop_columns(op, 'songs', ['song_book_id', 'song_number']) + drop_columns(self.op, 'songs', ['song_book_id', 'song_number']) # THEN: The columns should have been deleted - meta = sqlalchemy.MetaData(bind=op.get_bind()) + meta = sqlalchemy.MetaData(bind=self.op.get_bind()) meta.reflect() columns = meta.tables['songs'].columns for column in columns: if column.name == 'song_book_id' or column.name == 'song_number': self.fail("The column '%s' should have been deleted." % column.name) + From 11b7bfd22d0325386bbe05cf59aed5f9ab467e8f Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 14 Jan 2016 22:31:37 +0200 Subject: [PATCH 08/17] See if waiting a second helps --- tests/functional/openlp_core_utils/test_db.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/functional/openlp_core_utils/test_db.py b/tests/functional/openlp_core_utils/test_db.py index b46e97a80..5968536f6 100644 --- a/tests/functional/openlp_core_utils/test_db.py +++ b/tests/functional/openlp_core_utils/test_db.py @@ -27,6 +27,7 @@ import shutil import sqlalchemy from unittest import TestCase from tempfile import mkdtemp +import time from openlp.core.utils.db import drop_column, drop_columns from openlp.core.lib.db import init_db, get_upgrade_op @@ -52,6 +53,7 @@ class TestUtilsDBFunctions(TestCase): Clean up """ self.session.close() + time.sleep(1) shutil.rmtree(self.tmp_folder) def delete_column_test(self): From 402917024bc8766d6a8f627d97b197d978243ee4 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 15 Jan 2016 19:11:02 +0200 Subject: [PATCH 09/17] Another go at this --- tests/functional/openlp_core_utils/test_db.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/openlp_core_utils/test_db.py b/tests/functional/openlp_core_utils/test_db.py index 5968536f6..baeb195e0 100644 --- a/tests/functional/openlp_core_utils/test_db.py +++ b/tests/functional/openlp_core_utils/test_db.py @@ -53,6 +53,7 @@ class TestUtilsDBFunctions(TestCase): Clean up """ self.session.close() + self.session = None time.sleep(1) shutil.rmtree(self.tmp_folder) From d7b9e2cbe519d18bc08c24ab1d9e8e611604fd59 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 15 Jan 2016 19:50:57 +0200 Subject: [PATCH 10/17] Try deleting the file itself after telling Python to do garbage collection --- tests/functional/openlp_core_utils/test_db.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/functional/openlp_core_utils/test_db.py b/tests/functional/openlp_core_utils/test_db.py index baeb195e0..b3ebafd89 100644 --- a/tests/functional/openlp_core_utils/test_db.py +++ b/tests/functional/openlp_core_utils/test_db.py @@ -22,15 +22,17 @@ """ Package to test the openlp.core.utils.db package. """ +from tempfile import mkdtemp +from unittest import TestCase +import gc import os import shutil import sqlalchemy -from unittest import TestCase -from tempfile import mkdtemp import time from openlp.core.utils.db import drop_column, drop_columns from openlp.core.lib.db import init_db, get_upgrade_op + from tests.utils.constants import TEST_RESOURCES_PATH @@ -42,9 +44,9 @@ class TestUtilsDBFunctions(TestCase): """ self.tmp_folder = mkdtemp() db_path = os.path.join(TEST_RESOURCES_PATH, 'songs', 'songs-1.9.7.sqlite') - db_tmp_path = os.path.join(self.tmp_folder, 'songs-1.9.7.sqlite') - shutil.copyfile(db_path, db_tmp_path) - db_url = 'sqlite:///' + db_tmp_path + self.db_tmp_path = os.path.join(self.tmp_folder, 'songs-1.9.7.sqlite') + shutil.copyfile(db_path, self.db_tmp_path) + db_url = 'sqlite:///' + self.db_tmp_path self.session, metadata = init_db(db_url) self.op = get_upgrade_op(self.session) @@ -54,7 +56,9 @@ class TestUtilsDBFunctions(TestCase): """ self.session.close() self.session = None + gc.collect() time.sleep(1) + os.unlink(self.db_tmp_path) shutil.rmtree(self.tmp_folder) def delete_column_test(self): From b11b88f4eb4079c2f13e65c82f25c4dcc3866f57 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 15 Jan 2016 19:58:21 +0200 Subject: [PATCH 11/17] Add a retry mechanism --- tests/functional/openlp_core_utils/test_db.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/functional/openlp_core_utils/test_db.py b/tests/functional/openlp_core_utils/test_db.py index b3ebafd89..6575f4875 100644 --- a/tests/functional/openlp_core_utils/test_db.py +++ b/tests/functional/openlp_core_utils/test_db.py @@ -57,8 +57,14 @@ class TestUtilsDBFunctions(TestCase): self.session.close() self.session = None gc.collect() - time.sleep(1) - os.unlink(self.db_tmp_path) + retries = 0 + while retries < 5: + try: + os.unlink(self.db_tmp_path) + break + except: + time.sleep(1) + retries += 1 shutil.rmtree(self.tmp_folder) def delete_column_test(self): From e1ed3ab1637e8c80240c0f797ac5ee04030f509a Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 15 Jan 2016 20:10:09 +0200 Subject: [PATCH 12/17] Use rmtree in the retry mechanism --- tests/functional/openlp_core_utils/test_db.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/functional/openlp_core_utils/test_db.py b/tests/functional/openlp_core_utils/test_db.py index 6575f4875..1e84325e3 100644 --- a/tests/functional/openlp_core_utils/test_db.py +++ b/tests/functional/openlp_core_utils/test_db.py @@ -60,12 +60,13 @@ class TestUtilsDBFunctions(TestCase): retries = 0 while retries < 5: try: - os.unlink(self.db_tmp_path) + shutil.rmtree(self.tmp_folder) + # os.unlink(self.db_tmp_path) break - except: + except Exception as e: time.sleep(1) retries += 1 - shutil.rmtree(self.tmp_folder) + print(e) def delete_column_test(self): """ From 5d21aab53959228ead11c84196e60bf3dc437520 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 15 Jan 2016 20:31:05 +0200 Subject: [PATCH 13/17] Make pep8 happy --- openlp/plugins/songs/forms/editsongform.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 6 +++--- tests/functional/openlp_core_lib/test_htmlbuilder.py | 3 +-- tests/functional/openlp_core_ui/test_mainwindow.py | 1 - tests/functional/openlp_core_utils/test_db.py | 1 - tests/resources/projector/data.py | 1 - 6 files changed, 5 insertions(+), 9 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 33b106aa0..4bc77c65c 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -515,7 +515,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): self.topics_list_view.addItem(topic_name) self.songbooks_list_view.clear() for songbook_entry in self.song.songbook_entries: - self.add_songbook_entry_to_list(songbook_entry.songbook.id, songbook_entry.songbook.name, + self.add_songbook_entry_to_list(songbook_entry.songbook.id, songbook_entry.songbook.name, songbook_entry.entry) self.audio_list_widget.clear() for media in self.song.media_files: diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index dfa967e22..82a2d6085 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -255,9 +255,9 @@ class SongMediaItem(MediaManagerItem): search_entry = re.sub(r'[^0-9]', '', search_keywords[2]) songbook_entries = (self.plugin.manager.session.query(SongBookEntry) - .join(Book) - .order_by(Book.name) - .order_by(SongBookEntry.entry)) + .join(Book) + .order_by(Book.name) + .order_by(SongBookEntry.entry)) for songbook_entry in songbook_entries: if songbook_entry.song.temporary: continue diff --git a/tests/functional/openlp_core_lib/test_htmlbuilder.py b/tests/functional/openlp_core_lib/test_htmlbuilder.py index 181c485f5..8ca98060d 100644 --- a/tests/functional/openlp_core_lib/test_htmlbuilder.py +++ b/tests/functional/openlp_core_lib/test_htmlbuilder.py @@ -363,9 +363,8 @@ class Htmbuilder(TestCase, TestMixin): """ Test the webkit_version() function """ - # GIVEN: Webkit + # GIVEN: Webkit webkit_ver = float(QtWebKit.qWebKitVersion()) # WHEN: Retrieving the webkit version # THEN: Webkit versions should match self.assertEquals(webkit_version(), webkit_ver, "The returned webkit version doesn't match the installed one") - diff --git a/tests/functional/openlp_core_ui/test_mainwindow.py b/tests/functional/openlp_core_ui/test_mainwindow.py index 5499a78a7..ba290b865 100644 --- a/tests/functional/openlp_core_ui/test_mainwindow.py +++ b/tests/functional/openlp_core_ui/test_mainwindow.py @@ -190,4 +190,3 @@ class TestMainWindow(TestCase, TestMixin): self.assertEqual(0, mocked_media_manager_dock.setVisible.call_count) mocked_widget.on_focus.assert_called_with() - diff --git a/tests/functional/openlp_core_utils/test_db.py b/tests/functional/openlp_core_utils/test_db.py index 1e84325e3..7ac3c1440 100644 --- a/tests/functional/openlp_core_utils/test_db.py +++ b/tests/functional/openlp_core_utils/test_db.py @@ -103,4 +103,3 @@ class TestUtilsDBFunctions(TestCase): for column in columns: if column.name == 'song_book_id' or column.name == 'song_number': self.fail("The column '%s' should have been deleted." % column.name) - diff --git a/tests/resources/projector/data.py b/tests/resources/projector/data.py index fca9c0ca0..00d150cf2 100644 --- a/tests/resources/projector/data.py +++ b/tests/resources/projector/data.py @@ -59,4 +59,3 @@ TEST3_DATA = dict(ip='333.333.333.333', name='___TEST_THREE___', location='location three', notes='notes three') - From 1e8d787b93b0a816f7d5444c4644858ac12484f8 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 15 Jan 2016 20:37:03 +0200 Subject: [PATCH 14/17] Make pep8 happy --- tests/functional/openlp_core_ui/test_mainwindow.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/functional/openlp_core_ui/test_mainwindow.py b/tests/functional/openlp_core_ui/test_mainwindow.py index ba290b865..a49ded25c 100644 --- a/tests/functional/openlp_core_ui/test_mainwindow.py +++ b/tests/functional/openlp_core_ui/test_mainwindow.py @@ -189,4 +189,3 @@ class TestMainWindow(TestCase, TestMixin): # THEN: The media manager dock is made visible self.assertEqual(0, mocked_media_manager_dock.setVisible.call_count) mocked_widget.on_focus.assert_called_with() - From 48eeb50d0291f689abd44b1820d5a406f926543b Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 15 Jan 2016 21:14:24 +0200 Subject: [PATCH 15/17] Add retries around other db removals --- tests/functional/openlp_core_lib/test_projectordb.py | 10 ++++++++-- tests/functional/openlp_core_utils/test_db.py | 7 +++---- .../openlp_core_ui/test_projectorsourceform.py | 10 ++++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_projectordb.py b/tests/functional/openlp_core_lib/test_projectordb.py index 58eff13bc..8243292d0 100644 --- a/tests/functional/openlp_core_lib/test_projectordb.py +++ b/tests/functional/openlp_core_lib/test_projectordb.py @@ -87,8 +87,6 @@ class TestProjectorDB(TestCase): Set up anything necessary for all tests """ with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url: - if os.path.exists(TEST_DB): - os.unlink(TEST_DB) mocked_init_url.return_value = 'sqlite:///%s' % TEST_DB self.projector = ProjectorDB() @@ -98,6 +96,14 @@ class TestProjectorDB(TestCase): """ self.projector.session.close() self.projector = None + while retries < 5: + try: + if os.path.exists(TEST_DB): + os.unlink(TEST_DB) + break + except: + time.sleep(1) + retries += 1 def find_record_by_ip_test(self): """ diff --git a/tests/functional/openlp_core_utils/test_db.py b/tests/functional/openlp_core_utils/test_db.py index 7ac3c1440..f2c3d264a 100644 --- a/tests/functional/openlp_core_utils/test_db.py +++ b/tests/functional/openlp_core_utils/test_db.py @@ -60,13 +60,12 @@ class TestUtilsDBFunctions(TestCase): retries = 0 while retries < 5: try: - shutil.rmtree(self.tmp_folder) - # os.unlink(self.db_tmp_path) + if os.path.exists(self.tmp_folder): + shutil.rmtree(self.tmp_folder) break - except Exception as e: + except: time.sleep(1) retries += 1 - print(e) def delete_column_test(self): """ diff --git a/tests/interfaces/openlp_core_ui/test_projectorsourceform.py b/tests/interfaces/openlp_core_ui/test_projectorsourceform.py index b4951e910..3b08db149 100644 --- a/tests/interfaces/openlp_core_ui/test_projectorsourceform.py +++ b/tests/interfaces/openlp_core_ui/test_projectorsourceform.py @@ -65,8 +65,6 @@ class ProjectorSourceFormTest(TestCase, TestMixin): """ Set up anything necessary for all tests """ - if os.path.exists(TEST_DB): - os.unlink(TEST_DB) mocked_init_url.return_value = 'sqlite:///{}'.format(TEST_DB) self.build_settings() self.setup_application() @@ -90,6 +88,14 @@ class ProjectorSourceFormTest(TestCase, TestMixin): self.projectordb.session.close() del(self.projectordb) del(self.projector) + while retries < 5: + try: + if os.path.exists(TEST_DB): + os.unlink(TEST_DB) + break + except: + time.sleep(1) + retries += 1 self.destroy_settings() def source_dict_test(self): From 478d356d2e0ba21aa586537df2d537c82ea52f83 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 15 Jan 2016 21:41:14 +0200 Subject: [PATCH 16/17] Oops, forgot a variable --- tests/functional/openlp_core_lib/test_projectordb.py | 1 + tests/interfaces/openlp_core_ui/test_projectorsourceform.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/functional/openlp_core_lib/test_projectordb.py b/tests/functional/openlp_core_lib/test_projectordb.py index 8243292d0..7a8a57d19 100644 --- a/tests/functional/openlp_core_lib/test_projectordb.py +++ b/tests/functional/openlp_core_lib/test_projectordb.py @@ -96,6 +96,7 @@ class TestProjectorDB(TestCase): """ self.projector.session.close() self.projector = None + retries = 0 while retries < 5: try: if os.path.exists(TEST_DB): diff --git a/tests/interfaces/openlp_core_ui/test_projectorsourceform.py b/tests/interfaces/openlp_core_ui/test_projectorsourceform.py index 3b08db149..93aeb4c0a 100644 --- a/tests/interfaces/openlp_core_ui/test_projectorsourceform.py +++ b/tests/interfaces/openlp_core_ui/test_projectorsourceform.py @@ -88,6 +88,7 @@ class ProjectorSourceFormTest(TestCase, TestMixin): self.projectordb.session.close() del(self.projectordb) del(self.projector) + retries = 0 while retries < 5: try: if os.path.exists(TEST_DB): From ddfed93fbe05f886cbe373aa5f3d7c7e82021c50 Mon Sep 17 00:00:00 2001 From: "s.mehrbrodt@gmail.com" Date: Sat, 16 Jan 2016 22:13:41 +0200 Subject: [PATCH 17/17] "* Fix importing older song dbs by migrating them first * Fix comparing songs without title lp:~sam92/openlp/bug-1533081 (revision 2615) [SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1260/ [SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1184/ [SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1123/ [FAILURE] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/959/ Stopping after failure" bzr-revno: 2609 Fixes: https://launchpad.net/bugs/1533081, https://launchpad.net/bugs/1534306 --- openlp/core/__init__.py | 8 ++++---- openlp/core/ui/generaltab.py | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 196317b06..50a1ab9b6 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -153,10 +153,10 @@ class OpenLP(OpenLPMixin, QtWidgets.QApplication): self.processEvents() if not has_run_wizard: self.main_window.first_time() - update_check = Settings().value('core/update check') - if update_check: - version = VersionThread(self.main_window) - version.start() + # update_check = Settings().value('core/update check') + # if update_check: + # version = VersionThread(self.main_window) + # version.start() self.main_window.is_display_blank() self.main_window.app_startup() return self.exec() diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 28f2b0362..8ed8b3edf 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -159,6 +159,7 @@ class GeneralTab(SettingsTab): self.startup_layout.addWidget(self.show_splash_check_box) self.check_for_updates_check_box = QtWidgets.QCheckBox(self.startup_group_box) self.check_for_updates_check_box.setObjectName('check_for_updates_check_box') + self.check_for_updates_check_box.setVisible(False) self.startup_layout.addWidget(self.check_for_updates_check_box) self.right_layout.addWidget(self.startup_group_box) # Application Settings