openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #09824
[Merge] lp:~orangeshirt/openlp/bibles_fixes into lp:openlp
Armin Köhler has proposed merging lp:~orangeshirt/openlp/bibles_fixes into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Related bugs:
Bug #792811 in OpenLP: "Bible Upgrade wizard crashed"
https://bugs.launchpad.net/openlp/+bug/792811
Bug #792831 in OpenLP: "Bible Update Language Selection bugs"
https://bugs.launchpad.net/openlp/+bug/792831
For more details, see:
https://code.launchpad.net/~orangeshirt/openlp/bibles_fixes/+merge/63495
- Fix Bug #792811 - Traceback UnicodeEncodeError while importing a webbible
- If upgrade fails new bible databases which are failed now should be deleted always. If upgrade was successfull the old database is deleted immediately. So never should stay an old and a new version from one bible.
- changed behaviour if the user cancel the import so that after a traceback it is possible to cancel the dialog.
- Fix Bug #792831 - now the right parent is used for dialogs and error messages
- Biblegateway.com has changed it's Bible-Book-List Layout. Addapt the regex for importing the booklist of a bible from biblegateway to the new html layout.
- changed log usage
- remove unnecessary code
- small fixes
--
https://code.launchpad.net/~orangeshirt/openlp/bibles_fixes/+merge/63495
Your team OpenLP Core is requested to review the proposed merge of lp:~orangeshirt/openlp/bibles_fixes into lp:openlp.
=== modified file 'openlp/plugins/bibles/forms/bibleupgradeform.py'
--- openlp/plugins/bibles/forms/bibleupgradeform.py 2011-06-04 13:52:26 +0000
+++ openlp/plugins/bibles/forms/bibleupgradeform.py 2011-06-05 17:54:23 +0000
@@ -115,6 +115,8 @@
self.stop_import_flag = True
if not self.currentPage() == self.progressPage:
self.done(QtGui.QDialog.Rejected)
+ else:
+ self.postWizard()
def onCurrentIdChanged(self, pageId):
"""
@@ -127,14 +129,6 @@
elif self.page(pageId) == self.selectPage and self.maxBibles == 0:
self.next()
- def onFinishButton(self):
- """
- Some cleanup while finishing
- """
- for number, filename in enumerate(self.files):
- if number in self.success and self.success[number] == True:
- delete_file(os.path.join(self.path, filename[0]))
-
def onBackupBrowseButtonClicked(self):
"""
Show the file open dialog for the OSIS file.
@@ -180,8 +174,6 @@
"""
Set up the signals used in the bible importer.
"""
- QtCore.QObject.connect(self.finishButton,
- QtCore.SIGNAL(u'clicked()'), self.onFinishButton)
QtCore.QObject.connect(self.backupBrowseButton,
QtCore.SIGNAL(u'clicked()'), self.onBackupBrowseButtonClicked)
QtCore.QObject.connect(self.noBackupCheckBox,
@@ -536,7 +528,7 @@
"""
Perform the actual upgrade.
"""
- include_webbible = False
+ self.include_webbible = False
proxy_server = None
if self.maxBibles == 0:
self.progressLabel.setText(
@@ -578,19 +570,19 @@
name = unicode(self.versionNameEdit[biblenumber].text())
self.newbibles[number] = BibleDB(self.mediaItem, path=self.path,
name=name)
+ self.newbibles[number].register(self.plugin.upgrade_wizard)
metadata = oldbible.get_metadata()
webbible = False
meta_data = {}
for meta in metadata:
meta_data[meta[u'key']] = meta[u'value']
- if not meta[u'key'] == u'Version':
+ if not meta[u'key'] == u'Version' and not meta[u'key'] == \
+ u'dbversion':
self.newbibles[number].create_meta(meta[u'key'],
meta[u'value'])
- else:
- self.newbibles[number].create_meta(meta[u'key'], name)
if meta[u'key'] == u'download source':
webbible = True
- include_webbible = True
+ self.include_webbible = True
if meta.has_key(u'proxy server'):
proxy_server = meta[u'proxy server']
if webbible:
@@ -606,8 +598,7 @@
u'name: "%s" failed' % (
meta_data[u'download source'],
meta_data[u'download name']))
- delete_database(self.path,
- clean_filename(self.newbibles[number].get_name()))
+ delete_database(self.path, clean_filename(name))
del self.newbibles[number]
critical_error_message_box(
translate('BiblesPlugin.UpgradeWizardForm',
@@ -626,7 +617,7 @@
bible = BiblesResourcesDB.get_webbible(
meta_data[u'download name'],
meta_data[u'download source'].lower())
- if bible[u'language_id']:
+ if bible and bible[u'language_id']:
language_id = bible[u'language_id']
self.newbibles[number].create_meta(u'language_id',
language_id)
@@ -634,8 +625,7 @@
language_id = self.newbibles[number].get_language(name)
if not language_id:
log.warn(u'Upgrading from "%s" failed' % filename[0])
- delete_database(self.path,
- clean_filename(self.newbibles[number].get_name()))
+ delete_database(self.path, clean_filename(name))
del self.newbibles[number]
self.incrementProgressBar(unicode(translate(
'BiblesPlugin.UpgradeWizardForm',
@@ -661,8 +651,7 @@
u'name: "%s" aborted by user' % (
meta_data[u'download source'],
meta_data[u'download name']))
- delete_database(self.path,
- clean_filename(self.newbibles[number].get_name()))
+ delete_database(self.path, clean_filename(name))
del self.newbibles[number]
bible_failed = True
break
@@ -693,8 +682,7 @@
language_id = self.newbibles[number].get_language(name)
if not language_id:
log.warn(u'Upgrading books from "%s" failed' % name)
- delete_database(self.path,
- clean_filename(self.newbibles[number].get_name()))
+ delete_database(self.path, clean_filename(name))
del self.newbibles[number]
self.incrementProgressBar(unicode(translate(
'BiblesPlugin.UpgradeWizardForm',
@@ -720,8 +708,7 @@
if not book_ref_id:
log.warn(u'Upgrading books from %s " '\
'failed - aborted by user' % name)
- delete_database(self.path,
- clean_filename(self.newbibles[number].get_name()))
+ delete_database(self.path, clean_filename(name))
del self.newbibles[number]
bible_failed = True
break
@@ -744,6 +731,8 @@
Receiver.send_message(u'openlp_process_events')
self.newbibles[number].session.commit()
if not bible_failed:
+ self.newbibles[number].create_meta(u'Version', name)
+ delete_file(os.path.join(self.path, filename[0]))
self.incrementProgressBar(unicode(translate(
'BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\n'
@@ -756,10 +745,13 @@
'Upgrading Bible %s of %s: "%s"\nFailed')) %
(number + 1, self.maxBibles, name),
self.progressBar.maximum() - self.progressBar.value())
- delete_database(self.path,
- clean_filename(name))
+ delete_database(self.path, clean_filename(name))
number += 1
- self.mediaItem.reloadBibles()
+
+ def postWizard(self):
+ """
+ Clean up the UI after the import has finished.
+ """
successful_import = 0
failed_import = 0
for number, filename in enumerate(self.files):
@@ -774,7 +766,7 @@
else:
failed_import_text = u''
if successful_import > 0:
- if include_webbible:
+ if self.include_webbible:
self.progressLabel.setText(unicode(
translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading '
'Bible(s): %s successful%s\nPlease note, that verses from '
@@ -790,3 +782,4 @@
self.progressLabel.setText(
translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade '
'failed.'))
+ OpenLPWizard.postWizard(self)
=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py 2011-05-31 07:31:38 +0000
+++ openlp/plugins/bibles/lib/http.py 2011-06-05 17:54:23 +0000
@@ -109,7 +109,7 @@
try:
clean_verse_num = int(str(raw_verse_num))
except ValueError:
- log.exception(u'Illegal verse number in %s %s %s:%s',
+ log.warn(u'Illegal verse number in %s %s %s:%s',
version, bookname, chapter, unicode(raw_verse_num))
if clean_verse_num:
verse_text = raw_verse_num.next
@@ -139,16 +139,17 @@
"""
log.debug(u'BGExtract.get_books_from_http("%s")', version)
url_params = urllib.urlencode(
- {u'search': 'Bible-List', u'version': u'%s' % version})
- reference_url = u'http://www.biblegateway.com/passage/?%s' % url_params
+ {u'action': 'getVersionInfo', u'vid': u'%s' % version})
+ reference_url = u'http://www.biblegateway.com/versions/?%s#books' % \
+ url_params
page = get_web_page(reference_url)
if not page:
send_error_message(u'download')
return None
page_source = page.read()
page_source = unicode(page_source, 'utf8')
- page_source_temp = re.search(u'<table id="booklist".*?>.*?</table>', \
- page_source, re.DOTALL)
+ page_source_temp = re.search(u'<table .*?class="infotable".*?>.*?'\
+ u'</table>', page_source, re.DOTALL)
if page_source_temp:
soup = page_source_temp.group(0)
else:
@@ -156,15 +157,17 @@
try:
soup = BeautifulSoup(soup)
except HTMLParseError:
- log.exception(u'BeautifulSoup could not parse the Bible page.')
+ log.error(u'BeautifulSoup could not parse the Bible page.')
+ send_error_message(u'parse')
+ return None
if not soup:
send_error_message(u'parse')
return None
Receiver.send_message(u'openlp_process_events')
- content = soup.find(u'table', {u'id': u'booklist'})
+ content = soup.find(u'table', {u'class': u'infotable'})
content = content.findAll(u'tr')
if not content:
- log.exception(u'No books found in the Biblegateway response.')
+ log.error(u'No books found in the Biblegateway response.')
send_error_message(u'parse')
return None
books = []
@@ -199,9 +202,10 @@
"""
log.debug(u'BSExtract.get_bible_chapter("%s", "%s", "%s")', version,
bookname, chapter)
+ urlversion = urllib.quote(version.encode("utf-8"))
urlbookname = urllib.quote(bookname.encode("utf-8"))
- chapter_url = u'http://m.bibleserver.com/text/%s/%s%s' % \
- (version, urlbookname, chapter)
+ chapter_url = u'http://m.bibleserver.com/text/%s/%s%d' % \
+ (urlversion, urlbookname, chapter)
header = (u'Accept-Language', u'en')
soup = get_soup_for_bible_ref(chapter_url, header)
if not soup:
@@ -209,7 +213,7 @@
Receiver.send_message(u'openlp_process_events')
content = soup.find(u'div', u'content')
if not content:
- log.exception(u'No verses found in the Bibleserver response.')
+ log.error(u'No verses found in the Bibleserver response.')
send_error_message(u'parse')
return None
content = content.find(u'div').findAll(u'div')
@@ -230,14 +234,15 @@
The version of the Bible like NIV for New International Version
"""
log.debug(u'BSExtract.get_books_from_http("%s")', version)
+ urlversion = urllib.quote(version.encode("utf-8"))
chapter_url = u'http://m.bibleserver.com/overlay/selectBook?'\
- 'translation=%s' % (version)
+ 'translation=%s' % (urlversion)
soup = get_soup_for_bible_ref(chapter_url)
if not soup:
return None
content = soup.find(u'ul')
if not content:
- log.exception(u'No books found in the Bibleserver response.')
+ log.error(u'No books found in the Bibleserver response.')
send_error_message(u'parse')
return None
content = content.findAll(u'li')
@@ -281,7 +286,7 @@
Receiver.send_message(u'openlp_process_events')
htmlverses = soup.findAll(u'span', u'versetext')
if not htmlverses:
- log.debug(u'No verses found in the CrossWalk response.')
+ log.error(u'No verses found in the CrossWalk response.')
send_error_message(u'parse')
return None
verses = {}
@@ -333,7 +338,7 @@
content = soup.find(u'div', {u'class': u'Body'})
content = content.find(u'ul', {u'class': u'parent'})
if not content:
- log.exception(u'No books found in the Crosswalk response.')
+ log.error(u'No books found in the Crosswalk response.')
send_error_message(u'parse')
return None
content = content.findAll(u'li')
=== modified file 'openlp/plugins/bibles/resources/bibles_resources.sqlite'
Binary files openlp/plugins/bibles/resources/bibles_resources.sqlite 2011-05-02 18:20:38 +0000 and openlp/plugins/bibles/resources/bibles_resources.sqlite 2011-06-05 17:54:23 +0000 differ
Follow ups