From c435127585284e27676963cdfb02ead7fb077efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 26 May 2011 21:13:11 +0200 Subject: [PATCH] some fixes in relation with the extened LanguageForm close cursor from OldBibleDB --- openlp/plugins/bibles/forms/bibleimportform.py | 2 +- openlp/plugins/bibles/forms/bibleupgradeform.py | 1 + openlp/plugins/bibles/forms/languageform.py | 6 +----- openlp/plugins/bibles/lib/csvbible.py | 7 +++---- openlp/plugins/bibles/lib/db.py | 7 +++++++ openlp/plugins/bibles/lib/http.py | 4 ++-- openlp/plugins/bibles/lib/openlp1.py | 7 +++---- openlp/plugins/bibles/lib/opensong.py | 4 ++-- openlp/plugins/bibles/lib/osis.py | 7 +++---- 9 files changed, 23 insertions(+), 22 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 45ada29ba..731c4ff17 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -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() diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 7b7c259ac..fef8c04df 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -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', diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index e7cde104c..477c7ee1e 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -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']) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index a4a498677..8b1ce0c8d 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -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 = {} diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index a3eb0e849..ab4cf3ba4 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -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. diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 5a05ade92..ab82799d1 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -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) diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 2c3eb7851..3564c5d37 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -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') diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index f848cd69b..005139784 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -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) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 682fed11a..effb62104 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -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'])