Merge lp:~tomasgroth/openlp/bugfixes12 into lp:openlp

Proposed by Tomas Groth
Status: Merged
Approved by: Raoul Snyman
Approved revision: 2497
Merged at revision: 2495
Proposed branch: lp:~tomasgroth/openlp/bugfixes12
Merge into: lp:openlp
Diff against target: 214 lines (+77/-7)
8 files modified
openlp/core/ui/firsttimeform.py (+13/-0)
openlp/core/ui/firsttimewizard.py (+4/-1)
openlp/plugins/bibles/lib/__init__.py (+3/-3)
openlp/plugins/presentations/lib/mediaitem.py (+1/-1)
openlp/plugins/songs/lib/importers/presentationmanager.py (+15/-2)
tests/functional/openlp_plugins/songs/test_presentationmanagerimport.py (+2/-0)
tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py (+10/-0)
tests/resources/presentationmanagersongs/Amazing Grace.json (+29/-0)
To merge this branch: bzr merge lp:~tomasgroth/openlp/bugfixes12
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tim Bentley Approve
Review via email: mp+248175@code.launchpad.net

Description of the change

Make xml parsing of presentation manager files recover if errors are encountered. Fixes bug 1414980.
Set the cursor back to normal after deleting a presentation. Fixes bug 1414978.
Added a cancel-button to FTW when no internet is available. Fixes bug 1410738
Fix support for 'end' mark in bible-search. Fixes bug 1412517.

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) wrote :
Revision history for this message
Tim Bentley (trb143) :
review: Approve
Revision history for this message
Tim Bentley (trb143) wrote :

Sorry just merged a fix and phil had fixed a fix you are doing!

review: Needs Fixing
Revision history for this message
Tomas Groth (tomasgroth) wrote :

> Sorry just merged a fix and phil had fixed a fix you are doing!
I don't see any conflicts...?
I think both fixed the same pep8 issue, shouldn't be an problem.

Revision history for this message
Tim Bentley (trb143) :
review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/core/ui/firsttimeform.py'
--- openlp/core/ui/firsttimeform.py 2015-01-20 21:38:34 +0000
+++ openlp/core/ui/firsttimeform.py 2015-01-30 21:59:49 +0000
@@ -268,9 +268,11 @@
268 self.web = 'http://openlp.org/files/frw/'268 self.web = 'http://openlp.org/files/frw/'
269 self.cancel_button.clicked.connect(self.on_cancel_button_clicked)269 self.cancel_button.clicked.connect(self.on_cancel_button_clicked)
270 self.no_internet_finish_button.clicked.connect(self.on_no_internet_finish_button_clicked)270 self.no_internet_finish_button.clicked.connect(self.on_no_internet_finish_button_clicked)
271 self.no_internet_cancel_button.clicked.connect(self.on_no_internet_cancel_button_clicked)
271 self.currentIdChanged.connect(self.on_current_id_changed)272 self.currentIdChanged.connect(self.on_current_id_changed)
272 Registry().register_function('config_screen_changed', self.update_screen_list_combo)273 Registry().register_function('config_screen_changed', self.update_screen_list_combo)
273 self.no_internet_finish_button.setVisible(False)274 self.no_internet_finish_button.setVisible(False)
275 self.no_internet_cancel_button.setVisible(False)
274 # Check if this is a re-run of the wizard.276 # Check if this is a re-run of the wizard.
275 self.has_run_wizard = Settings().value('core/has run wizard')277 self.has_run_wizard = Settings().value('core/has run wizard')
276 check_directory_exists(os.path.join(gettempdir(), 'openlp'))278 check_directory_exists(os.path.join(gettempdir(), 'openlp'))
@@ -327,6 +329,10 @@
327 self.next_button.setVisible(False)329 self.next_button.setVisible(False)
328 self.cancel_button.setVisible(False)330 self.cancel_button.setVisible(False)
329 self.no_internet_finish_button.setVisible(True)331 self.no_internet_finish_button.setVisible(True)
332 if self.has_run_wizard:
333 self.no_internet_cancel_button.setVisible(False)
334 else:
335 self.no_internet_cancel_button.setVisible(True)
330 elif page_id == FirstTimePage.Plugins:336 elif page_id == FirstTimePage.Plugins:
331 self.back_button.setVisible(False)337 self.back_button.setVisible(False)
332 elif page_id == FirstTimePage.Progress:338 elif page_id == FirstTimePage.Progress:
@@ -372,6 +378,13 @@
372 Settings().setValue('core/has run wizard', True)378 Settings().setValue('core/has run wizard', True)
373 self.close()379 self.close()
374380
381 def on_no_internet_cancel_button_clicked(self):
382 """
383 Process the triggering of the "Cancel" button on the No Internet page.
384 """
385 self.was_cancelled = True
386 self.close()
387
375 def url_get_file(self, url, f_path):388 def url_get_file(self, url, f_path):
376 """"389 """"
377 Download a file given a URL. The file is retrieved in chunks, giving the ability to cancel the download at any390 Download a file given a URL. The file is retrieved in chunks, giving the ability to cancel the download at any
378391
=== modified file 'openlp/core/ui/firsttimewizard.py'
--- openlp/core/ui/firsttimewizard.py 2015-01-18 13:39:21 +0000
+++ openlp/core/ui/firsttimewizard.py 2015-01-30 21:59:49 +0000
@@ -59,7 +59,8 @@
59 first_time_wizard.resize(550, 386)59 first_time_wizard.resize(550, 386)
60 first_time_wizard.setModal(True)60 first_time_wizard.setModal(True)
61 first_time_wizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage |61 first_time_wizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage |
62 QtGui.QWizard.NoBackButtonOnLastPage | QtGui.QWizard.HaveCustomButton1)62 QtGui.QWizard.NoBackButtonOnLastPage | QtGui.QWizard.HaveCustomButton1 |
63 QtGui.QWizard.HaveCustomButton2)
63 if is_macosx():64 if is_macosx():
64 first_time_wizard.setPixmap(QtGui.QWizard.BackgroundPixmap,65 first_time_wizard.setPixmap(QtGui.QWizard.BackgroundPixmap,
65 QtGui.QPixmap(':/wizards/openlp-osx-wizard.png'))66 QtGui.QPixmap(':/wizards/openlp-osx-wizard.png'))
@@ -69,6 +70,7 @@
69 self.finish_button = self.button(QtGui.QWizard.FinishButton)70 self.finish_button = self.button(QtGui.QWizard.FinishButton)
70 self.no_internet_finish_button = self.button(QtGui.QWizard.CustomButton1)71 self.no_internet_finish_button = self.button(QtGui.QWizard.CustomButton1)
71 self.cancel_button = self.button(QtGui.QWizard.CancelButton)72 self.cancel_button = self.button(QtGui.QWizard.CancelButton)
73 self.no_internet_cancel_button = self.button(QtGui.QWizard.CustomButton2)
72 self.next_button = self.button(QtGui.QWizard.NextButton)74 self.next_button = self.button(QtGui.QWizard.NextButton)
73 self.back_button = self.button(QtGui.QWizard.BackButton)75 self.back_button = self.button(QtGui.QWizard.BackButton)
74 add_welcome_page(first_time_wizard, ':/wizards/wizard_firsttime.bmp')76 add_welcome_page(first_time_wizard, ':/wizards/wizard_firsttime.bmp')
@@ -271,3 +273,4 @@
271 'and OpenLP is configured.'))273 'and OpenLP is configured.'))
272 self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Starting configuration process...'))274 self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Starting configuration process...'))
273 first_time_wizard.setButtonText(QtGui.QWizard.CustomButton1, translate('OpenLP.FirstTimeWizard', 'Finish'))275 first_time_wizard.setButtonText(QtGui.QWizard.CustomButton1, translate('OpenLP.FirstTimeWizard', 'Finish'))
276 first_time_wizard.setButtonText(QtGui.QWizard.CustomButton2, translate('OpenLP.FirstTimeWizard', 'Cancel'))
274277
=== modified file 'openlp/plugins/bibles/lib/__init__.py'
--- openlp/plugins/bibles/lib/__init__.py 2015-01-22 13:19:10 +0000
+++ openlp/plugins/bibles/lib/__init__.py 2015-01-30 21:59:49 +0000
@@ -178,7 +178,7 @@
178 default_separators = [178 default_separators = [
179 '|'.join([179 '|'.join([
180 translate('BiblesPlugin', ':', 'Verse identifier e.g. Genesis 1 : 1 = Genesis Chapter 1 Verse 1'),180 translate('BiblesPlugin', ':', 'Verse identifier e.g. Genesis 1 : 1 = Genesis Chapter 1 Verse 1'),
181 translate('BiblesPlugin', 'v','Verse identifier e.g. Genesis 1 v 1 = Genesis Chapter 1 Verse 1'),181 translate('BiblesPlugin', 'v', 'Verse identifier e.g. Genesis 1 v 1 = Genesis Chapter 1 Verse 1'),
182 translate('BiblesPlugin', 'V', 'Verse identifier e.g. Genesis 1 V 1 = Genesis Chapter 1 Verse 1'),182 translate('BiblesPlugin', 'V', 'Verse identifier e.g. Genesis 1 V 1 = Genesis Chapter 1 Verse 1'),
183 translate('BiblesPlugin', 'verse', 'Verse identifier e.g. Genesis 1 verse 1 = Genesis Chapter 1 Verse 1'),183 translate('BiblesPlugin', 'verse', 'Verse identifier e.g. Genesis 1 verse 1 = Genesis Chapter 1 Verse 1'),
184 translate('BiblesPlugin', 'verses',184 translate('BiblesPlugin', 'verses',
@@ -371,7 +371,7 @@
371 from_chapter = from_verse371 from_chapter = from_verse
372 from_verse = None372 from_verse = None
373 if to_chapter:373 if to_chapter:
374 if to_chapter < from_chapter:374 if from_chapter and to_chapter < from_chapter:
375 continue375 continue
376 else:376 else:
377 chapter = to_chapter377 chapter = to_chapter
@@ -387,7 +387,7 @@
387 from_verse = 1387 from_verse = 1
388 if not to_verse:388 if not to_verse:
389 to_verse = -1389 to_verse = -1
390 if to_chapter > from_chapter:390 if to_chapter and to_chapter > from_chapter:
391 ref_list.append((book_ref_id, from_chapter, from_verse, -1))391 ref_list.append((book_ref_id, from_chapter, from_verse, -1))
392 for i in range(from_chapter + 1, to_chapter):392 for i in range(from_chapter + 1, to_chapter):
393 ref_list.append((book_ref_id, i, 1, -1))393 ref_list.append((book_ref_id, i, 1, -1))
394394
=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py 2015-01-22 18:01:54 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py 2015-01-30 21:59:49 +0000
@@ -225,10 +225,10 @@
225 self.clean_up_thumbnails(filepath)225 self.clean_up_thumbnails(filepath)
226 self.main_window.increment_progress_bar()226 self.main_window.increment_progress_bar()
227 self.main_window.finished_progress_bar()227 self.main_window.finished_progress_bar()
228 self.application.set_busy_cursor()
229 for row in row_list:228 for row in row_list:
230 self.list_view.takeItem(row)229 self.list_view.takeItem(row)
231 Settings().setValue(self.settings_section + '/presentations files', self.get_file_list())230 Settings().setValue(self.settings_section + '/presentations files', self.get_file_list())
231 self.application.set_normal_cursor()
232232
233 def clean_up_thumbnails(self, filepath):233 def clean_up_thumbnails(self, filepath):
234 """234 """
235235
=== modified file 'openlp/plugins/songs/lib/importers/presentationmanager.py'
--- openlp/plugins/songs/lib/importers/presentationmanager.py 2015-01-22 17:42:29 +0000
+++ openlp/plugins/songs/lib/importers/presentationmanager.py 2015-01-30 21:59:49 +0000
@@ -25,7 +25,9 @@
25"""25"""
2626
27import os27import os
28from lxml import objectify28import re
29import chardet
30from lxml import objectify, etree
2931
30from openlp.core.ui.wizard import WizardStrings32from openlp.core.ui.wizard import WizardStrings
31from .songimport import SongImport33from .songimport import SongImport
@@ -42,7 +44,18 @@
42 if self.stop_import_flag:44 if self.stop_import_flag:
43 return45 return
44 self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % os.path.basename(file_path))46 self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % os.path.basename(file_path))
45 root = objectify.parse(open(file_path, 'rb')).getroot()47 try:
48 tree = etree.parse(file_path, parser=etree.XMLParser(recover=True))
49 except etree.XMLSyntaxError:
50 # Try to detect encoding and use it
51 file = open(file_path, mode='rb')
52 encoding = chardet.detect(file.read())['encoding']
53 file.close()
54 # Open file with detected encoding and remove encoding declaration
55 text = open(file_path, mode='r', encoding=encoding).read()
56 text = re.sub('.+\?>\n', '', text)
57 tree = etree.fromstring(text, parser=etree.XMLParser(recover=True))
58 root = objectify.fromstring(etree.tostring(tree))
46 self.process_song(root)59 self.process_song(root)
4760
48 def process_song(self, root):61 def process_song(self, root):
4962
=== modified file 'tests/functional/openlp_plugins/songs/test_presentationmanagerimport.py'
--- tests/functional/openlp_plugins/songs/test_presentationmanagerimport.py 2015-01-18 13:39:21 +0000
+++ tests/functional/openlp_plugins/songs/test_presentationmanagerimport.py 2015-01-30 21:59:49 +0000
@@ -46,3 +46,5 @@
46 self.load_external_result_data(os.path.join(TEST_PATH, 'Great Is Thy Faithfulness.json')))46 self.load_external_result_data(os.path.join(TEST_PATH, 'Great Is Thy Faithfulness.json')))
47 self.file_import([os.path.join(TEST_PATH, 'Agnus Dei.sng')],47 self.file_import([os.path.join(TEST_PATH, 'Agnus Dei.sng')],
48 self.load_external_result_data(os.path.join(TEST_PATH, 'Agnus Dei.json')))48 self.load_external_result_data(os.path.join(TEST_PATH, 'Agnus Dei.json')))
49 self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.sng')],
50 self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
4951
=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py'
--- tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py 2015-01-18 13:39:21 +0000
+++ tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py 2015-01-30 21:59:49 +0000
@@ -109,3 +109,13 @@
109 results = parse_reference('Raoul 1', self.manager.db_cache['tests'], MagicMock())109 results = parse_reference('Raoul 1', self.manager.db_cache['tests'], MagicMock())
110 # THEN a verse array should be returned110 # THEN a verse array should be returned
111 self.assertEqual(False, results, "The bible Search should return False")111 self.assertEqual(False, results, "The bible Search should return False")
112
113 def parse_reference_five_test(self):
114 """
115 Test the parse_reference method with 1 Timothy 1:3-end
116 """
117 # GIVEN given a bible in the bible manager
118 # WHEN asking to parse the bible reference
119 results = parse_reference('1 Timothy 1:3-end', self.manager.db_cache['tests'], MagicMock(), 54)
120 # THEN a verse array should be returned
121 self.assertEqual([(54, 1, 3, -1)], results, "The bible verses should matches the expected results")
112122
=== added file 'tests/resources/presentationmanagersongs/Amazing Grace.json'
--- tests/resources/presentationmanagersongs/Amazing Grace.json 1970-01-01 00:00:00 +0000
+++ tests/resources/presentationmanagersongs/Amazing Grace.json 2015-01-30 21:59:49 +0000
@@ -0,0 +1,29 @@
1{
2 "title": "Amazing Grace",
3 "authors": [
4 "John Newton"
5 ],
6 "verse_order_list": ["v1", "v2", "v3", "v4", "v5"],
7 "verses": [
8 [
9 "Amazing grace! How sweet the sound!\nThat saved a wretch like me!\nI once was lost, but now am found;\nWas blind, but now I see.",
10 "v1"
11 ],
12 [
13 "'Twas grace that taught my heart to fear,\nAnd grace my fears relieved.\nHow precious did that grace appear,\nThe hour I first believed.",
14 "v2"
15 ],
16 [
17 "The Lord has promised good to me,\nHis Word my hope secures.\nHe will my shield and portion be\nAs long as life endures.",
18 "v3"
19 ],
20 [
21 "Thro' many dangers, toils and snares\nI have already come.\n'Tis grace that brought me safe thus far,\nAnd grace will lead me home.",
22 "v4"
23 ],
24 [
25 "When we've been there ten thousand years,\nBright shining as the sun,\nWe've no less days to sing God's praise,\nThan when we first begun.",
26 "v5"
27 ]
28 ]
29}
030
=== added file 'tests/resources/presentationmanagersongs/Amazing Grace.sng'
1Binary files tests/resources/presentationmanagersongs/Amazing Grace.sng 1970-01-01 00:00:00 +0000 and tests/resources/presentationmanagersongs/Amazing Grace.sng 2015-01-30 21:59:49 +0000 differ31Binary files tests/resources/presentationmanagersongs/Amazing Grace.sng 1970-01-01 00:00:00 +0000 and tests/resources/presentationmanagersongs/Amazing Grace.sng 2015-01-30 21:59:49 +0000 differ