Merge lp:~raoul-snyman/openlp/bug-fixes into lp:openlp

Proposed by Raoul Snyman
Status: Merged
Merged at revision: 1180
Proposed branch: lp:~raoul-snyman/openlp/bug-fixes
Merge into: lp:openlp
Diff against target: 266 lines (+75/-30)
5 files modified
openlp/core/lib/eventreceiver.py (+1/-1)
openlp/core/ui/mainwindow.py (+18/-1)
openlp/plugins/bibles/lib/db.py (+7/-7)
openlp/plugins/bibles/lib/http.py (+49/-12)
openlp/plugins/bibles/lib/mediaitem.py (+0/-9)
To merge this branch: bzr merge lp:~raoul-snyman/openlp/bug-fixes
Reviewer Review Type Date Requested Status
Tim Bentley Approve
Review via email: mp+44973@code.launchpad.net

Description of the change

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

Approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/lib/eventreceiver.py'
2--- openlp/core/lib/eventreceiver.py 2010-12-26 11:04:47 +0000
3+++ openlp/core/lib/eventreceiver.py 2011-01-01 11:48:59 +0000
4@@ -278,4 +278,4 @@
5 """
6 Get the global ``eventreceiver`` instance.
7 """
8- return Receiver.eventreceiver
9\ No newline at end of file
10+ return Receiver.eventreceiver
11
12=== modified file 'openlp/core/ui/mainwindow.py'
13--- openlp/core/ui/mainwindow.py 2010-12-31 21:45:12 +0000
14+++ openlp/core/ui/mainwindow.py 2011-01-01 11:48:59 +0000
15@@ -612,6 +612,14 @@
16 QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged)
17 QtCore.QObject.connect(Receiver.get_receiver(),
18 QtCore.SIGNAL(u'maindisplay_status_text'), self.showStatusMessage)
19+ # Simple message boxes
20+ QtCore.QObject.connect(Receiver.get_receiver(),
21+ QtCore.SIGNAL(u'openlp_error_message'), self.onErrorMessage)
22+ QtCore.QObject.connect(Receiver.get_receiver(),
23+ QtCore.SIGNAL(u'openlp_warning_message'), self.onWarningMessage)
24+ QtCore.QObject.connect(Receiver.get_receiver(),
25+ QtCore.SIGNAL(u'openlp_information_message'),
26+ self.onInformationMessage)
27 # warning cyclic dependency
28 # RenderManager needs to call ThemeManager and
29 # ThemeManager needs to call RenderManager
30@@ -721,6 +729,15 @@
31 translate('OpenLP.MainWindow',
32 'The Main Display has been blanked out'))
33
34+ def onErrorMessage(self, data):
35+ QtGui.QMessageBox.critical(self, data[u'title'], data[u'message'])
36+
37+ def onWarningMessage(self, data):
38+ QtGui.QMessageBox.warning(self, data[u'title'], data[u'message'])
39+
40+ def onInformationMessage(self, data):
41+ QtGui.QMessageBox.information(self, data[u'title'], data[u'message'])
42+
43 def onHelpWebSiteClicked(self):
44 """
45 Load the OpenLP website
46@@ -838,7 +855,7 @@
47 else:
48 ret = QtGui.QMessageBox.question(self,
49 translate('OpenLP.MainWindow', 'Close OpenLP'),
50- translate('OpenLP.MainWindow', 'Are you sure you want to Exit?'),
51+ translate('OpenLP.MainWindow', 'Are you sure you want to close OpenLP?'),
52 QtGui.QMessageBox.StandardButtons(
53 QtGui.QMessageBox.Yes |
54 QtGui.QMessageBox.No),
55
56=== modified file 'openlp/plugins/bibles/lib/db.py'
57--- openlp/plugins/bibles/lib/db.py 2010-12-28 11:18:56 +0000
58+++ openlp/plugins/bibles/lib/db.py 2011-01-01 11:48:59 +0000
59@@ -33,7 +33,7 @@
60 from sqlalchemy.orm import class_mapper, mapper, relation
61 from sqlalchemy.orm.exc import UnmappedClassError
62
63-from openlp.core.lib import translate
64+from openlp.core.lib import Receiver, translate
65 from openlp.core.lib.db import BaseModel, init_db, Manager
66
67 log = logging.getLogger(__name__)
68@@ -354,12 +354,12 @@
69 verse_list.extend(verses)
70 else:
71 log.debug(u'OpenLP failed to find book %s', book)
72- QtGui.QMessageBox.information(self.bible_plugin.mediaItem,
73- translate('BiblesPlugin.BibleDB', 'Book not found'),
74- translate('BiblesPlugin.BibleDB', 'The book you requested '
75- 'could not be found in this Bible. Please check your '
76- 'spelling and that this is a complete Bible not just '
77- 'one testament.'))
78+ Receiver.send_message(u'openlp_error_message', {
79+ u'title': translate('BiblesPlugin', 'No Book Found'),
80+ u'message': translate('BiblesPlugin', 'No matching book '
81+ 'could be found in this Bible. Check that you have '
82+ 'spelled the name of the book correctly.')
83+ })
84 return verse_list
85
86 def verse_search(self, text):
87
88=== modified file 'openlp/plugins/bibles/lib/http.py'
89--- openlp/plugins/bibles/lib/http.py 2010-12-28 11:18:56 +0000
90+++ openlp/plugins/bibles/lib/http.py 2011-01-01 11:48:59 +0000
91@@ -28,13 +28,14 @@
92 import os
93 import re
94 import sqlite3
95+import socket
96 import urllib
97 import urllib2
98 from HTMLParser import HTMLParseError
99
100 from BeautifulSoup import BeautifulSoup, NavigableString
101
102-from openlp.core.lib import Receiver
103+from openlp.core.lib import Receiver, translate
104 from openlp.core.utils import AppLocation
105 from openlp.plugins.bibles.lib import SearchResults
106 from openlp.plugins.bibles.lib.db import BibleDB, Book
107@@ -184,6 +185,7 @@
108 def __init__(self, proxyurl=None):
109 log.debug(u'init %s', proxyurl)
110 self.proxyurl = proxyurl
111+ socket.setdefaulttimeout(30)
112
113 def get_bible_chapter(self, version, bookname, chapter):
114 """
115@@ -210,6 +212,13 @@
116 Receiver.send_message(u'openlp_process_events')
117 except urllib2.URLError:
118 log.exception(u'The web bible page could not be downloaded.')
119+ Receiver.send_message(u'openlp_error_message', {
120+ u'title': translate('BiblePlugin.HTTPBible', 'Download Error'),
121+ u'message': translate('BiblePlugin.HTTPBible', 'There was a '
122+ 'problem downloading your verse selection. Please check your '
123+ 'Internet connection, and if this error continues to occur '
124+ 'consider reporting a bug.')
125+ })
126 finally:
127 if not page:
128 return None
129@@ -219,6 +228,7 @@
130 soup = BeautifulSoup(page, markupMassage=cleaner)
131 except HTMLParseError:
132 log.exception(u'BeautifulSoup could not parse the bible page.')
133+ Receiver.send_message(u'bibles_download_error')
134 finally:
135 if not soup:
136 return None
137@@ -247,6 +257,7 @@
138 def __init__(self, proxyurl=None):
139 log.debug(u'init %s', proxyurl)
140 self.proxyurl = proxyurl
141+ socket.setdefaulttimeout(30)
142
143 def get_bible_chapter(self, version, bookname, chapter):
144 """
145@@ -264,7 +275,7 @@
146 log.debug(u'get_bible_chapter %s,%s,%s', version, bookname, chapter)
147 chapter_url = u'http://m.bibleserver.com/text/%s/%s%s' % \
148 (version, bookname, chapter)
149-
150+
151 log.debug(u'URL: %s', chapter_url)
152 page = None
153 try:
154@@ -272,6 +283,13 @@
155 Receiver.send_message(u'openlp_process_events')
156 except urllib2.URLError:
157 log.exception(u'The web bible page could not be downloaded.')
158+ Receiver.send_message(u'openlp_error_message', {
159+ u'title': translate('BiblePlugin.HTTPBible', 'Download Error'),
160+ u'message': translate('BiblePlugin.HTTPBible', 'There was a '
161+ 'problem downloading your verse selection. Please check your '
162+ 'Internet connection, and if this error continues to occur '
163+ 'consider reporting a bug.')
164+ })
165 finally:
166 if not page:
167 return None
168@@ -280,9 +298,13 @@
169 soup = BeautifulSoup(page)
170 except HTMLParseError:
171 log.exception(u'BeautifulSoup could not parse the bible page.')
172- finally:
173- if not soup:
174- return None
175+ Receiver.send_message(u'openlp_error_message', {
176+ u'title': translate('BiblePlugin.HTTPBible', 'Parse Error'),
177+ u'message': translate('BiblePlugin.HTTPBible', 'There was a '
178+ 'problem extracting your verse selection. If this error '
179+ 'continues to occur consider reporting a bug.')
180+ })
181+ return None
182 Receiver.send_message(u'openlp_process_events')
183 content = None
184 try:
185@@ -308,6 +330,7 @@
186 def __init__(self, proxyurl=None):
187 log.debug(u'init %s', proxyurl)
188 self.proxyurl = proxyurl
189+ socket.setdefaulttimeout(30)
190
191 def get_bible_chapter(self, version, bookname, chapter):
192 """
193@@ -333,17 +356,26 @@
194 Receiver.send_message(u'openlp_process_events')
195 except urllib2.URLError:
196 log.exception(u'The web bible page could not be downloaded.')
197- finally:
198- if not page:
199- return None
200+ Receiver.send_message(u'openlp_error_message', {
201+ u'title': translate('BiblePlugin.HTTPBible', 'Download Error'),
202+ u'message': translate('BiblePlugin.HTTPBible', 'There was a '
203+ 'problem downloading your verse selection. Please check your '
204+ 'Internet connection, and if this error continues to occur '
205+ 'consider reporting a bug.')
206+ })
207+ return None
208 soup = None
209 try:
210 soup = BeautifulSoup(page)
211 except HTMLParseError:
212 log.exception(u'BeautifulSoup could not parse the bible page.')
213- finally:
214- if not soup:
215- return None
216+ Receiver.send_message(u'openlp_error_message', {
217+ u'title': translate('BiblePlugin.HTTPBible', 'Parse Error'),
218+ u'message': translate('BiblePlugin.HTTPBible', 'There was a '
219+ 'problem extracting your verse selection. If this error '
220+ 'continues to occur consider reporting a bug.')
221+ })
222+ return None
223 Receiver.send_message(u'openlp_process_events')
224 htmlverses = soup.findAll(u'span', u'versetext')
225 verses = {}
226@@ -453,7 +485,12 @@
227 if not db_book:
228 book_details = self.lookup_book(book)
229 if not book_details:
230- Receiver.send_message(u'bibles_nobook')
231+ Receiver.send_message(u'openlp_error_message', {
232+ u'title': translate('BiblesPlugin', 'No Book Found'),
233+ u'message': translate('BiblesPlugin', 'No matching '
234+ 'book could be found in this Bible. Check that you'
235+ 'have spelled the name of the book correctly.')
236+ })
237 return []
238 db_book = self.create_book(book_details[u'name'],
239 book_details[u'abbreviation'],
240
241=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
242--- openlp/plugins/bibles/lib/mediaitem.py 2010-12-31 02:17:41 +0000
243+++ openlp/plugins/bibles/lib/mediaitem.py 2011-01-01 11:48:59 +0000
244@@ -259,8 +259,6 @@
245 QtCore.SIGNAL(u'bibles_showprogress'), self.onSearchProgressShow)
246 QtCore.QObject.connect(Receiver.get_receiver(),
247 QtCore.SIGNAL(u'bibles_hideprogress'), self.onSearchProgressHide)
248- QtCore.QObject.connect(Receiver.get_receiver(),
249- QtCore.SIGNAL(u'bibles_nobook'), self.onNoBookFound)
250
251 def addListViewToToolBar(self):
252 MediaManagerItem.addListViewToToolBar(self)
253@@ -360,13 +358,6 @@
254 def onSearchProgressHide(self):
255 self.SearchProgress.setVisible(False)
256
257- def onNoBookFound(self):
258- QtGui.QMessageBox.critical(self,
259- translate('BiblesPlugin.MediaItem', 'No Book Found'),
260- translate('BiblesPlugin.MediaItem',
261- 'No matching book could be found in this Bible.'))
262- self.AdvancedSearchButton.setEnabled(True)
263-
264 def onImportClick(self):
265 if not hasattr(self, u'import_wizard'):
266 self.import_wizard = BibleImportForm(self, self.parent.manager,