forked from openlp/openlp
Changes to CCLI file importer to work with import wizard
This commit is contained in:
commit
80ded239a8
@ -204,7 +204,7 @@ class Theme(object):
|
|||||||
val = element_text
|
val = element_text
|
||||||
if (element.tag.find(u'Color') > 0 or
|
if (element.tag.find(u'Color') > 0 or
|
||||||
(element.tag.find(u'BackgroundParameter') == 0 and
|
(element.tag.find(u'BackgroundParameter') == 0 and
|
||||||
isinstance(int, val))):
|
isinstance(val, int))):
|
||||||
# convert to a wx.Colour
|
# convert to a wx.Colour
|
||||||
if not delphi_color_change:
|
if not delphi_color_change:
|
||||||
val = QtGui.QColor(
|
val = QtGui.QColor(
|
||||||
|
@ -652,8 +652,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
version_text = unicode(translate('OpenLP.MainWindow',
|
version_text = unicode(translate('OpenLP.MainWindow',
|
||||||
'Version %s of OpenLP is now available for download (you are '
|
'Version %s of OpenLP is now available for download (you are '
|
||||||
'currently running version %s). \n\nYou can download the latest '
|
'currently running version %s). \n\nYou can download the latest '
|
||||||
'version from '
|
'version from http://openlp.org/.'))
|
||||||
'<a href="http://openlp.org/">http://openlp.org/</a>.'))
|
|
||||||
QtGui.QMessageBox.question(self,
|
QtGui.QMessageBox.question(self,
|
||||||
translate('OpenLP.MainWindow', 'OpenLP Version Updated'),
|
translate('OpenLP.MainWindow', 'OpenLP Version Updated'),
|
||||||
version_text % (version, self.applicationVersion[u'full']))
|
version_text % (version, self.applicationVersion[u'full']))
|
||||||
|
@ -70,6 +70,8 @@ class VersionThread(QtCore.QThread):
|
|||||||
remote_version[u'release'] = int(match.group(3))
|
remote_version[u'release'] = int(match.group(3))
|
||||||
if len(match.groups()) > 3 and match.group(4):
|
if len(match.groups()) > 3 and match.group(4):
|
||||||
remote_version[u'revision'] = int(match.group(4))
|
remote_version[u'revision'] = int(match.group(4))
|
||||||
|
else:
|
||||||
|
return
|
||||||
match = self.version_splitter.match(self.app_version[u'full'])
|
match = self.version_splitter.match(self.app_version[u'full'])
|
||||||
if match:
|
if match:
|
||||||
local_version[u'major'] = int(match.group(1))
|
local_version[u'major'] = int(match.group(1))
|
||||||
@ -77,6 +79,8 @@ class VersionThread(QtCore.QThread):
|
|||||||
local_version[u'release'] = int(match.group(3))
|
local_version[u'release'] = int(match.group(3))
|
||||||
if len(match.groups()) > 3 and match.group(4):
|
if len(match.groups()) > 3 and match.group(4):
|
||||||
local_version[u'revision'] = int(match.group(4))
|
local_version[u'revision'] = int(match.group(4))
|
||||||
|
else:
|
||||||
|
return
|
||||||
if remote_version[u'major'] > local_version[u'major'] or \
|
if remote_version[u'major'] > local_version[u'major'] or \
|
||||||
remote_version[u'minor'] > local_version[u'minor'] or \
|
remote_version[u'minor'] > local_version[u'minor'] or \
|
||||||
remote_version[u'release'] > local_version[u'release']:
|
remote_version[u'release'] > local_version[u'release']:
|
||||||
@ -147,10 +151,10 @@ class AppLocation(object):
|
|||||||
return plugin_path
|
return plugin_path
|
||||||
elif dir_type == AppLocation.VersionDir:
|
elif dir_type == AppLocation.VersionDir:
|
||||||
if hasattr(sys, u'frozen') and sys.frozen == 1:
|
if hasattr(sys, u'frozen') and sys.frozen == 1:
|
||||||
plugin_path = os.path.abspath(os.path.split(sys.argv[0])[0])
|
version_path = os.path.abspath(os.path.split(sys.argv[0])[0])
|
||||||
else:
|
else:
|
||||||
plugin_path = os.path.split(openlp.__file__)[0]
|
version_path = os.path.split(openlp.__file__)[0]
|
||||||
return plugin_path
|
return version_path
|
||||||
elif dir_type == AppLocation.CacheDir:
|
elif dir_type == AppLocation.CacheDir:
|
||||||
if sys.platform == u'win32':
|
if sys.platform == u'win32':
|
||||||
path = os.path.join(os.getenv(u'APPDATA'), u'openlp')
|
path = os.path.join(os.getenv(u'APPDATA'), u'openlp')
|
||||||
@ -206,11 +210,14 @@ def check_latest_version(current_version):
|
|||||||
else:
|
else:
|
||||||
req = urllib2.Request(u'http://www.openlp.org/files/version.txt')
|
req = urllib2.Request(u'http://www.openlp.org/files/version.txt')
|
||||||
req.add_header(u'User-Agent', u'OpenLP/%s' % current_version[u'full'])
|
req.add_header(u'User-Agent', u'OpenLP/%s' % current_version[u'full'])
|
||||||
|
remote_version = None
|
||||||
try:
|
try:
|
||||||
version_string = unicode(urllib2.urlopen(req, None).read()).strip()
|
remote_version = unicode(urllib2.urlopen(req, None).read()).strip()
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
if hasattr(e, u'reason'):
|
if hasattr(e, u'reason'):
|
||||||
log.exception(u'Reason for failure: %s', e.reason)
|
log.exception(u'Reason for failure: %s', e.reason)
|
||||||
|
if remote_version:
|
||||||
|
version_string = remote_version
|
||||||
return version_string
|
return version_string
|
||||||
|
|
||||||
def add_actions(target, actions):
|
def add_actions(target, actions):
|
||||||
|
@ -641,7 +641,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
'''
|
'''
|
||||||
version = self.parent.manager.get_meta_data(bible, u'Version')
|
version = self.parent.manager.get_meta_data(bible, u'Version')
|
||||||
copyright = self.parent.manager.get_meta_data(bible, u'Copyright')
|
copyright = self.parent.manager.get_meta_data(bible, u'Copyright')
|
||||||
permission = self.parent.manager.get_meta_data(bible, u'Permissions')
|
#permission = self.parent.manager.get_meta_data(bible, u'Permissions')
|
||||||
if dual_bible:
|
if dual_bible:
|
||||||
dual_version = self.parent.manager.get_meta_data(dual_bible,
|
dual_version = self.parent.manager.get_meta_data(dual_bible,
|
||||||
u'Version')
|
u'Version')
|
||||||
|
@ -142,7 +142,7 @@ class Ui_CustomEditDialog(object):
|
|||||||
customEditDialog.setWindowTitle(
|
customEditDialog.setWindowTitle(
|
||||||
translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides'))
|
translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides'))
|
||||||
self.upButton.setToolTip(
|
self.upButton.setToolTip(
|
||||||
translate('CustomPlugin.EditCustomForm', 'Move slide up once '
|
translate('CustomPlugin.EditCustomForm', 'Move slide up one '
|
||||||
'position.'))
|
'position.'))
|
||||||
self.downButton.setToolTip(
|
self.downButton.setToolTip(
|
||||||
translate('CustomPlugin.EditCustomForm', 'Move slide down one '
|
translate('CustomPlugin.EditCustomForm', 'Move slide down one '
|
||||||
|
@ -318,8 +318,8 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
|
|||||||
Stop the import on pressing the cancel button.
|
Stop the import on pressing the cancel button.
|
||||||
"""
|
"""
|
||||||
log.debug('Cancel button pressed!')
|
log.debug('Cancel button pressed!')
|
||||||
if self.currentId() == 3:
|
if self.currentId() == 2:
|
||||||
Receiver.send_message(u'song_stop_import')
|
Receiver.send_message(u'songs_stop_import')
|
||||||
|
|
||||||
def onCurrentIdChanged(self, id):
|
def onCurrentIdChanged(self, id):
|
||||||
if id == 2:
|
if id == 2:
|
||||||
|
@ -88,9 +88,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||||||
item = self.songmanager.get_object(item_class, item_id)
|
item = self.songmanager.get_object(item_class, item_id)
|
||||||
if item and len(item.songs) == 0:
|
if item and len(item.songs) == 0:
|
||||||
if QtGui.QMessageBox.warning(self, dlg_title, del_text,
|
if QtGui.QMessageBox.warning(self, dlg_title, del_text,
|
||||||
QtGui.QMessageBox.StandardButtons(
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
|
||||||
QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)
|
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes:
|
||||||
) == QtGui.QMessageBox.Yes:
|
|
||||||
self.songmanager.delete_object(item_class, item.id)
|
self.songmanager.delete_object(item_class, item.id)
|
||||||
reset_func()
|
reset_func()
|
||||||
else:
|
else:
|
||||||
|
@ -75,18 +75,17 @@ class OpenLPSongImport(SongImport):
|
|||||||
The :class:`OpenLPSongImport` class provides OpenLP with the ability to
|
The :class:`OpenLPSongImport` class provides OpenLP with the ability to
|
||||||
import song databases from other installations of OpenLP.
|
import song databases from other installations of OpenLP.
|
||||||
"""
|
"""
|
||||||
def __init__(self, master_manager, **kwargs):
|
def __init__(self, manager, **kwargs):
|
||||||
"""
|
"""
|
||||||
Initialise the import.
|
Initialise the import.
|
||||||
|
|
||||||
``master_manager``
|
``manager``
|
||||||
The song manager for the running OpenLP installation.
|
The song manager for the running OpenLP installation.
|
||||||
|
|
||||||
``source_db``
|
``source_db``
|
||||||
The database providing the data to import.
|
The database providing the data to import.
|
||||||
"""
|
"""
|
||||||
SongImport.__init__(self, master_manager)
|
SongImport.__init__(self, manager)
|
||||||
self.master_manager = master_manager
|
|
||||||
self.import_source = u'sqlite:///%s' % kwargs[u'filename']
|
self.import_source = u'sqlite:///%s' % kwargs[u'filename']
|
||||||
log.debug(self.import_source)
|
log.debug(self.import_source)
|
||||||
self.source_session = None
|
self.source_session = None
|
||||||
@ -145,7 +144,12 @@ class OpenLPSongImport(SongImport):
|
|||||||
mapper(OldTopic, source_topics_table)
|
mapper(OldTopic, source_topics_table)
|
||||||
|
|
||||||
source_songs = self.source_session.query(OldSong).all()
|
source_songs = self.source_session.query(OldSong).all()
|
||||||
|
song_total = len(source_songs)
|
||||||
|
self.import_wizard.importProgressBar.setMaximum(song_total)
|
||||||
|
song_count = 1
|
||||||
for song in source_songs:
|
for song in source_songs:
|
||||||
|
self.import_wizard.incrementProgressBar(
|
||||||
|
u'Importing song %s of %s' % (song_count, song_total))
|
||||||
new_song = Song()
|
new_song = Song()
|
||||||
new_song.title = song.title
|
new_song.title = song.title
|
||||||
if has_media_files:
|
if has_media_files:
|
||||||
@ -167,7 +171,7 @@ class OpenLPSongImport(SongImport):
|
|||||||
new_song.ccli_number = song.ccli_number
|
new_song.ccli_number = song.ccli_number
|
||||||
if song.authors:
|
if song.authors:
|
||||||
for author in song.authors:
|
for author in song.authors:
|
||||||
existing_author = self.master_manager.get_object_filtered(
|
existing_author = self.manager.get_object_filtered(
|
||||||
Author, Author.display_name == author.display_name)
|
Author, Author.display_name == author.display_name)
|
||||||
if existing_author:
|
if existing_author:
|
||||||
new_song.authors.append(existing_author)
|
new_song.authors.append(existing_author)
|
||||||
@ -177,7 +181,7 @@ class OpenLPSongImport(SongImport):
|
|||||||
last_name=author.last_name,
|
last_name=author.last_name,
|
||||||
display_name=author.display_name))
|
display_name=author.display_name))
|
||||||
else:
|
else:
|
||||||
au = self.master_manager.get_object_filtered(Author,
|
au = self.manager.get_object_filtered(Author,
|
||||||
Author.display_name == u'Author Unknown')
|
Author.display_name == u'Author Unknown')
|
||||||
if au:
|
if au:
|
||||||
new_song.authors.append(au)
|
new_song.authors.append(au)
|
||||||
@ -185,7 +189,7 @@ class OpenLPSongImport(SongImport):
|
|||||||
new_song.authors.append(Author.populate(
|
new_song.authors.append(Author.populate(
|
||||||
display_name=u'Author Unknown'))
|
display_name=u'Author Unknown'))
|
||||||
if song.book:
|
if song.book:
|
||||||
existing_song_book = self.master_manager.get_object_filtered(
|
existing_song_book = self.manager.get_object_filtered(
|
||||||
Book, Book.name == song.book.name)
|
Book, Book.name == song.book.name)
|
||||||
if existing_song_book:
|
if existing_song_book:
|
||||||
new_song.book = existing_song_book
|
new_song.book = existing_song_book
|
||||||
@ -194,7 +198,7 @@ class OpenLPSongImport(SongImport):
|
|||||||
publisher=song.book.publisher)
|
publisher=song.book.publisher)
|
||||||
if song.topics:
|
if song.topics:
|
||||||
for topic in song.topics:
|
for topic in song.topics:
|
||||||
existing_topic = self.master_manager.get_object_filtered(
|
existing_topic = self.manager.get_object_filtered(
|
||||||
Topic, Topic.name == topic.name)
|
Topic, Topic.name == topic.name)
|
||||||
if existing_topic:
|
if existing_topic:
|
||||||
new_song.topics.append(existing_topic)
|
new_song.topics.append(existing_topic)
|
||||||
@ -204,12 +208,16 @@ class OpenLPSongImport(SongImport):
|
|||||||
# if song.media_files:
|
# if song.media_files:
|
||||||
# for media_file in song.media_files:
|
# for media_file in song.media_files:
|
||||||
# existing_media_file = \
|
# existing_media_file = \
|
||||||
# self.master_manager.get_object_filtered(MediaFile,
|
# self.manager.get_object_filtered(MediaFile,
|
||||||
# MediaFile.file_name == media_file.file_name)
|
# MediaFile.file_name == media_file.file_name)
|
||||||
# if existing_media_file:
|
# if existing_media_file:
|
||||||
# new_song.media_files.append(existing_media_file)
|
# new_song.media_files.append(existing_media_file)
|
||||||
# else:
|
# else:
|
||||||
# new_song.media_files.append(MediaFile.populate(
|
# new_song.media_files.append(MediaFile.populate(
|
||||||
# file_name=media_file.file_name))
|
# file_name=media_file.file_name))
|
||||||
self.master_manager.save_object(new_song)
|
self.manager.save_object(new_song)
|
||||||
|
song_count += 1
|
||||||
|
if self.stop_import_flag:
|
||||||
|
return False
|
||||||
engine.dispose()
|
engine.dispose()
|
||||||
|
return True
|
||||||
|
@ -24,14 +24,18 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
import logging
|
||||||
import re
|
import re
|
||||||
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
from openlp.core.lib import translate
|
from openlp.core.lib import Receiver, translate
|
||||||
from openlp.plugins.songs.lib import VerseType
|
from openlp.plugins.songs.lib import VerseType
|
||||||
from openlp.plugins.songs.lib.db import Song, Author, Topic, Book
|
from openlp.plugins.songs.lib.db import Song, Author, Topic, Book
|
||||||
from openlp.plugins.songs.lib.xml import SongXMLBuilder
|
from openlp.plugins.songs.lib.xml import SongXMLBuilder
|
||||||
|
|
||||||
class SongImport(object):
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class SongImport(QtCore.QObject):
|
||||||
"""
|
"""
|
||||||
Helper class for import a song from a third party source into OpenLP
|
Helper class for import a song from a third party source into OpenLP
|
||||||
|
|
||||||
@ -39,7 +43,6 @@ class SongImport(object):
|
|||||||
whether the authors etc already exist and add them or refer to them
|
whether the authors etc already exist and add them or refer to them
|
||||||
as necessary
|
as necessary
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, manager):
|
def __init__(self, manager):
|
||||||
"""
|
"""
|
||||||
Initialise and create defaults for properties
|
Initialise and create defaults for properties
|
||||||
@ -48,6 +51,7 @@ class SongImport(object):
|
|||||||
database access is performed
|
database access is performed
|
||||||
"""
|
"""
|
||||||
self.manager = manager
|
self.manager = manager
|
||||||
|
self.stop_import_flag = False
|
||||||
self.title = u''
|
self.title = u''
|
||||||
self.song_number = u''
|
self.song_number = u''
|
||||||
self.alternate_title = u''
|
self.alternate_title = u''
|
||||||
@ -67,6 +71,15 @@ class SongImport(object):
|
|||||||
'SongsPlugin.SongImport', 'copyright'))
|
'SongsPlugin.SongImport', 'copyright'))
|
||||||
self.copyright_symbol = unicode(translate(
|
self.copyright_symbol = unicode(translate(
|
||||||
'SongsPlugin.SongImport', '\xa9'))
|
'SongsPlugin.SongImport', '\xa9'))
|
||||||
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
|
QtCore.SIGNAL(u'songs_stop_import'), self.stop_import)
|
||||||
|
|
||||||
|
def stop_import(self):
|
||||||
|
"""
|
||||||
|
Sets the flag for importers to stop their import
|
||||||
|
"""
|
||||||
|
log.debug(u'Stopping songs import')
|
||||||
|
self.stop_import_flag = True
|
||||||
|
|
||||||
def register(self, import_wizard):
|
def register(self, import_wizard):
|
||||||
self.import_wizard = import_wizard
|
self.import_wizard = import_wizard
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user