This commit is contained in:
Tim Bentley 2012-11-11 19:27:52 +00:00
commit 13cf482495
3 changed files with 14 additions and 16 deletions

View File

@ -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__

View File

@ -109,7 +109,7 @@ class Ui_AboutDialog(object):
contributors = [u'Gerald "jerryb" Britton', contributors = [u'Gerald "jerryb" Britton',
u'Samuel "MrGamgee" Findlay', u'Scott "sguerrieri" Guerrieri', u'Samuel "MrGamgee" Findlay', u'Scott "sguerrieri" Guerrieri',
u'Matthias "matthub" Hub', u'Meinert "m2j" Jordan', u'Matthias "matthub" Hub', u'Meinert "m2j" Jordan',
u'Armin "orangeshirt" K\xf6hler', u'Eric "luen" Ludin', u'Armin "orangeshirt" K\xf6hler', u'Erik "luen" Lundin',
u'Edwin "edwinlunando" Lunando', u'Brian "brianmeyer" Meyer', u'Edwin "edwinlunando" Lunando', u'Brian "brianmeyer" Meyer',
u'Joshua "milleja46" Miller', u'Stevan "ElderP" Pettit', u'Joshua "milleja46" Miller', u'Stevan "ElderP" Pettit',
u'Mattias "mahfiaz" P\xf5ldaru', u'Christian "crichter" Richter', u'Mattias "mahfiaz" P\xf5ldaru', u'Christian "crichter" Richter',
@ -149,7 +149,7 @@ class Ui_AboutDialog(object):
u'Gustavo Bim', u'Rog\xeanio Bel\xe9m', u'Samuel' u'Gustavo Bim', u'Rog\xeanio Bel\xe9m', u'Samuel'
u'Simon "samscudder" Scudder', u'Van Der Fran'], u'Simon "samscudder" Scudder', u'Van Der Fran'],
u'ru': [u'Sergey "ratz" Ratz'], u'ru': [u'Sergey "ratz" Ratz'],
u'sv': [u'Eric "luen" Ludin'] u'sv': [u'Erik "luen" Lundin']
} }
documentors = [u'Wesley "wrst" Stout', documentors = [u'Wesley "wrst" Stout',
u'John "jseagull1" Cegalis (lead)'] u'John "jseagull1" Cegalis (lead)']

View File

@ -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')