This commit is contained in:
Raoul Snyman 2011-01-01 12:33:14 +02:00
parent f7943d5746
commit 4bb59bff67
5 changed files with 70 additions and 51 deletions

View File

@ -278,4 +278,4 @@ class Receiver(object):
""" """
Get the global ``eventreceiver`` instance. Get the global ``eventreceiver`` instance.
""" """
return Receiver.eventreceiver return Receiver.eventreceiver

View File

@ -612,6 +612,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged) QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_status_text'), self.showStatusMessage) 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 # warning cyclic dependency
# RenderManager needs to call ThemeManager and # RenderManager needs to call ThemeManager and
# ThemeManager needs to call RenderManager # ThemeManager needs to call RenderManager
@ -720,6 +728,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
translate('OpenLP.MainWindow', translate('OpenLP.MainWindow',
'The Main Display has been blanked out')) '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): def onHelpWebSiteClicked(self):
""" """
Load the OpenLP website Load the OpenLP website
@ -834,7 +851,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
else: else:
ret = QtGui.QMessageBox.question(self, ret = QtGui.QMessageBox.question(self,
translate('OpenLP.MainWindow', 'Close OpenLP'), 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.StandardButtons(
QtGui.QMessageBox.Yes | QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No), QtGui.QMessageBox.No),

View File

@ -33,7 +33,7 @@ from sqlalchemy import Column, ForeignKey, or_, Table, types
from sqlalchemy.orm import class_mapper, mapper, relation from sqlalchemy.orm import class_mapper, mapper, relation
from sqlalchemy.orm.exc import UnmappedClassError 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 from openlp.core.lib.db import BaseModel, init_db, Manager
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -354,12 +354,12 @@ class BibleDB(QtCore.QObject, Manager):
verse_list.extend(verses) verse_list.extend(verses)
else: else:
log.debug(u'OpenLP failed to find book %s', book) log.debug(u'OpenLP failed to find book %s', book)
QtGui.QMessageBox.information(self.bible_plugin.mediaItem, Receiver.send_message(u'openlp_error_message', {
translate('BiblesPlugin.BibleDB', 'Book not found'), u'title': translate('BiblesPlugin', 'No Book Found'),
translate('BiblesPlugin.BibleDB', 'The book you requested ' u'message': translate('BiblesPlugin', 'No matching book '
'could not be found in this Bible. Please check your ' 'could be found in this Bible. Check that you have '
'spelling and that this is a complete Bible not just ' 'spelled the name of the book correctly.')
'one testament.')) })
return verse_list return verse_list
def verse_search(self, text): def verse_search(self, text):

View File

@ -35,7 +35,7 @@ from HTMLParser import HTMLParseError
from BeautifulSoup import BeautifulSoup, NavigableString 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.core.utils import AppLocation
from openlp.plugins.bibles.lib import SearchResults from openlp.plugins.bibles.lib import SearchResults
from openlp.plugins.bibles.lib.db import BibleDB, Book from openlp.plugins.bibles.lib.db import BibleDB, Book
@ -212,7 +212,13 @@ class BGExtract(object):
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
except urllib2.URLError: except urllib2.URLError:
log.exception(u'The web bible page could not be downloaded.') 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: finally:
if not page: if not page:
return None return None
@ -277,7 +283,13 @@ class BSExtract(object):
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
except urllib2.URLError: except urllib2.URLError:
log.exception(u'The web bible page could not be downloaded.') 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: finally:
if not page: if not page:
return None return None
@ -286,10 +298,13 @@ class BSExtract(object):
soup = BeautifulSoup(page) soup = BeautifulSoup(page)
except HTMLParseError: except HTMLParseError:
log.exception(u'BeautifulSoup could not parse the bible page.') log.exception(u'BeautifulSoup could not parse the bible page.')
Receiver.send_message(u'bibles_download_error') Receiver.send_message(u'openlp_error_message', {
finally: u'title': translate('BiblePlugin.HTTPBible', 'Parse Error'),
if not soup: u'message': translate('BiblePlugin.HTTPBible', 'There was a '
return None 'problem extracting your verse selection. If this error '
'continues to occur consider reporting a bug.')
})
return None
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
content = None content = None
try: try:
@ -341,19 +356,26 @@ class CWExtract(object):
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
except urllib2.URLError: except urllib2.URLError:
log.exception(u'The web bible page could not be downloaded.') 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', {
finally: u'title': translate('BiblePlugin.HTTPBible', 'Download Error'),
if not page: u'message': translate('BiblePlugin.HTTPBible', 'There was a '
return None '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 soup = None
try: try:
soup = BeautifulSoup(page) soup = BeautifulSoup(page)
except HTMLParseError: except HTMLParseError:
log.exception(u'BeautifulSoup could not parse the bible page.') log.exception(u'BeautifulSoup could not parse the bible page.')
Receiver.send_message(u'bibles_download_error') Receiver.send_message(u'openlp_error_message', {
finally: u'title': translate('BiblePlugin.HTTPBible', 'Parse Error'),
if not soup: u'message': translate('BiblePlugin.HTTPBible', 'There was a '
return None 'problem extracting your verse selection. If this error '
'continues to occur consider reporting a bug.')
})
return None
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
htmlverses = soup.findAll(u'span', u'versetext') htmlverses = soup.findAll(u'span', u'versetext')
verses = {} verses = {}
@ -463,7 +485,12 @@ class HTTPBible(BibleDB):
if not db_book: if not db_book:
book_details = self.lookup_book(book) book_details = self.lookup_book(book)
if not book_details: 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 [] return []
db_book = self.create_book(book_details[u'name'], db_book = self.create_book(book_details[u'name'],
book_details[u'abbreviation'], book_details[u'abbreviation'],
@ -501,12 +528,7 @@ class HTTPBible(BibleDB):
ev = BGExtract(self.proxy_server) ev = BGExtract(self.proxy_server)
elif self.download_source.lower() == u'bibleserver': elif self.download_source.lower() == u'bibleserver':
ev = BSExtract(self.proxy_server) ev = BSExtract(self.proxy_server)
try: return ev.get_bible_chapter(self.download_name, book, chapter)
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
def get_books(self): def get_books(self):
""" """

View File

@ -259,10 +259,6 @@ class BibleMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'bibles_showprogress'), self.onSearchProgressShow) QtCore.SIGNAL(u'bibles_showprogress'), self.onSearchProgressShow)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'bibles_hideprogress'), self.onSearchProgressHide) 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): def addListViewToToolBar(self):
MediaManagerItem.addListViewToToolBar(self) MediaManagerItem.addListViewToToolBar(self)
@ -362,22 +358,6 @@ class BibleMediaItem(MediaManagerItem):
def onSearchProgressHide(self): def onSearchProgressHide(self):
self.SearchProgress.setVisible(False) 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): def onImportClick(self):
if not hasattr(self, u'import_wizard'): if not hasattr(self, u'import_wizard'):
self.import_wizard = BibleImportForm(self, self.parent.manager, self.import_wizard = BibleImportForm(self, self.parent.manager,