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
1=== modified file 'openlp/core/ui/firsttimeform.py'
2--- openlp/core/ui/firsttimeform.py 2015-01-20 21:38:34 +0000
3+++ openlp/core/ui/firsttimeform.py 2015-01-30 21:59:49 +0000
4@@ -268,9 +268,11 @@
5 self.web = 'http://openlp.org/files/frw/'
6 self.cancel_button.clicked.connect(self.on_cancel_button_clicked)
7 self.no_internet_finish_button.clicked.connect(self.on_no_internet_finish_button_clicked)
8+ self.no_internet_cancel_button.clicked.connect(self.on_no_internet_cancel_button_clicked)
9 self.currentIdChanged.connect(self.on_current_id_changed)
10 Registry().register_function('config_screen_changed', self.update_screen_list_combo)
11 self.no_internet_finish_button.setVisible(False)
12+ self.no_internet_cancel_button.setVisible(False)
13 # Check if this is a re-run of the wizard.
14 self.has_run_wizard = Settings().value('core/has run wizard')
15 check_directory_exists(os.path.join(gettempdir(), 'openlp'))
16@@ -327,6 +329,10 @@
17 self.next_button.setVisible(False)
18 self.cancel_button.setVisible(False)
19 self.no_internet_finish_button.setVisible(True)
20+ if self.has_run_wizard:
21+ self.no_internet_cancel_button.setVisible(False)
22+ else:
23+ self.no_internet_cancel_button.setVisible(True)
24 elif page_id == FirstTimePage.Plugins:
25 self.back_button.setVisible(False)
26 elif page_id == FirstTimePage.Progress:
27@@ -372,6 +378,13 @@
28 Settings().setValue('core/has run wizard', True)
29 self.close()
30
31+ def on_no_internet_cancel_button_clicked(self):
32+ """
33+ Process the triggering of the "Cancel" button on the No Internet page.
34+ """
35+ self.was_cancelled = True
36+ self.close()
37+
38 def url_get_file(self, url, f_path):
39 """"
40 Download a file given a URL. The file is retrieved in chunks, giving the ability to cancel the download at any
41
42=== modified file 'openlp/core/ui/firsttimewizard.py'
43--- openlp/core/ui/firsttimewizard.py 2015-01-18 13:39:21 +0000
44+++ openlp/core/ui/firsttimewizard.py 2015-01-30 21:59:49 +0000
45@@ -59,7 +59,8 @@
46 first_time_wizard.resize(550, 386)
47 first_time_wizard.setModal(True)
48 first_time_wizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage |
49- QtGui.QWizard.NoBackButtonOnLastPage | QtGui.QWizard.HaveCustomButton1)
50+ QtGui.QWizard.NoBackButtonOnLastPage | QtGui.QWizard.HaveCustomButton1 |
51+ QtGui.QWizard.HaveCustomButton2)
52 if is_macosx():
53 first_time_wizard.setPixmap(QtGui.QWizard.BackgroundPixmap,
54 QtGui.QPixmap(':/wizards/openlp-osx-wizard.png'))
55@@ -69,6 +70,7 @@
56 self.finish_button = self.button(QtGui.QWizard.FinishButton)
57 self.no_internet_finish_button = self.button(QtGui.QWizard.CustomButton1)
58 self.cancel_button = self.button(QtGui.QWizard.CancelButton)
59+ self.no_internet_cancel_button = self.button(QtGui.QWizard.CustomButton2)
60 self.next_button = self.button(QtGui.QWizard.NextButton)
61 self.back_button = self.button(QtGui.QWizard.BackButton)
62 add_welcome_page(first_time_wizard, ':/wizards/wizard_firsttime.bmp')
63@@ -271,3 +273,4 @@
64 'and OpenLP is configured.'))
65 self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Starting configuration process...'))
66 first_time_wizard.setButtonText(QtGui.QWizard.CustomButton1, translate('OpenLP.FirstTimeWizard', 'Finish'))
67+ first_time_wizard.setButtonText(QtGui.QWizard.CustomButton2, translate('OpenLP.FirstTimeWizard', 'Cancel'))
68
69=== modified file 'openlp/plugins/bibles/lib/__init__.py'
70--- openlp/plugins/bibles/lib/__init__.py 2015-01-22 13:19:10 +0000
71+++ openlp/plugins/bibles/lib/__init__.py 2015-01-30 21:59:49 +0000
72@@ -178,7 +178,7 @@
73 default_separators = [
74 '|'.join([
75 translate('BiblesPlugin', ':', 'Verse identifier e.g. Genesis 1 : 1 = Genesis Chapter 1 Verse 1'),
76- translate('BiblesPlugin', 'v','Verse identifier e.g. Genesis 1 v 1 = Genesis Chapter 1 Verse 1'),
77+ translate('BiblesPlugin', 'v', 'Verse identifier e.g. Genesis 1 v 1 = Genesis Chapter 1 Verse 1'),
78 translate('BiblesPlugin', 'V', 'Verse identifier e.g. Genesis 1 V 1 = Genesis Chapter 1 Verse 1'),
79 translate('BiblesPlugin', 'verse', 'Verse identifier e.g. Genesis 1 verse 1 = Genesis Chapter 1 Verse 1'),
80 translate('BiblesPlugin', 'verses',
81@@ -371,7 +371,7 @@
82 from_chapter = from_verse
83 from_verse = None
84 if to_chapter:
85- if to_chapter < from_chapter:
86+ if from_chapter and to_chapter < from_chapter:
87 continue
88 else:
89 chapter = to_chapter
90@@ -387,7 +387,7 @@
91 from_verse = 1
92 if not to_verse:
93 to_verse = -1
94- if to_chapter > from_chapter:
95+ if to_chapter and to_chapter > from_chapter:
96 ref_list.append((book_ref_id, from_chapter, from_verse, -1))
97 for i in range(from_chapter + 1, to_chapter):
98 ref_list.append((book_ref_id, i, 1, -1))
99
100=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
101--- openlp/plugins/presentations/lib/mediaitem.py 2015-01-22 18:01:54 +0000
102+++ openlp/plugins/presentations/lib/mediaitem.py 2015-01-30 21:59:49 +0000
103@@ -225,10 +225,10 @@
104 self.clean_up_thumbnails(filepath)
105 self.main_window.increment_progress_bar()
106 self.main_window.finished_progress_bar()
107- self.application.set_busy_cursor()
108 for row in row_list:
109 self.list_view.takeItem(row)
110 Settings().setValue(self.settings_section + '/presentations files', self.get_file_list())
111+ self.application.set_normal_cursor()
112
113 def clean_up_thumbnails(self, filepath):
114 """
115
116=== modified file 'openlp/plugins/songs/lib/importers/presentationmanager.py'
117--- openlp/plugins/songs/lib/importers/presentationmanager.py 2015-01-22 17:42:29 +0000
118+++ openlp/plugins/songs/lib/importers/presentationmanager.py 2015-01-30 21:59:49 +0000
119@@ -25,7 +25,9 @@
120 """
121
122 import os
123-from lxml import objectify
124+import re
125+import chardet
126+from lxml import objectify, etree
127
128 from openlp.core.ui.wizard import WizardStrings
129 from .songimport import SongImport
130@@ -42,7 +44,18 @@
131 if self.stop_import_flag:
132 return
133 self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % os.path.basename(file_path))
134- root = objectify.parse(open(file_path, 'rb')).getroot()
135+ try:
136+ tree = etree.parse(file_path, parser=etree.XMLParser(recover=True))
137+ except etree.XMLSyntaxError:
138+ # Try to detect encoding and use it
139+ file = open(file_path, mode='rb')
140+ encoding = chardet.detect(file.read())['encoding']
141+ file.close()
142+ # Open file with detected encoding and remove encoding declaration
143+ text = open(file_path, mode='r', encoding=encoding).read()
144+ text = re.sub('.+\?>\n', '', text)
145+ tree = etree.fromstring(text, parser=etree.XMLParser(recover=True))
146+ root = objectify.fromstring(etree.tostring(tree))
147 self.process_song(root)
148
149 def process_song(self, root):
150
151=== modified file 'tests/functional/openlp_plugins/songs/test_presentationmanagerimport.py'
152--- tests/functional/openlp_plugins/songs/test_presentationmanagerimport.py 2015-01-18 13:39:21 +0000
153+++ tests/functional/openlp_plugins/songs/test_presentationmanagerimport.py 2015-01-30 21:59:49 +0000
154@@ -46,3 +46,5 @@
155 self.load_external_result_data(os.path.join(TEST_PATH, 'Great Is Thy Faithfulness.json')))
156 self.file_import([os.path.join(TEST_PATH, 'Agnus Dei.sng')],
157 self.load_external_result_data(os.path.join(TEST_PATH, 'Agnus Dei.json')))
158+ self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.sng')],
159+ self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
160
161=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py'
162--- tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py 2015-01-18 13:39:21 +0000
163+++ tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py 2015-01-30 21:59:49 +0000
164@@ -109,3 +109,13 @@
165 results = parse_reference('Raoul 1', self.manager.db_cache['tests'], MagicMock())
166 # THEN a verse array should be returned
167 self.assertEqual(False, results, "The bible Search should return False")
168+
169+ def parse_reference_five_test(self):
170+ """
171+ Test the parse_reference method with 1 Timothy 1:3-end
172+ """
173+ # GIVEN given a bible in the bible manager
174+ # WHEN asking to parse the bible reference
175+ results = parse_reference('1 Timothy 1:3-end', self.manager.db_cache['tests'], MagicMock(), 54)
176+ # THEN a verse array should be returned
177+ self.assertEqual([(54, 1, 3, -1)], results, "The bible verses should matches the expected results")
178
179=== added file 'tests/resources/presentationmanagersongs/Amazing Grace.json'
180--- tests/resources/presentationmanagersongs/Amazing Grace.json 1970-01-01 00:00:00 +0000
181+++ tests/resources/presentationmanagersongs/Amazing Grace.json 2015-01-30 21:59:49 +0000
182@@ -0,0 +1,29 @@
183+{
184+ "title": "Amazing Grace",
185+ "authors": [
186+ "John Newton"
187+ ],
188+ "verse_order_list": ["v1", "v2", "v3", "v4", "v5"],
189+ "verses": [
190+ [
191+ "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.",
192+ "v1"
193+ ],
194+ [
195+ "'Twas grace that taught my heart to fear,\nAnd grace my fears relieved.\nHow precious did that grace appear,\nThe hour I first believed.",
196+ "v2"
197+ ],
198+ [
199+ "The Lord has promised good to me,\nHis Word my hope secures.\nHe will my shield and portion be\nAs long as life endures.",
200+ "v3"
201+ ],
202+ [
203+ "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.",
204+ "v4"
205+ ],
206+ [
207+ "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.",
208+ "v5"
209+ ]
210+ ]
211+}
212
213=== added file 'tests/resources/presentationmanagersongs/Amazing Grace.sng'
214Binary 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