This commit is contained in:
Tim Bentley 2011-01-01 12:50:49 +00:00
commit 672eeb812b
4 changed files with 74 additions and 29 deletions

View File

@ -613,6 +613,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
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)
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
# 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
@ -723,6 +731,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
@ -840,7 +857,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

@ -28,13 +28,14 @@ import logging
import os import os
import re import re
import sqlite3 import sqlite3
import socket
import urllib import urllib
import urllib2 import urllib2
from HTMLParser import HTMLParseError 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
@ -184,6 +185,7 @@ class BGExtract(object):
def __init__(self, proxyurl=None): def __init__(self, proxyurl=None):
log.debug(u'init %s', proxyurl) log.debug(u'init %s', proxyurl)
self.proxyurl = proxyurl self.proxyurl = proxyurl
socket.setdefaulttimeout(30)
def get_bible_chapter(self, version, bookname, chapter): def get_bible_chapter(self, version, bookname, chapter):
""" """
@ -210,6 +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'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
@ -219,6 +228,7 @@ class BGExtract(object):
soup = BeautifulSoup(page, markupMassage=cleaner) soup = BeautifulSoup(page, markupMassage=cleaner)
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')
finally: finally:
if not soup: if not soup:
return None return None
@ -247,6 +257,7 @@ class BSExtract(object):
def __init__(self, proxyurl=None): def __init__(self, proxyurl=None):
log.debug(u'init %s', proxyurl) log.debug(u'init %s', proxyurl)
self.proxyurl = proxyurl self.proxyurl = proxyurl
socket.setdefaulttimeout(30)
def get_bible_chapter(self, version, bookname, chapter): def get_bible_chapter(self, version, bookname, chapter):
""" """
@ -272,6 +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'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
@ -280,9 +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.')
finally: Receiver.send_message(u'openlp_error_message', {
if not soup: u'title': translate('BiblePlugin.HTTPBible', 'Parse Error'),
return None 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') Receiver.send_message(u'openlp_process_events')
content = None content = None
try: try:
@ -308,6 +330,7 @@ class CWExtract(object):
def __init__(self, proxyurl=None): def __init__(self, proxyurl=None):
log.debug(u'init %s', proxyurl) log.debug(u'init %s', proxyurl)
self.proxyurl = proxyurl self.proxyurl = proxyurl
socket.setdefaulttimeout(30)
def get_bible_chapter(self, version, bookname, chapter): def get_bible_chapter(self, version, bookname, chapter):
""" """
@ -333,17 +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.')
finally: Receiver.send_message(u'openlp_error_message', {
if not page: u'title': translate('BiblePlugin.HTTPBible', 'Download Error'),
return None 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 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.')
finally: Receiver.send_message(u'openlp_error_message', {
if not soup: u'title': translate('BiblePlugin.HTTPBible', 'Parse Error'),
return None 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') Receiver.send_message(u'openlp_process_events')
htmlverses = soup.findAll(u'span', u'versetext') htmlverses = soup.findAll(u'span', u'versetext')
verses = {} verses = {}
@ -453,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'],

View File

@ -259,8 +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)
def addListViewToToolBar(self): def addListViewToToolBar(self):
MediaManagerItem.addListViewToToolBar(self) MediaManagerItem.addListViewToToolBar(self)
@ -360,13 +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 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,