forked from openlp/openlp
Head
This commit is contained in:
commit
672eeb812b
@ -613,6 +613,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'maindisplay_status_text'), self.showStatusMessage)
|
||||
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
|
||||
# RenderManager needs to call ThemeManager and
|
||||
# ThemeManager needs to call RenderManager
|
||||
@ -723,6 +731,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
|
||||
@ -840,7 +857,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):
|
||||
|
@ -28,13 +28,14 @@ import logging
|
||||
import os
|
||||
import re
|
||||
import sqlite3
|
||||
import socket
|
||||
import urllib
|
||||
import urllib2
|
||||
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
|
||||
@ -184,6 +185,7 @@ class BGExtract(object):
|
||||
def __init__(self, proxyurl=None):
|
||||
log.debug(u'init %s', proxyurl)
|
||||
self.proxyurl = proxyurl
|
||||
socket.setdefaulttimeout(30)
|
||||
|
||||
def get_bible_chapter(self, version, bookname, chapter):
|
||||
"""
|
||||
@ -210,6 +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'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
|
||||
@ -219,6 +228,7 @@ class BGExtract(object):
|
||||
soup = BeautifulSoup(page, markupMassage=cleaner)
|
||||
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
|
||||
@ -247,6 +257,7 @@ class BSExtract(object):
|
||||
def __init__(self, proxyurl=None):
|
||||
log.debug(u'init %s', proxyurl)
|
||||
self.proxyurl = proxyurl
|
||||
socket.setdefaulttimeout(30)
|
||||
|
||||
def get_bible_chapter(self, version, bookname, chapter):
|
||||
"""
|
||||
@ -264,7 +275,7 @@ class BSExtract(object):
|
||||
log.debug(u'get_bible_chapter %s,%s,%s', version, bookname, chapter)
|
||||
chapter_url = u'http://m.bibleserver.com/text/%s/%s%s' % \
|
||||
(version, bookname, chapter)
|
||||
|
||||
|
||||
log.debug(u'URL: %s', chapter_url)
|
||||
page = None
|
||||
try:
|
||||
@ -272,6 +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'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
|
||||
@ -280,9 +298,13 @@ class BSExtract(object):
|
||||
soup = BeautifulSoup(page)
|
||||
except HTMLParseError:
|
||||
log.exception(u'BeautifulSoup could not parse the bible page.')
|
||||
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:
|
||||
@ -308,6 +330,7 @@ class CWExtract(object):
|
||||
def __init__(self, proxyurl=None):
|
||||
log.debug(u'init %s', proxyurl)
|
||||
self.proxyurl = proxyurl
|
||||
socket.setdefaulttimeout(30)
|
||||
|
||||
def get_bible_chapter(self, version, bookname, chapter):
|
||||
"""
|
||||
@ -333,17 +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.')
|
||||
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.')
|
||||
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 = {}
|
||||
@ -453,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'],
|
||||
|
@ -259,8 +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)
|
||||
|
||||
def addListViewToToolBar(self):
|
||||
MediaManagerItem.addListViewToToolBar(self)
|
||||
@ -360,13 +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 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