forked from openlp/openlp
Fixed bug #1077654 where there were more classes in the CSS, but we were specifically looking for only one class. Made the code less brittle.
Fixes: https://launchpad.net/bugs/1077654
This commit is contained in:
parent
e90af50fd6
commit
b76be3d6b8
@ -85,11 +85,13 @@ def upgrade_db(url, upgrade):
|
|||||||
Provides a class for the metadata table.
|
Provides a class for the metadata table.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
load_changes = True
|
load_changes = False
|
||||||
|
tables = []
|
||||||
try:
|
try:
|
||||||
tables = upgrade.upgrade_setup(metadata)
|
tables = upgrade.upgrade_setup(metadata)
|
||||||
|
load_changes = True
|
||||||
except (SQLAlchemyError, DBAPIError):
|
except (SQLAlchemyError, DBAPIError):
|
||||||
load_changes = False
|
pass
|
||||||
metadata_table = Table(u'metadata', metadata,
|
metadata_table = Table(u'metadata', metadata,
|
||||||
Column(u'key', types.Unicode(64), primary_key=True),
|
Column(u'key', types.Unicode(64), primary_key=True),
|
||||||
Column(u'value', types.UnicodeText(), default=None)
|
Column(u'value', types.UnicodeText(), default=None)
|
||||||
@ -99,6 +101,7 @@ def upgrade_db(url, upgrade):
|
|||||||
version_meta = session.query(Metadata).get(u'version')
|
version_meta = session.query(Metadata).get(u'version')
|
||||||
if version_meta is None:
|
if version_meta is None:
|
||||||
version_meta = Metadata.populate(key=u'version', value=u'0')
|
version_meta = Metadata.populate(key=u'version', value=u'0')
|
||||||
|
session.add(version_meta)
|
||||||
version = 0
|
version = 0
|
||||||
else:
|
else:
|
||||||
version = int(version_meta.value)
|
version = int(version_meta.value)
|
||||||
@ -111,17 +114,17 @@ def upgrade_db(url, upgrade):
|
|||||||
try:
|
try:
|
||||||
getattr(upgrade, u'upgrade_%d' % version) \
|
getattr(upgrade, u'upgrade_%d' % version) \
|
||||||
(session, metadata, tables)
|
(session, metadata, tables)
|
||||||
version_meta.value = unicode(version)
|
|
||||||
except (SQLAlchemyError, DBAPIError):
|
except (SQLAlchemyError, DBAPIError):
|
||||||
log.exception(u'Could not run database upgrade script '
|
log.exception(u'Could not run database upgrade script '
|
||||||
'"upgrade_%s", upgrade process has been halted.', version)
|
'"upgrade_%s", upgrade process has been halted.', version)
|
||||||
break
|
break
|
||||||
|
version_meta.value = unicode(version)
|
||||||
|
session.commit()
|
||||||
version += 1
|
version += 1
|
||||||
else:
|
else:
|
||||||
version_meta = Metadata.populate(key=u'version',
|
version_meta = Metadata.populate(key=u'version',
|
||||||
value=int(upgrade.__version__))
|
value=int(upgrade.__version__))
|
||||||
session.add(version_meta)
|
session.commit()
|
||||||
session.commit()
|
|
||||||
return int(version_meta.value), upgrade.__version__
|
return int(version_meta.value), upgrade.__version__
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,14 +279,8 @@ class BGExtract(object):
|
|||||||
page_source = unicode(page_source, u'utf8')
|
page_source = unicode(page_source, u'utf8')
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
page_source = unicode(page_source, u'cp1251')
|
page_source = unicode(page_source, u'cp1251')
|
||||||
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:
|
|
||||||
soup = None
|
|
||||||
try:
|
try:
|
||||||
soup = BeautifulSoup(soup)
|
soup = BeautifulSoup(page_source)
|
||||||
except HTMLParseError:
|
except HTMLParseError:
|
||||||
log.error(u'BeautifulSoup could not parse the Bible page.')
|
log.error(u'BeautifulSoup could not parse the Bible page.')
|
||||||
send_error_message(u'parse')
|
send_error_message(u'parse')
|
||||||
@ -295,8 +289,9 @@ class BGExtract(object):
|
|||||||
send_error_message(u'parse')
|
send_error_message(u'parse')
|
||||||
return None
|
return None
|
||||||
Receiver.send_message(u'openlp_process_events')
|
Receiver.send_message(u'openlp_process_events')
|
||||||
content = soup.find(u'table', {u'class': u'infotable'})
|
content = soup.find(u'table', u'infotable')
|
||||||
content = content.findAll(u'tr')
|
if content:
|
||||||
|
content = content.findAll(u'tr')
|
||||||
if not content:
|
if not content:
|
||||||
log.error(u'No books found in the Biblegateway response.')
|
log.error(u'No books found in the Biblegateway response.')
|
||||||
send_error_message(u'parse')
|
send_error_message(u'parse')
|
||||||
|
Loading…
Reference in New Issue
Block a user