forked from openlp/openlp
Fix bug #641661
This commit is contained in:
parent
f7943d5746
commit
4bb59bff67
@ -278,4 +278,4 @@ class Receiver(object):
|
||||
"""
|
||||
Get the global ``eventreceiver`` instance.
|
||||
"""
|
||||
return Receiver.eventreceiver
|
||||
return Receiver.eventreceiver
|
||||
|
@ -612,6 +612,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'maindisplay_status_text'), self.showStatusMessage)
|
||||
# Simple message boxes
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'openlp_error_message'), self.onErrorMessage)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'openlp_warning_message'), self.onWarningMessage)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'openlp_information_message'),
|
||||
self.onInformationMessage)
|
||||
# warning cyclic dependency
|
||||
# RenderManager needs to call ThemeManager and
|
||||
# ThemeManager needs to call RenderManager
|
||||
@ -720,6 +728,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
translate('OpenLP.MainWindow',
|
||||
'The Main Display has been blanked out'))
|
||||
|
||||
def onErrorMessage(self, data):
|
||||
QtGui.QMessageBox.critical(self, data[u'title'], data[u'message'])
|
||||
|
||||
def onWarningMessage(self, data):
|
||||
QtGui.QMessageBox.warning(self, data[u'title'], data[u'message'])
|
||||
|
||||
def onInformationMessage(self, data):
|
||||
QtGui.QMessageBox.information(self, data[u'title'], data[u'message'])
|
||||
|
||||
def onHelpWebSiteClicked(self):
|
||||
"""
|
||||
Load the OpenLP website
|
||||
@ -834,7 +851,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
else:
|
||||
ret = QtGui.QMessageBox.question(self,
|
||||
translate('OpenLP.MainWindow', 'Close OpenLP'),
|
||||
translate('OpenLP.MainWindow', 'Are you sure you want to Exit?'),
|
||||
translate('OpenLP.MainWindow', 'Are you sure you want to close OpenLP?'),
|
||||
QtGui.QMessageBox.StandardButtons(
|
||||
QtGui.QMessageBox.Yes |
|
||||
QtGui.QMessageBox.No),
|
||||
|
@ -33,7 +33,7 @@ from sqlalchemy import Column, ForeignKey, or_, Table, types
|
||||
from sqlalchemy.orm import class_mapper, mapper, relation
|
||||
from sqlalchemy.orm.exc import UnmappedClassError
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.lib.db import BaseModel, init_db, Manager
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -354,12 +354,12 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
verse_list.extend(verses)
|
||||
else:
|
||||
log.debug(u'OpenLP failed to find book %s', book)
|
||||
QtGui.QMessageBox.information(self.bible_plugin.mediaItem,
|
||||
translate('BiblesPlugin.BibleDB', 'Book not found'),
|
||||
translate('BiblesPlugin.BibleDB', 'The book you requested '
|
||||
'could not be found in this Bible. Please check your '
|
||||
'spelling and that this is a complete Bible not just '
|
||||
'one testament.'))
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('BiblesPlugin', 'No Book Found'),
|
||||
u'message': translate('BiblesPlugin', 'No matching book '
|
||||
'could be found in this Bible. Check that you have '
|
||||
'spelled the name of the book correctly.')
|
||||
})
|
||||
return verse_list
|
||||
|
||||
def verse_search(self, text):
|
||||
|
@ -35,7 +35,7 @@ from HTMLParser import HTMLParseError
|
||||
|
||||
from BeautifulSoup import BeautifulSoup, NavigableString
|
||||
|
||||
from openlp.core.lib import Receiver
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.plugins.bibles.lib import SearchResults
|
||||
from openlp.plugins.bibles.lib.db import BibleDB, Book
|
||||
@ -212,7 +212,13 @@ class BGExtract(object):
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
except urllib2.URLError:
|
||||
log.exception(u'The web bible page could not be downloaded.')
|
||||
Receiver.send_message(u'bibles_download_error')
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('BiblePlugin.HTTPBible', 'Download Error'),
|
||||
u'message': translate('BiblePlugin.HTTPBible', 'There was a '
|
||||
'problem downloading your verse selection. Please check your '
|
||||
'Internet connection, and if this error continues to occur '
|
||||
'consider reporting a bug.')
|
||||
})
|
||||
finally:
|
||||
if not page:
|
||||
return None
|
||||
@ -277,7 +283,13 @@ class BSExtract(object):
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
except urllib2.URLError:
|
||||
log.exception(u'The web bible page could not be downloaded.')
|
||||
Receiver.send_message(u'bibles_download_error')
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('BiblePlugin.HTTPBible', 'Download Error'),
|
||||
u'message': translate('BiblePlugin.HTTPBible', 'There was a '
|
||||
'problem downloading your verse selection. Please check your '
|
||||
'Internet connection, and if this error continues to occur '
|
||||
'consider reporting a bug.')
|
||||
})
|
||||
finally:
|
||||
if not page:
|
||||
return None
|
||||
@ -286,10 +298,13 @@ class BSExtract(object):
|
||||
soup = BeautifulSoup(page)
|
||||
except HTMLParseError:
|
||||
log.exception(u'BeautifulSoup could not parse the bible page.')
|
||||
Receiver.send_message(u'bibles_download_error')
|
||||
finally:
|
||||
if not soup:
|
||||
return None
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('BiblePlugin.HTTPBible', 'Parse Error'),
|
||||
u'message': translate('BiblePlugin.HTTPBible', 'There was a '
|
||||
'problem extracting your verse selection. If this error '
|
||||
'continues to occur consider reporting a bug.')
|
||||
})
|
||||
return None
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
content = None
|
||||
try:
|
||||
@ -341,19 +356,26 @@ class CWExtract(object):
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
except urllib2.URLError:
|
||||
log.exception(u'The web bible page could not be downloaded.')
|
||||
Receiver.send_message(u'bibles_download_error')
|
||||
finally:
|
||||
if not page:
|
||||
return None
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('BiblePlugin.HTTPBible', 'Download Error'),
|
||||
u'message': translate('BiblePlugin.HTTPBible', 'There was a '
|
||||
'problem downloading your verse selection. Please check your '
|
||||
'Internet connection, and if this error continues to occur '
|
||||
'consider reporting a bug.')
|
||||
})
|
||||
return None
|
||||
soup = None
|
||||
try:
|
||||
soup = BeautifulSoup(page)
|
||||
except HTMLParseError:
|
||||
log.exception(u'BeautifulSoup could not parse the bible page.')
|
||||
Receiver.send_message(u'bibles_download_error')
|
||||
finally:
|
||||
if not soup:
|
||||
return None
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('BiblePlugin.HTTPBible', 'Parse Error'),
|
||||
u'message': translate('BiblePlugin.HTTPBible', 'There was a '
|
||||
'problem extracting your verse selection. If this error '
|
||||
'continues to occur consider reporting a bug.')
|
||||
})
|
||||
return None
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
htmlverses = soup.findAll(u'span', u'versetext')
|
||||
verses = {}
|
||||
@ -463,7 +485,12 @@ class HTTPBible(BibleDB):
|
||||
if not db_book:
|
||||
book_details = self.lookup_book(book)
|
||||
if not book_details:
|
||||
Receiver.send_message(u'bibles_nobook')
|
||||
Receiver.send_message(u'openlp_error_message', {
|
||||
u'title': translate('BiblesPlugin', 'No Book Found'),
|
||||
u'message': translate('BiblesPlugin', 'No matching '
|
||||
'book could be found in this Bible. Check that you'
|
||||
'have spelled the name of the book correctly.')
|
||||
})
|
||||
return []
|
||||
db_book = self.create_book(book_details[u'name'],
|
||||
book_details[u'abbreviation'],
|
||||
@ -501,12 +528,7 @@ class HTTPBible(BibleDB):
|
||||
ev = BGExtract(self.proxy_server)
|
||||
elif self.download_source.lower() == u'bibleserver':
|
||||
ev = BSExtract(self.proxy_server)
|
||||
try:
|
||||
return ev.get_bible_chapter(self.download_name, book, chapter)
|
||||
except:
|
||||
log.exception(u'Error occurred while downloading verses')
|
||||
Receiver.send_message(u'bibles_download_error')
|
||||
return None
|
||||
return ev.get_bible_chapter(self.download_name, book, chapter)
|
||||
|
||||
def get_books(self):
|
||||
"""
|
||||
|
@ -259,10 +259,6 @@ class BibleMediaItem(MediaManagerItem):
|
||||
QtCore.SIGNAL(u'bibles_showprogress'), self.onSearchProgressShow)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'bibles_hideprogress'), self.onSearchProgressHide)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'bibles_nobook'), self.onNoBookFound)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'bibles_download_error'), self.onDownloadError)
|
||||
|
||||
def addListViewToToolBar(self):
|
||||
MediaManagerItem.addListViewToToolBar(self)
|
||||
@ -362,22 +358,6 @@ class BibleMediaItem(MediaManagerItem):
|
||||
def onSearchProgressHide(self):
|
||||
self.SearchProgress.setVisible(False)
|
||||
|
||||
def onNoBookFound(self):
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('BiblesPlugin.MediaItem', 'No Book Found'),
|
||||
translate('BiblesPlugin.MediaItem',
|
||||
'No matching book could be found in this Bible.'))
|
||||
self.AdvancedSearchButton.setEnabled(True)
|
||||
|
||||
def onDownloadError(self):
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('BiblesPlugin.MediaItem', 'Download Error'),
|
||||
translate('BiblesPlugin.MediaItem',
|
||||
'There was a problem downloading your verse selection. Please '
|
||||
'check your Internet connection, and if this error continues to '
|
||||
'occur please consider reporting a bug.'))
|
||||
self.AdvancedSearchButton.setEnabled(True)
|
||||
|
||||
def onImportClick(self):
|
||||
if not hasattr(self, u'import_wizard'):
|
||||
self.import_wizard = BibleImportForm(self, self.parent.manager,
|
||||
|
Loading…
Reference in New Issue
Block a user