forked from openlp/openlp
HEAD
This commit is contained in:
commit
87c21201e7
@ -17,7 +17,6 @@ Contents:
|
|||||||
|
|
||||||
openlp
|
openlp
|
||||||
core/index
|
core/index
|
||||||
migration/index
|
|
||||||
plugins/index
|
plugins/index
|
||||||
|
|
||||||
Indices and tables
|
Indices and tables
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
.. _migration-index:
|
|
||||||
|
|
||||||
:mod:`migration` Module
|
|
||||||
=======================
|
|
||||||
|
|
||||||
.. automodule:: openlp.migration
|
|
||||||
:members:
|
|
||||||
|
|
||||||
:mod:`display` Submodule
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
.. automodule:: openlp.migration.display
|
|
||||||
:members:
|
|
||||||
|
|
||||||
:mod:`migratebibles` Submodule
|
|
||||||
------------------------------
|
|
||||||
|
|
||||||
.. automodule:: openlp.migration.migratebibles
|
|
||||||
:members:
|
|
||||||
|
|
||||||
:mod:`migratefiles` Submodule
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
.. automodule:: openlp.migration.migratefiles
|
|
||||||
:members:
|
|
||||||
|
|
||||||
:mod:`migratesongs` Submodule
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
.. automodule:: openlp.migration.migratesongs
|
|
||||||
:members:
|
|
||||||
|
|
@ -97,11 +97,10 @@ def build_icon(icon):
|
|||||||
The icon to build. This can be a QIcon, a resource string in the form
|
The icon to build. This can be a QIcon, a resource string in the form
|
||||||
``:/resource/file.png``, or a file location like ``/path/to/file.png``.
|
``:/resource/file.png``, or a file location like ``/path/to/file.png``.
|
||||||
"""
|
"""
|
||||||
button_icon = None
|
button_icon = QtGui.QIcon()
|
||||||
if isinstance(icon, QtGui.QIcon):
|
if isinstance(icon, QtGui.QIcon):
|
||||||
button_icon = icon
|
button_icon = icon
|
||||||
elif isinstance(icon, basestring):
|
elif isinstance(icon, basestring):
|
||||||
button_icon = QtGui.QIcon()
|
|
||||||
if icon.startswith(u':/'):
|
if icon.startswith(u':/'):
|
||||||
button_icon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal,
|
button_icon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal,
|
||||||
QtGui.QIcon.Off)
|
QtGui.QIcon.Off)
|
||||||
@ -109,7 +108,6 @@ def build_icon(icon):
|
|||||||
button_icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
|
button_icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
|
||||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
elif isinstance(icon, QtGui.QImage):
|
elif isinstance(icon, QtGui.QImage):
|
||||||
button_icon = QtGui.QIcon()
|
|
||||||
button_icon.addPixmap(QtGui.QPixmap.fromImage(icon),
|
button_icon.addPixmap(QtGui.QPixmap.fromImage(icon),
|
||||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
return button_icon
|
return button_icon
|
||||||
|
@ -72,9 +72,6 @@ class OpenLPToolbar(QtGui.QToolBar):
|
|||||||
ToolbarButton = None
|
ToolbarButton = None
|
||||||
if icon:
|
if icon:
|
||||||
ButtonIcon = build_icon(icon)
|
ButtonIcon = build_icon(icon)
|
||||||
else:
|
|
||||||
ButtonIcon = None
|
|
||||||
if ButtonIcon:
|
|
||||||
if slot and not checkable:
|
if slot and not checkable:
|
||||||
ToolbarButton = self.addAction(ButtonIcon, title, slot)
|
ToolbarButton = self.addAction(ButtonIcon, title, slot)
|
||||||
else:
|
else:
|
||||||
|
@ -30,6 +30,7 @@ import os.path
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import ThemeXML, translate
|
from openlp.core.lib import ThemeXML, translate
|
||||||
|
from openlp.core.utils import get_images_filter
|
||||||
from amendthemedialog import Ui_AmendThemeDialog
|
from amendthemedialog import Ui_AmendThemeDialog
|
||||||
|
|
||||||
log = logging.getLogger(u'AmendThemeForm')
|
log = logging.getLogger(u'AmendThemeForm')
|
||||||
@ -209,8 +210,11 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
self.previewTheme()
|
self.previewTheme()
|
||||||
|
|
||||||
def onImageToolButtonClicked(self):
|
def onImageToolButtonClicked(self):
|
||||||
filename = unicode(QtGui.QFileDialog.getOpenFileName(
|
images_filter = get_images_filter()
|
||||||
self, translate('AmendThemeForm', 'Open File')))
|
images_filter = '%s;;%s (*.*) (*)' % (images_filter,
|
||||||
|
translate('AmendThemeForm', 'All Files'))
|
||||||
|
filename = QtGui.QFileDialog.getOpenFileName(self,
|
||||||
|
translate('AmendThemeForm', 'Select Image'), u'', images_filter)
|
||||||
if filename:
|
if filename:
|
||||||
self.ImageLineEdit.setText(filename)
|
self.ImageLineEdit.setText(filename)
|
||||||
self.theme.background_filename = filename
|
self.theme.background_filename = filename
|
||||||
|
@ -30,17 +30,20 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import urllib2
|
import urllib2
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from PyQt4 import QtCore
|
|
||||||
|
from PyQt4 import QtGui, QtCore
|
||||||
|
|
||||||
import openlp
|
import openlp
|
||||||
|
from openlp.core.lib import translate
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
images_filter = None
|
||||||
|
|
||||||
class AppLocation(object):
|
class AppLocation(object):
|
||||||
"""
|
"""
|
||||||
Retrieve a directory based on the directory type.
|
The :class:`AppLocation` class is a static class which retrieves a
|
||||||
|
directory based on the directory type.
|
||||||
"""
|
"""
|
||||||
AppDir = 1
|
AppDir = 1
|
||||||
ConfigDir = 2
|
ConfigDir = 2
|
||||||
@ -176,6 +179,22 @@ def get_filesystem_encoding():
|
|||||||
encoding = sys.getdefaultencoding()
|
encoding = sys.getdefaultencoding()
|
||||||
return encoding
|
return encoding
|
||||||
|
|
||||||
|
def get_images_filter():
|
||||||
|
"""
|
||||||
|
Returns a filter string for a file dialog containing all the supported
|
||||||
|
image formats.
|
||||||
|
"""
|
||||||
|
global images_filter
|
||||||
|
if not images_filter:
|
||||||
|
log.debug(u'Generating images filter.')
|
||||||
|
formats = [unicode(fmt)
|
||||||
|
for fmt in QtGui.QImageReader.supportedImageFormats()]
|
||||||
|
visible_formats = u'(*.%s)' % u'; *.'.join(formats)
|
||||||
|
actual_formats = u'(*.%s)' % u' *.'.join(formats)
|
||||||
|
images_filter = u'%s %s %s' % (translate('OpenLP', 'Image Files'),
|
||||||
|
visible_formats, actual_formats)
|
||||||
|
return images_filter
|
||||||
|
|
||||||
from languagemanager import LanguageManager
|
from languagemanager import LanguageManager
|
||||||
|
|
||||||
__all__ = [u'AppLocation', u'check_latest_version', u'add_actions',
|
__all__ = [u'AppLocation', u'check_latest_version', u'add_actions',
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
|
||||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
|
||||||
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
|
|
||||||
# Thompson, Jon Tibble, Carsten Tinggaard #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
|
||||||
# Software Foundation; version 2 of the License. #
|
|
||||||
# #
|
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
||||||
# more details. #
|
|
||||||
# #
|
|
||||||
# You should have received a copy of the GNU General Public License along #
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
||||||
###############################################################################
|
|
@ -1,42 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
|
||||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
|
||||||
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
|
|
||||||
# Thompson, Jon Tibble, Carsten Tinggaard #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
|
||||||
# Software Foundation; version 2 of the License. #
|
|
||||||
# #
|
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
||||||
# more details. #
|
|
||||||
# #
|
|
||||||
# You should have received a copy of the GNU General Public License along #
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
class Display(object):
|
|
||||||
log.info(u'Display Class loaded')
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def output(string):
|
|
||||||
log.debug(string)
|
|
||||||
#print (string)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def sub_output(string):
|
|
||||||
if not string is None:
|
|
||||||
log.debug(u' '+string)
|
|
||||||
#print (u' '+string)
|
|
@ -1,198 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
|
||||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
|
||||||
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
|
|
||||||
# Thompson, Jon Tibble, Carsten Tinggaard #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
|
||||||
# Software Foundation; version 2 of the License. #
|
|
||||||
# #
|
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
||||||
# more details. #
|
|
||||||
# #
|
|
||||||
# You should have received a copy of the GNU General Public License along #
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import sqlite3
|
|
||||||
|
|
||||||
from sqlalchemy.exceptions import InvalidRequestError
|
|
||||||
from sqlalchemy.orm import mapper
|
|
||||||
|
|
||||||
from openlp.core.lib import BaseModel, SettingsManager
|
|
||||||
from openlp.core.utils import AppLocation
|
|
||||||
from openlp.plugins.bibles.lib.models import *
|
|
||||||
|
|
||||||
class TBibleMeta(BaseModel):
|
|
||||||
"""
|
|
||||||
Bible Meta Data
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
class TTestament(BaseModel):
|
|
||||||
"""
|
|
||||||
Bible Testaments
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
class TBook(BaseModel):
|
|
||||||
"""
|
|
||||||
Song model
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
class TVerse(BaseModel):
|
|
||||||
"""
|
|
||||||
Topic model
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
temp_meta_table = Table(u'metadata_temp', metadata,
|
|
||||||
Column(u'key', types.Unicode(255), primary_key=True),
|
|
||||||
Column(u'value', types.Unicode(255)),
|
|
||||||
)
|
|
||||||
temp_testament_table = Table(u'testament_temp', metadata,
|
|
||||||
Column(u'id', types.Integer, primary_key=True),
|
|
||||||
Column(u'name', types.Unicode(30)),
|
|
||||||
)
|
|
||||||
temp_book_table = Table(u'book_temp', metadata,
|
|
||||||
Column(u'id', types.Integer, primary_key=True),
|
|
||||||
Column(u'testament_id', types.Integer),
|
|
||||||
Column(u'name', types.Unicode(30)),
|
|
||||||
Column(u'abbreviation', types.Unicode(5)),
|
|
||||||
)
|
|
||||||
temp_verse_table = Table(u'verse_temp', metadata,
|
|
||||||
Column(u'id', types.Integer, primary_key=True),
|
|
||||||
Column(u'book_id', types.Integer),
|
|
||||||
Column(u'chapter', types.Integer),
|
|
||||||
Column(u'verse', types.Integer),
|
|
||||||
Column(u'text', types.UnicodeText),
|
|
||||||
)
|
|
||||||
|
|
||||||
mapper(TBibleMeta, temp_meta_table)
|
|
||||||
mapper(TTestament, temp_testament_table)
|
|
||||||
mapper(TBook, temp_book_table)
|
|
||||||
mapper(TVerse, temp_verse_table)
|
|
||||||
|
|
||||||
class MigrateBibles(object):
|
|
||||||
def __init__(self, display):
|
|
||||||
self.display = display
|
|
||||||
self.data_path = AppLocation.get_section_data_path(u'bibles')
|
|
||||||
self.database_files = SettingsManager.get_files(u'bibles', u'.sqlite')
|
|
||||||
print self.database_files
|
|
||||||
|
|
||||||
def progress(self, text):
|
|
||||||
print text
|
|
||||||
self.display.output(text)
|
|
||||||
|
|
||||||
def process(self):
|
|
||||||
self.progress(u'Bibles processing started')
|
|
||||||
for db_file in self.database_files:
|
|
||||||
self.v_1_9_0(db_file)
|
|
||||||
self.progress(u'Bibles processing finished')
|
|
||||||
|
|
||||||
def v_1_9_0(self, database):
|
|
||||||
self.progress(u'Migration 1.9.0 Started for ' + database)
|
|
||||||
self._v1_9_0_old(database)
|
|
||||||
self._v1_9_0_new(database)
|
|
||||||
self._v1_9_0_cleanup(database)
|
|
||||||
self.progress(u'Migration 1.9.0 Finished for ' + database)
|
|
||||||
|
|
||||||
def _v1_9_0_old(self, database):
|
|
||||||
self.progress(u'Rename Tables ' + database)
|
|
||||||
conn = sqlite3.connect(os.path.join(self.data_path, database))
|
|
||||||
conn.execute(u'alter table book rename to book_temp;')
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'alter table testament rename to testament_temp;')
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'alter table verse rename to verse_temp;')
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'alter table metadata rename to metadata_temp;')
|
|
||||||
conn.commit()
|
|
||||||
|
|
||||||
def _v1_9_0_new(self, database):
|
|
||||||
self.progress(u'Create new Tables ' + database)
|
|
||||||
self.db_url = u'sqlite:///' + self.data_path + u'/' + database
|
|
||||||
print self.db_url
|
|
||||||
self.session = init_models(self.db_url)
|
|
||||||
metadata.create_all(checkfirst=True)
|
|
||||||
self.progress(u'Create testament table')
|
|
||||||
results = self.session.query(TTestament).order_by(TTestament.id).all()
|
|
||||||
for testament_temp in results:
|
|
||||||
testament = Testament()
|
|
||||||
testament.id = testament_temp.id
|
|
||||||
testament.name = testament_temp.name
|
|
||||||
try:
|
|
||||||
self.session.add(testament)
|
|
||||||
self.session.commit()
|
|
||||||
except InvalidRequestError:
|
|
||||||
self.session.rollback()
|
|
||||||
print u'Error thrown = ', sys.exc_info()[1]
|
|
||||||
self.progress(u'Create book table')
|
|
||||||
results = self.session.query(TBook).order_by(TBook.id).all()
|
|
||||||
for book_temp in results:
|
|
||||||
book = Book()
|
|
||||||
book.id = book_temp.id
|
|
||||||
book.testament_id = book_temp.testament_id
|
|
||||||
book.name = book_temp.name
|
|
||||||
book.abbreviation = book_temp.abbreviation
|
|
||||||
try:
|
|
||||||
self.session.add(book)
|
|
||||||
self.session.commit()
|
|
||||||
except InvalidRequestError:
|
|
||||||
self.session.rollback()
|
|
||||||
print u'Error thrown = ', sys.exc_info()[1]
|
|
||||||
self.progress(u'Create verse table')
|
|
||||||
results = self.session.query(TVerse).order_by(TVerse.id).all()
|
|
||||||
for verse_temp in results:
|
|
||||||
verse = Verse()
|
|
||||||
verse.id = verse_temp.id
|
|
||||||
verse.book_id = verse_temp.book_id
|
|
||||||
verse.chapter = verse_temp.chapter
|
|
||||||
verse.verse = verse_temp.verse
|
|
||||||
verse.text = verse_temp.text
|
|
||||||
try:
|
|
||||||
self.session.add(verse)
|
|
||||||
self.session.commit()
|
|
||||||
except InvalidRequestError:
|
|
||||||
self.session.rollback()
|
|
||||||
print u'Error thrown = ', sys.exc_info()[1]
|
|
||||||
self.progress(u'Create metadata table')
|
|
||||||
results = self.session.query(TBibleMeta).order_by(TBibleMeta.key).all()
|
|
||||||
for biblemeta_temp in results:
|
|
||||||
biblemeta = BibleMeta()
|
|
||||||
biblemeta.key = biblemeta_temp.key
|
|
||||||
biblemeta.value = biblemeta_temp.value
|
|
||||||
try:
|
|
||||||
self.session.add(biblemeta)
|
|
||||||
self.session.commit()
|
|
||||||
except InvalidRequestError:
|
|
||||||
self.session.rollback()
|
|
||||||
print u'Error thrown = ', sys.exc_info()[1]
|
|
||||||
|
|
||||||
def _v1_9_0_cleanup(self, database):
|
|
||||||
self.progress(u'Update Internal Data ' + database)
|
|
||||||
conn = sqlite3.connect(os.path.join(self.data_path, database))
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'drop table book_temp;')
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'drop table testament_temp;')
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'drop table verse_temp;')
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'drop table metadata_temp;')
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'vacuum;')
|
|
||||||
conn.commit()
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
|
||||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
|
||||||
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
|
|
||||||
# Thompson, Jon Tibble, Carsten Tinggaard #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
|
||||||
# Software Foundation; version 2 of the License. #
|
|
||||||
# #
|
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
||||||
# more details. #
|
|
||||||
# #
|
|
||||||
# You should have received a copy of the GNU General Public License along #
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
from openlp.core.utils import AppLocation
|
|
||||||
|
|
||||||
class MigrateFiles(object):
|
|
||||||
def __init__(self, display):
|
|
||||||
self.display = display
|
|
||||||
|
|
||||||
def process(self):
|
|
||||||
self.display.output(u'Files process started')
|
|
||||||
self._initial_setup()
|
|
||||||
self.display.output(u'Files process finished')
|
|
||||||
|
|
||||||
def _initial_setup(self):
|
|
||||||
self.display.output(u'Initial Setup started')
|
|
||||||
data_path = AppLocation.get_data_path()
|
|
||||||
print data_path
|
|
||||||
self.display.sub_output(u'Config created')
|
|
||||||
bibles_path = AppLocation.get_section_data_path(u'bibles')
|
|
||||||
print bibles_path
|
|
||||||
self.display.sub_output(u'Config created')
|
|
||||||
# Media doesn't use a directory like the other plugins.
|
|
||||||
#media_path = AppLocation.get_section_data_path(u'media')
|
|
||||||
#self.display.sub_output(u'videos created')
|
|
||||||
images_path = AppLocation.get_section_data_path(u'images')
|
|
||||||
print images_path
|
|
||||||
self.display.sub_output(u'images created')
|
|
||||||
presentations_path = AppLocation.get_section_data_path(u'presentations')
|
|
||||||
print presentations_path
|
|
||||||
self.display.sub_output(u'presentations created')
|
|
||||||
self.display.output(u'Initial Setup finished')
|
|
@ -1,186 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
|
||||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
|
||||||
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
|
|
||||||
# Thompson, Jon Tibble, Carsten Tinggaard #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
|
||||||
# Software Foundation; version 2 of the License. #
|
|
||||||
# #
|
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
||||||
# more details. #
|
|
||||||
# #
|
|
||||||
# You should have received a copy of the GNU General Public License along #
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import sqlite3
|
|
||||||
|
|
||||||
from sqlalchemy import create_engine
|
|
||||||
from sqlalchemy.exceptions import InvalidRequestError
|
|
||||||
from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation
|
|
||||||
|
|
||||||
from openlp.core.lib import BaseModel, SettingsManager
|
|
||||||
from openlp.core.utils import AppLocation
|
|
||||||
from openlp.plugins.songs.lib.models import metadata, songs_table, Song, \
|
|
||||||
Author, Topic, Book
|
|
||||||
from openlp.plugins.songs.lib.tables import *
|
|
||||||
from openlp.plugins.songs.lib.classes import *
|
|
||||||
|
|
||||||
def init_models(url):
|
|
||||||
engine = create_engine(url)
|
|
||||||
metadata.bind = engine
|
|
||||||
session = scoped_session(
|
|
||||||
sessionmaker(autoflush=True, autocommit=False, bind=engine))
|
|
||||||
mapper(Author, authors_table)
|
|
||||||
mapper(TAuthor, temp_authors_table)
|
|
||||||
mapper(Book, song_books_table)
|
|
||||||
mapper(Song, songs_table,
|
|
||||||
properties={'authors': relation(Author, backref='songs',
|
|
||||||
secondary=authors_songs_table),
|
|
||||||
'book': relation(Book, backref='songs'),
|
|
||||||
'topics': relation(Topic, backref='songs',
|
|
||||||
secondary=songs_topics_table)})
|
|
||||||
mapper(TSong, temp_songs_table)
|
|
||||||
mapper(TSongAuthor, temp_authors_songs_table)
|
|
||||||
mapper(Topic, topics_table)
|
|
||||||
return session
|
|
||||||
|
|
||||||
temp_authors_table = Table(u'authors_temp', metadata,
|
|
||||||
Column(u'authorid', types.Integer, primary_key=True),
|
|
||||||
Column(u'authorname', String(40))
|
|
||||||
)
|
|
||||||
|
|
||||||
temp_songs_table = Table(u'songs_temp', metadata,
|
|
||||||
Column(u'songid', types.Integer, primary_key=True),
|
|
||||||
Column(u'songtitle', String(60)),
|
|
||||||
Column(u'lyrics', types.UnicodeText),
|
|
||||||
Column(u'copyrightinfo', String(255)),
|
|
||||||
Column(u'settingsid', types.Integer)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Definition of the "authors_songs" table
|
|
||||||
temp_authors_songs_table = Table(u'songauthors_temp', metadata,
|
|
||||||
Column(u'authorid', types.Integer, primary_key=True),
|
|
||||||
Column(u'songid', types.Integer)
|
|
||||||
)
|
|
||||||
|
|
||||||
class TAuthor(BaseModel):
|
|
||||||
"""
|
|
||||||
Author model
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
class TSong(BaseModel):
|
|
||||||
"""
|
|
||||||
Author model
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
class TSongAuthor(BaseModel):
|
|
||||||
"""
|
|
||||||
Author model
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
class MigrateSongs(object):
|
|
||||||
def __init__(self, display):
|
|
||||||
self.display = display
|
|
||||||
self.data_path = AppLocation.get_section_data_path(u'songs')
|
|
||||||
self.database_files = SettingsManager.get_files(u'songs', u'.sqlite')
|
|
||||||
print self.database_files
|
|
||||||
|
|
||||||
def process(self):
|
|
||||||
self.display.output(u'Songs processing started')
|
|
||||||
for f in self.database_files:
|
|
||||||
self.v_1_9_0(f)
|
|
||||||
self.display.output(u'Songs processing finished')
|
|
||||||
|
|
||||||
def v_1_9_0(self, database):
|
|
||||||
self.display.output(u'Migration 1.9.0 Started for ' + database)
|
|
||||||
self._v1_9_0_old(database)
|
|
||||||
self._v1_9_0_new(database)
|
|
||||||
self._v1_9_0_cleanup(database)
|
|
||||||
self.display.output(u'Migration 1.9.0 Finished for ' + database)
|
|
||||||
|
|
||||||
def _v1_9_0_old(self, database):
|
|
||||||
self.display.sub_output(u'Rename Tables ' + database)
|
|
||||||
conn = sqlite3.connect(self.data_path + os.sep + database)
|
|
||||||
conn.execute(u'alter table authors rename to authors_temp;')
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'alter table songs rename to songs_temp;')
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'alter table songauthors rename to songauthors_temp;')
|
|
||||||
conn.commit()
|
|
||||||
|
|
||||||
def _v1_9_0_new(self, database):
|
|
||||||
self.display.sub_output(u'Create new Tables ' + database)
|
|
||||||
self.db_url = u'sqlite:///' + self.data_path + u'/songs.sqlite'
|
|
||||||
print self.db_url
|
|
||||||
self.session = init_models(self.db_url)
|
|
||||||
metadata.create_all(checkfirst=True)
|
|
||||||
results = self.session.query(TSong).order_by(TSong.songid).all()
|
|
||||||
for songs_temp in results:
|
|
||||||
song = Song()
|
|
||||||
song.title = songs_temp.songtitle
|
|
||||||
song.lyrics = songs_temp.lyrics.replace(u'\r\n', u'\n')
|
|
||||||
song.copyright = songs_temp.copyrightinfo
|
|
||||||
song.search_title = u''
|
|
||||||
song.search_lyrics = u''
|
|
||||||
print songs_temp.songtitle
|
|
||||||
aa = self.session.execute(
|
|
||||||
u'select * from songauthors_temp where songid =' + \
|
|
||||||
unicode(songs_temp.songid))
|
|
||||||
for row in aa:
|
|
||||||
a = row['authorid']
|
|
||||||
authors_temp = self.session.query(TAuthor).get(a)
|
|
||||||
bb = self.session.execute(
|
|
||||||
u'select * from authors where display_name = \"%s\"' % \
|
|
||||||
unicode(authors_temp.authorname)).fetchone()
|
|
||||||
if bb is None:
|
|
||||||
author = Author()
|
|
||||||
author.display_name = authors_temp.authorname
|
|
||||||
author.first_name = u''
|
|
||||||
author.last_name = u''
|
|
||||||
else:
|
|
||||||
author = self.session.query(Author).get(bb[0])
|
|
||||||
song.authors.append(author)
|
|
||||||
try:
|
|
||||||
self.session.add(song)
|
|
||||||
self.session.commit()
|
|
||||||
except InvalidRequestError:
|
|
||||||
self.session.rollback()
|
|
||||||
print u'Error thrown = ', sys.exc_info()[1]
|
|
||||||
|
|
||||||
def _v1_9_0_cleanup(self, database):
|
|
||||||
self.display.sub_output(u'Update Internal Data ' + database)
|
|
||||||
conn = sqlite3.connect(self.data_path + os.sep + database)
|
|
||||||
conn.execute("""update songs set search_title =
|
|
||||||
replace(replace(replace(replace(replace(replace(replace(replace(
|
|
||||||
replace(title, '&', 'and'), ',', ''), ';', ''), ':', ''),
|
|
||||||
'(u', ''), ')', ''), '{', ''), '}',''),'?','');""")
|
|
||||||
conn.execute("""update songs set search_lyrics =
|
|
||||||
replace(replace(replace(replace(replace(replace(replace(replace(
|
|
||||||
replace(lyrics, '&', 'and'), ',', ''), ';', ''), ':', ''),
|
|
||||||
'(u', ''), ')', ''), '{', ''), '}',''),'?','')
|
|
||||||
;""")
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'drop table authors_temp;')
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'drop table songs_temp;')
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'drop table songauthors_temp;')
|
|
||||||
conn.commit()
|
|
||||||
conn.execute(u'drop table settings;')
|
|
||||||
conn.commit()
|
|
@ -30,7 +30,7 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||||
context_menu_action, ItemCapabilities, SettingsManager, translate
|
context_menu_action, ItemCapabilities, SettingsManager, translate
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.utils import AppLocation, get_images_filter
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -61,12 +61,9 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
self.OnNewPrompt = translate('ImagePlugin.MediaItem',
|
self.OnNewPrompt = translate('ImagePlugin.MediaItem',
|
||||||
'Select Image(s)')
|
'Select Image(s)')
|
||||||
file_formats = u''
|
file_formats = get_images_filter()
|
||||||
for file_format in QtGui.QImageReader.supportedImageFormats():
|
self.OnNewFileMasks = u'%s;;%s (*.*) (*)' % (file_formats,
|
||||||
file_formats += u'*.%s ' % file_format
|
unicode(translate('ImagePlugin.MediaItem', 'All Files')))
|
||||||
self.OnNewFileMasks = unicode(
|
|
||||||
translate('ImagePlugin.MediaItem',
|
|
||||||
'Images (%s);; All files (*)')) % file_formats
|
|
||||||
|
|
||||||
def requiredIcons(self):
|
def requiredIcons(self):
|
||||||
MediaManagerItem.requiredIcons(self)
|
MediaManagerItem.requiredIcons(self)
|
||||||
|
@ -29,7 +29,7 @@ import os
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||||
ItemCapabilities, SettingsManager, context_menu_action, Receiver, translate
|
ItemCapabilities, SettingsManager, translate
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -292,8 +292,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
last_name=text.rsplit(u' ', 1)[1], display_name=text)
|
last_name=text.rsplit(u' ', 1)[1], display_name=text)
|
||||||
self.songmanager.save_author(author)
|
self.songmanager.save_author(author)
|
||||||
self.song.authors.append(author)
|
self.song.authors.append(author)
|
||||||
author_item = QtGui.QListWidgetItem(unicode(author.display_name))
|
author_item = QtGui.QListWidgetItem(
|
||||||
author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
|
unicode(author.display_name))
|
||||||
|
author_item.setData(QtCore.Qt.UserRole,
|
||||||
|
QtCore.QVariant(author.id))
|
||||||
self.AuthorsListView.addItem(author_item)
|
self.AuthorsListView.addItem(author_item)
|
||||||
self.loadAuthors()
|
self.loadAuthors()
|
||||||
self.AuthorsSelectionComboItem.setCurrentIndex(0)
|
self.AuthorsSelectionComboItem.setCurrentIndex(0)
|
||||||
@ -343,7 +345,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.songmanager.save_topic(topic)
|
self.songmanager.save_topic(topic)
|
||||||
self.song.topics.append(topic)
|
self.song.topics.append(topic)
|
||||||
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
|
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
|
||||||
topic_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
|
topic_item.setData(QtCore.Qt.UserRole,
|
||||||
|
QtCore.QVariant(topic.id))
|
||||||
self.TopicsListView.addItem(topic_item)
|
self.TopicsListView.addItem(topic_item)
|
||||||
self.loadTopics()
|
self.loadTopics()
|
||||||
self.SongTopicCombo.setCurrentIndex(0)
|
self.SongTopicCombo.setCurrentIndex(0)
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import re
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
@ -161,7 +160,6 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
|
|
||||||
def onSearchTextButtonClick(self):
|
def onSearchTextButtonClick(self):
|
||||||
search_keywords = unicode(self.SearchTextEdit.displayText())
|
search_keywords = unicode(self.SearchTextEdit.displayText())
|
||||||
search_keywords = re.sub(r'\W+', u' ', search_keywords)
|
|
||||||
search_results = []
|
search_results = []
|
||||||
search_type = self.SearchTypeComboBox.currentIndex()
|
search_type = self.SearchTypeComboBox.currentIndex()
|
||||||
if search_type == 0:
|
if search_type == 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user