From 8765b0045cf92cb4bb7125f044e575c11b5d6e2b Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Sat, 13 Jun 2020 21:36:38 +0200 Subject: [PATCH] Various alpha2 fixes * Fix BibleGateway integration. * Fix traceback when cloning song. * Fix traceback when running portable build. --- openlp/core/common/applocation.py | 6 +++++- openlp/plugins/bibles/lib/importers/http.py | 4 ++-- openlp/plugins/songs/lib/mediaitem.py | 1 + tests/functional/openlp_core/common/test_applocation.py | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/openlp/core/common/applocation.py b/openlp/core/common/applocation.py index 40c754d7e..ae3abbf2c 100644 --- a/openlp/core/common/applocation.py +++ b/openlp/core/common/applocation.py @@ -68,7 +68,11 @@ class AppLocation(object): path = get_frozen_path(FROZEN_APP_PATH, _get_os_dir_path(dir_type)) / 'i18n' else: path = _get_os_dir_path(dir_type) - return path + # resolve() does not work on windows + if is_win(): + return Path.cwd() / path + else: + return path.resolve() @staticmethod def get_data_path(): diff --git a/openlp/plugins/bibles/lib/importers/http.py b/openlp/plugins/bibles/lib/importers/http.py index 9d93a0e29..3bd132824 100644 --- a/openlp/plugins/bibles/lib/importers/http.py +++ b/openlp/plugins/bibles/lib/importers/http.py @@ -365,7 +365,7 @@ class BGExtract(RegistryProperties): for book in content: td_element = book.find('td', {'class': 'book-name'}) strings = [text for text in td_element.stripped_strings] - book_name = strings[0] + book_name = strings[2].strip() if book_name: books.append(book_name) return books @@ -381,7 +381,7 @@ class BGExtract(RegistryProperties): soup = get_soup_for_bible_ref(bible_url) if not soup: return None - bible_select = soup.find('select', {'class': 'search-translation-select'}) + bible_select = soup.find('select', {'class': 'search-dropdown'}) if not bible_select: log.debug('No select tags found - did site change?') return None diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index e6549eee2..d1ebacb7f 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -538,6 +538,7 @@ class SongMediaItem(MediaManagerItem): new_media_file.weight = media_file.weight new_song.media_files.append(new_media_file) self.plugin.manager.save_object(new_song) + new_song.init_on_load() self.on_song_list_load() def generate_slide_data(self, service_item, *, item=None, context=ServiceItemContext.Service, **kwargs): diff --git a/tests/functional/openlp_core/common/test_applocation.py b/tests/functional/openlp_core/common/test_applocation.py index 4b00cb234..2bc6e1245 100644 --- a/tests/functional/openlp_core/common/test_applocation.py +++ b/tests/functional/openlp_core/common/test_applocation.py @@ -138,7 +138,7 @@ def test_get_directory_for_app_dir(mocked_get_frozen_path): directory = AppLocation.get_directory(AppLocation.AppDir) # THEN: check that the correct directory is returned - assert directory == Path('app', 'dir'), 'Directory should be "app/dir"' + assert directory == Path.cwd() / Path('app', 'dir'), 'Directory should be "app/dir"' @patch('openlp.core.common.applocation.get_frozen_path') @@ -160,7 +160,7 @@ def test_get_directory_for_plugins_dir(mocked_sys, mocked_split, mocked_abspath, directory = AppLocation.get_directory(AppLocation.PluginsDir) # THEN: The correct directory should be returned - assert directory == Path('dir', 'plugins'), 'Directory should be "dir/plugins"' + assert directory == Path.cwd() / Path('dir', 'plugins'), 'Directory should be "dir/plugins"' @patch('openlp.core.common.sys')