forked from openlp/openlp
Further fixes
This commit is contained in:
parent
75c9391d8e
commit
fb20f9243f
@ -28,9 +28,9 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
class HistoryComboBox(QtGui.QComboBox):
|
||||
"""
|
||||
The :class:`~openlp.core.common.historycombobox.HistoryComboBox` widget emulates the QLineEdit ``returnPressed`` signal
|
||||
for when the :kbd:`Enter` or :kbd:`Return` keys are pressed, and saves anything that is typed into the edit box into
|
||||
its list.
|
||||
The :class:`~openlp.core.common.historycombobox.HistoryComboBox` widget emulates the QLineEdit ``returnPressed``
|
||||
signal for when the :kbd:`Enter` or :kbd:`Return` keys are pressed, and saves anything that is typed into the edit
|
||||
box into its list.
|
||||
"""
|
||||
returnPressed = QtCore.pyqtSignal()
|
||||
|
||||
|
@ -30,6 +30,7 @@ log = logging.getLogger(__name__)
|
||||
__version__ = 1
|
||||
|
||||
|
||||
# TODO: When removing an upgrade path the ftw-data needs updating to the minimum supported version
|
||||
def upgrade_1(session, metadata):
|
||||
"""
|
||||
Version 1 upgrade.
|
||||
@ -38,132 +39,162 @@ def upgrade_1(session, metadata):
|
||||
"""
|
||||
metadata_table = metadata.tables['metadata']
|
||||
# Copy "Version" to "name" ("version" used by upgrade system)
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='name',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'Version'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'Version'))
|
||||
try:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='name',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'Version'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'Version'))
|
||||
except:
|
||||
log.exception('Exception when upgrading Version')
|
||||
# Copy "Copyright" to "copyright"
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='copyright',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'Copyright'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'Copyright'))
|
||||
try:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='copyright',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'Copyright'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'Copyright'))
|
||||
except:
|
||||
log.exception('Exception when upgrading Copyright')
|
||||
# Copy "Permissions" to "permissions"
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='permissions',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'Permissions'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'Permissions'))
|
||||
try:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='permissions',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'Permissions'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'Permissions'))
|
||||
except:
|
||||
log.exception('Exception when upgrading Permissions')
|
||||
# Copy "Bookname language" to "book_name_language"
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'Bookname language'
|
||||
)
|
||||
).scalar()
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='book_name_language',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
try:
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'Bookname language'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'Bookname language'))
|
||||
)
|
||||
).scalar()
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='book_name_language',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'Bookname language'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'Bookname language'))
|
||||
except:
|
||||
log.exception('Exception when upgrading Bookname language')
|
||||
# Copy "download source" to "download_source"
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'download source'
|
||||
)
|
||||
).scalar()
|
||||
log.debug('download source: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='download_source',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
try:
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'download source'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'download source'))
|
||||
)
|
||||
).scalar()
|
||||
log.debug('download source: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='download_source',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'download source'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'download source'))
|
||||
except:
|
||||
log.exception('Exception when upgrading download source')
|
||||
# Copy "download name" to "download_name"
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'download name'
|
||||
)
|
||||
).scalar()
|
||||
log.debug('download name: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='download_name',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
try:
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'download name'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'download name'))
|
||||
)
|
||||
).scalar()
|
||||
log.debug('download name: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='download_name',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'download name'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'download name'))
|
||||
except:
|
||||
log.exception('Exception when upgrading download name')
|
||||
# Copy "proxy server" to "proxy_server"
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'proxy server'
|
||||
)
|
||||
).scalar()
|
||||
log.debug('proxy server: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='proxy_server',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
try:
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'proxy server'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'proxy server'))
|
||||
)
|
||||
).scalar()
|
||||
log.debug('proxy server: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='proxy_server',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'proxy server'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'proxy server'))
|
||||
except:
|
||||
log.exception('Exception when upgrading proxy server')
|
||||
# Copy "proxy username" to "proxy_username"
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'proxy username'
|
||||
)
|
||||
).scalar()
|
||||
log.debug('proxy username: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='proxy_username',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
try:
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'proxy username'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'proxy username'))
|
||||
)
|
||||
).scalar()
|
||||
log.debug('proxy username: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='proxy_username',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'proxy username'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'proxy username'))
|
||||
except:
|
||||
log.exception('Exception when upgrading proxy username')
|
||||
# Copy "proxy password" to "proxy_password"
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'proxy password'
|
||||
)
|
||||
).scalar()
|
||||
log.debug('proxy password: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='proxy_password',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
try:
|
||||
value_count = session.execute(
|
||||
select(
|
||||
[func.count(metadata_table.c.value)],
|
||||
metadata_table.c.key == 'proxy password'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'proxy password'))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'dbversion'))
|
||||
)
|
||||
).scalar()
|
||||
log.debug('proxy password: %s', value_count)
|
||||
if value_count > 0:
|
||||
session.execute(insert(metadata_table).values(
|
||||
key='proxy_password',
|
||||
value=select(
|
||||
[metadata_table.c.value],
|
||||
metadata_table.c.key == 'proxy password'
|
||||
).as_scalar()
|
||||
))
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'proxy password'))
|
||||
except:
|
||||
log.exception('Exception when upgrading proxy password')
|
||||
try:
|
||||
session.execute(delete(metadata_table).where(metadata_table.c.key == 'dbversion'))
|
||||
except:
|
||||
log.exception('Exception when deleting dbversion')
|
||||
session.commit()
|
||||
|
@ -35,6 +35,7 @@ log = logging.getLogger(__name__)
|
||||
__version__ = 4
|
||||
|
||||
|
||||
# TODO: When removing an upgrade path the ftw-data needs updating to the minimum supported version
|
||||
def upgrade_1(session, metadata):
|
||||
"""
|
||||
Version 1 upgrade.
|
||||
|
Loading…
Reference in New Issue
Block a user