forked from openlp/openlp
some fixes in relation with the extened LanguageForm
close cursor from OldBibleDB
This commit is contained in:
parent
24d7b7b038
commit
c435127585
@ -706,7 +706,7 @@ class BibleImportForm(OpenLPWizard):
|
||||
name=license_version,
|
||||
filename=unicode(self.field(u'openlp1_location').toString())
|
||||
)
|
||||
if importer.do_import():
|
||||
if importer.do_import(license_version):
|
||||
self.manager.save_meta_data(license_version, license_version,
|
||||
license_copyright, license_permissions)
|
||||
self.manager.reload_bibles()
|
||||
|
@ -324,6 +324,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
oldbible = OldBibleDB(self.mediaItem, path=self.path,
|
||||
file=filename)
|
||||
oldname = oldbible.get_name()
|
||||
oldbible.close_cursor()
|
||||
if not version_name:
|
||||
critical_error_message_box(UiStrings().EmptyField,
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
|
@ -55,11 +55,7 @@ class LanguageForm(QDialog, Ui_LanguageDialog):
|
||||
def exec_(self, bible_name):
|
||||
self.languageComboBox.addItem(u'')
|
||||
if bible_name:
|
||||
self.infoLabel.setText(unicode(translate(
|
||||
'BiblesPlugin.LanguageDialog',
|
||||
'OpenLP is unable to determine the language of this translation'
|
||||
' of the Bible. Please select the language for "%s" from the '
|
||||
'list below.')) % bible_name)
|
||||
self.bibleLabel.setText(unicode(bible_name))
|
||||
items = BiblesResourcesDB.get_languages()
|
||||
for item in items:
|
||||
self.languageComboBox.addItem(item[u'name'])
|
||||
|
@ -92,7 +92,7 @@ class CSVBible(BibleDB):
|
||||
self.booksfile = kwargs[u'booksfile']
|
||||
self.versesfile = kwargs[u'versefile']
|
||||
|
||||
def do_import(self):
|
||||
def do_import(self, bible_name=None):
|
||||
"""
|
||||
Import the bible books and verses.
|
||||
"""
|
||||
@ -100,10 +100,9 @@ class CSVBible(BibleDB):
|
||||
self.wizard.progressBar.setMinimum(0)
|
||||
self.wizard.progressBar.setMaximum(66)
|
||||
success = True
|
||||
language_id = self.get_language()
|
||||
language_id = self.get_language(bible_name)
|
||||
if not language_id:
|
||||
log.exception(u'Importing books from "%s" '\
|
||||
'failed' % self.filename)
|
||||
log.exception(u'Importing books from "%s" failed' % self.filename)
|
||||
return False
|
||||
books_file = None
|
||||
book_list = {}
|
||||
|
@ -999,6 +999,13 @@ class OldBibleDB(QtCore.QObject, Manager):
|
||||
self.cursor = conn.cursor()
|
||||
return self.cursor
|
||||
|
||||
def close_cursor(self):
|
||||
"""
|
||||
Close the cursor
|
||||
"""
|
||||
if self.cursor:
|
||||
self.cursor.close()
|
||||
|
||||
def run_sql(self, query, parameters=()):
|
||||
"""
|
||||
Run an SQL query on the database, returning the results.
|
||||
|
@ -375,7 +375,7 @@ class HTTPBible(BibleDB):
|
||||
if u'proxy_password' in kwargs:
|
||||
self.proxy_password = kwargs[u'proxy_password']
|
||||
|
||||
def do_import(self):
|
||||
def do_import(self, bible_name=None):
|
||||
"""
|
||||
Run the import. This method overrides the parent class method. Returns
|
||||
``True`` on success, ``False`` on failure.
|
||||
@ -414,7 +414,7 @@ class HTTPBible(BibleDB):
|
||||
language_id = bible[u'language_id']
|
||||
self.create_meta(u'language_id', language_id)
|
||||
else:
|
||||
language_id = self.get_language()
|
||||
language_id = self.get_language(bible_name)
|
||||
if not language_id:
|
||||
log.exception(u'Importing books from %s " '\
|
||||
'failed' % self.filename)
|
||||
|
@ -46,7 +46,7 @@ class OpenLP1Bible(BibleDB):
|
||||
BibleDB.__init__(self, parent, **kwargs)
|
||||
self.filename = kwargs[u'filename']
|
||||
|
||||
def do_import(self):
|
||||
def do_import(self, bible_name=None):
|
||||
"""
|
||||
Imports an openlp.org v1 bible.
|
||||
"""
|
||||
@ -58,10 +58,9 @@ class OpenLP1Bible(BibleDB):
|
||||
except:
|
||||
return False
|
||||
#Create the bible language
|
||||
language_id = self.get_language()
|
||||
language_id = self.get_language(bible_name)
|
||||
if not language_id:
|
||||
log.exception(u'Importing books from "%s " '\
|
||||
'failed' % self.filename)
|
||||
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')
|
||||
|
@ -46,7 +46,7 @@ class OpenSongBible(BibleDB):
|
||||
BibleDB.__init__(self, parent, **kwargs)
|
||||
self.filename = kwargs['filename']
|
||||
|
||||
def do_import(self):
|
||||
def do_import(self, bible_name=None):
|
||||
"""
|
||||
Loads a Bible from file.
|
||||
"""
|
||||
@ -62,7 +62,7 @@ class OpenSongBible(BibleDB):
|
||||
file = open(self.filename, u'r')
|
||||
opensong = objectify.parse(file)
|
||||
bible = opensong.getroot()
|
||||
language_id = self.get_language()
|
||||
language_id = self.get_language(bible_name)
|
||||
if not language_id:
|
||||
log.exception(u'Importing books from "%s" '\
|
||||
'failed' % self.filename)
|
||||
|
@ -86,7 +86,7 @@ class OSISBible(BibleDB):
|
||||
if fbibles:
|
||||
fbibles.close()
|
||||
|
||||
def do_import(self):
|
||||
def do_import(self, bible_name=None):
|
||||
"""
|
||||
Loads a Bible from file.
|
||||
"""
|
||||
@ -109,10 +109,9 @@ class OSISBible(BibleDB):
|
||||
if detect_file:
|
||||
detect_file.close()
|
||||
# Set meta language_id
|
||||
language_id = self.get_language()
|
||||
language_id = self.get_language(bible_name)
|
||||
if not language_id:
|
||||
log.exception(u'Importing books from "%s" '\
|
||||
'failed' % self.filename)
|
||||
log.exception(u'Importing books from "%s" failed' % self.filename)
|
||||
return False
|
||||
try:
|
||||
osis = codecs.open(self.filename, u'r', details['encoding'])
|
||||
|
Loading…
Reference in New Issue
Block a user