forked from openlp/openlp
Add in an error message if there is a problem with the user's downloaded Bibles.
This commit is contained in:
parent
487837e615
commit
f7943d5746
@ -28,6 +28,7 @@ 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
|
||||||
@ -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,7 @@ 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')
|
||||||
finally:
|
finally:
|
||||||
if not page:
|
if not page:
|
||||||
return None
|
return None
|
||||||
@ -219,6 +222,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 +251,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 +277,7 @@ 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')
|
||||||
finally:
|
finally:
|
||||||
if not page:
|
if not page:
|
||||||
return None
|
return None
|
||||||
@ -280,6 +286,7 @@ 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')
|
||||||
finally:
|
finally:
|
||||||
if not soup:
|
if not soup:
|
||||||
return None
|
return None
|
||||||
@ -308,6 +315,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,6 +341,7 @@ 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')
|
||||||
finally:
|
finally:
|
||||||
if not page:
|
if not page:
|
||||||
return None
|
return None
|
||||||
@ -341,6 +350,7 @@ class CWExtract(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')
|
||||||
finally:
|
finally:
|
||||||
if not soup:
|
if not soup:
|
||||||
return None
|
return None
|
||||||
@ -491,7 +501,12 @@ 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)
|
||||||
return ev.get_bible_chapter(self.download_name, book, chapter)
|
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
|
||||||
|
|
||||||
def get_books(self):
|
def get_books(self):
|
||||||
"""
|
"""
|
||||||
|
@ -261,6 +261,8 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
QtCore.SIGNAL(u'bibles_hideprogress'), self.onSearchProgressHide)
|
QtCore.SIGNAL(u'bibles_hideprogress'), self.onSearchProgressHide)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'bibles_nobook'), self.onNoBookFound)
|
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)
|
||||||
@ -367,6 +369,15 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
'No matching book could be found in this Bible.'))
|
'No matching book could be found in this Bible.'))
|
||||||
self.AdvancedSearchButton.setEnabled(True)
|
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,
|
||||||
|
Loading…
Reference in New Issue
Block a user