Disable importer if pysword is missing. Pep8 fixes.

This commit is contained in:
Tomas Groth 2016-03-25 20:58:43 +01:00
parent a86ef7e4d5
commit 6b75148e34
3 changed files with 12 additions and 9 deletions

View File

@ -39,7 +39,7 @@ from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.core.utils import get_locale_key
from openlp.plugins.bibles.lib.manager import BibleFormat
from openlp.plugins.bibles.lib.db import BiblesResourcesDB, clean_filename
from openlp.plugins.bibles.lib.db import clean_filename
from openlp.plugins.bibles.lib.http import CWExtract, BGExtract, BSExtract
log = logging.getLogger(__name__)
@ -504,7 +504,8 @@ class BibleImportForm(OpenLPWizard):
# Test the SWORD tab that is currently active
if self.sword_tab_widget.currentIndex() == self.sword_tab_widget.indexOf(self.sword_folder_tab):
if not self.field('sword_folder_path') and self.sword_bible_combo_box.count() == 0:
critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFolder % WizardStrings.SWORD)
critical_error_message_box(UiStrings().NFSs,
WizardStrings.YouSpecifyFolder % WizardStrings.SWORD)
self.sword_folder_edit.setFocus()
return False
key = self.sword_bible_combo_box.itemData(self.sword_bible_combo_box.currentIndex())
@ -785,12 +786,12 @@ class BibleImportForm(OpenLPWizard):
importer = self.manager.import_bible(BibleFormat.SWORD, name=license_version,
sword_path=self.field('sword_folder_path'),
sword_key=self.sword_bible_combo_box.itemData(
self.sword_bible_combo_box.currentIndex()))
self.sword_bible_combo_box.currentIndex()))
else:
importer = self.manager.import_bible(BibleFormat.SWORD, name=license_version,
sword_path=self.field('sword_zip_path'),
sword_key=self.sword_zipbible_combo_box.itemData(
self.sword_zipbible_combo_box.currentIndex()))
self.sword_zipbible_combo_box.currentIndex()))
if importer.do_import(license_version):
self.manager.save_meta_data(license_version, license_version, license_copyright, license_permissions)
self.manager.reload_bibles()

View File

@ -32,8 +32,10 @@ from .http import HTTPBible
from .opensong import OpenSongBible
from .osis import OSISBible
from .zefania import ZefaniaBible
from .sword import SwordBible
try:
from .sword import SwordBible
except:
pass
log = logging.getLogger(__name__)

View File

@ -91,9 +91,9 @@ class SwordBible(BibleDB):
self.application.process_events()
except Exception as e:
critical_error_message_box(
message=translate('BiblesPlugin.SwordImport','An unexpected error happened while importing the SWORD '
'bible, please report this to the OpenLP developers.\n'
'%s' % e.msg))
message=translate('BiblesPlugin.SwordImport', 'An unexpected error happened while importing the SWORD '
'bible, please report this to the OpenLP developers.\n'
'%s' % e.msg))
log.exception(str(e))
success = False
if self.stop_import_flag: