openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #13530
[Merge] lp:~mahfiaz/openlp/v1db_import_nonascii into lp:openlp
mahfiaz has proposed merging lp:~mahfiaz/openlp/v1db_import_nonascii into lp:openlp.
Requested reviews:
Raoul Snyman (raoul-snyman)
For more details, see:
https://code.launchpad.net/~mahfiaz/openlp/v1db_import_nonascii/+merge/86509
Fixes error when trying to import an openlp.org songs or bibles database with non-ascii filename. Also some in-code notes about error handling.
--
https://code.launchpad.net/~mahfiaz/openlp/v1db_import_nonascii/+merge/86509
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/bibles/lib/openlp1.py'
--- openlp/plugins/bibles/lib/openlp1.py 2011-06-12 16:02:52 +0000
+++ openlp/plugins/bibles/lib/openlp1.py 2011-12-21 08:24:26 +0000
@@ -27,6 +27,7 @@
import logging
import sqlite
+import sys
from openlp.core.lib import Receiver
from openlp.core.ui.wizard import WizardStrings
@@ -53,9 +54,14 @@
connection = None
cursor = None
try:
- connection = sqlite.connect(self.filename)
+ connection = sqlite.connect(
+ self.filename.encode(sys.getfilesystemencoding()))
cursor = connection.cursor()
- except:
+ except sqlite.DatabaseError:
+ log.exception(u'File "%s" is encrypted or not a sqlite database, '
+ 'therefore not an openlp.org 1.x database either' % self.filename)
+ # Please add an user error here!
+ # This file is not an openlp.org 1.x bible database.
return False
#Create the bible language
language_id = self.get_language(bible_name)
@@ -63,7 +69,14 @@
log.exception(u'Importing books from "%s" failed' % self.filename)
return False
# Create all books.
- cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
+ try:
+ cursor.execute(
+ u'SELECT id, testament_id, name, abbreviation FROM book')
+ except sqlite.DatabaseError as error:
+ log.exception(u'DatabaseError: %s' % error)
+ # Please add an user error here!
+ # This file is not an openlp.org 1.x bible database.
+ return False
books = cursor.fetchall()
self.wizard.progressBar.setMaximum(len(books) + 1)
for book in books:
=== modified file 'openlp/plugins/songs/lib/olp1import.py'
--- openlp/plugins/songs/lib/olp1import.py 2011-10-31 14:18:22 +0000
+++ openlp/plugins/songs/lib/olp1import.py 2011-12-21 08:24:26 +0000
@@ -165,7 +165,8 @@
Detect character encoding of an openlp.org 1.x song database.
"""
# Connect to the database.
- connection = sqlite.connect(self.importSource, mode=0444)
+ connection = sqlite.connect(self.importSource.encode(
+ sys.getfilesystemencoding()), mode=0444)
cursor = connection.cursor()
detector = UniversalDetector()
Follow ups