Fix Bug #792811 - Traceback UnicodeEncodeError while importing a webbible

If upgrade fails new bible databases now should be deleted always
This commit is contained in:
Armin Köhler 2011-06-04 20:43:59 +02:00
parent 9230fbb116
commit 937cfd2260
3 changed files with 7 additions and 6 deletions

View File

@ -586,8 +586,6 @@ class BibleUpgradeForm(OpenLPWizard):
if not meta[u'key'] == u'Version': if not meta[u'key'] == u'Version':
self.newbibles[number].create_meta(meta[u'key'], self.newbibles[number].create_meta(meta[u'key'],
meta[u'value']) meta[u'value'])
else:
self.newbibles[number].create_meta(meta[u'key'], name)
if meta[u'key'] == u'download source': if meta[u'key'] == u'download source':
webbible = True webbible = True
include_webbible = True include_webbible = True
@ -626,7 +624,7 @@ class BibleUpgradeForm(OpenLPWizard):
bible = BiblesResourcesDB.get_webbible( bible = BiblesResourcesDB.get_webbible(
meta_data[u'download name'], meta_data[u'download name'],
meta_data[u'download source'].lower()) meta_data[u'download source'].lower())
if bible[u'language_id']: if bible and bible[u'language_id']:
language_id = bible[u'language_id'] language_id = bible[u'language_id']
self.newbibles[number].create_meta(u'language_id', self.newbibles[number].create_meta(u'language_id',
language_id) language_id)
@ -744,6 +742,7 @@ class BibleUpgradeForm(OpenLPWizard):
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
self.newbibles[number].session.commit() self.newbibles[number].session.commit()
if not bible_failed: if not bible_failed:
self.newbibles[number].create_meta(u'Version', name)
self.incrementProgressBar(unicode(translate( self.incrementProgressBar(unicode(translate(
'BiblesPlugin.UpgradeWizardForm', 'BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\n' 'Upgrading Bible %s of %s: "%s"\n'

View File

@ -199,9 +199,10 @@ class BSExtract(object):
""" """
log.debug(u'BSExtract.get_bible_chapter("%s", "%s", "%s")', version, log.debug(u'BSExtract.get_bible_chapter("%s", "%s", "%s")', version,
bookname, chapter) bookname, chapter)
urlversion = urllib.quote(version.encode("utf-8"))
urlbookname = urllib.quote(bookname.encode("utf-8")) urlbookname = urllib.quote(bookname.encode("utf-8"))
chapter_url = u'http://m.bibleserver.com/text/%s/%s%s' % \ chapter_url = u'http://m.bibleserver.com/text/%s/%s%d' % \
(version, urlbookname, chapter) (urlversion, urlbookname, chapter)
header = (u'Accept-Language', u'en') header = (u'Accept-Language', u'en')
soup = get_soup_for_bible_ref(chapter_url, header) soup = get_soup_for_bible_ref(chapter_url, header)
if not soup: if not soup:
@ -230,8 +231,9 @@ class BSExtract(object):
The version of the Bible like NIV for New International Version The version of the Bible like NIV for New International Version
""" """
log.debug(u'BSExtract.get_books_from_http("%s")', 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?'\ chapter_url = u'http://m.bibleserver.com/overlay/selectBook?'\
'translation=%s' % (version) 'translation=%s' % (urlversion)
soup = get_soup_for_bible_ref(chapter_url) soup = get_soup_for_bible_ref(chapter_url)
if not soup: if not soup:
return None return None