forked from openlp/openlp
- do not show an error message when the directory does not exist, instead create items
- trivial clean ups
This commit is contained in:
parent
9a81e8dbe6
commit
d7ebb73fd1
|
@ -33,7 +33,8 @@ import shutil
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, SettingsManager, translate
|
from openlp.core.lib import Receiver, SettingsManager, translate, \
|
||||||
|
check_directory_exists
|
||||||
from openlp.core.lib.db import delete_database
|
from openlp.core.lib.db import delete_database
|
||||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
||||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
||||||
|
@ -94,7 +95,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||||
|
|
||||||
def onCheckBoxIndexChanged(self, index):
|
def onCheckBoxIndexChanged(self, index):
|
||||||
"""
|
"""
|
||||||
Show/ Hide warnings if CheckBox state has changed
|
Show/Hide warnings if CheckBox state has changed
|
||||||
"""
|
"""
|
||||||
for number, filename in enumerate(self.files):
|
for number, filename in enumerate(self.files):
|
||||||
if not self.checkBox[number].checkState() == QtCore.Qt.Checked:
|
if not self.checkBox[number].checkState() == QtCore.Qt.Checked:
|
||||||
|
@ -154,17 +155,19 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||||
self.backupDirectoryEdit.setEnabled(not checked)
|
self.backupDirectoryEdit.setEnabled(not checked)
|
||||||
self.backupBrowseButton.setEnabled(not checked)
|
self.backupBrowseButton.setEnabled(not checked)
|
||||||
|
|
||||||
def backupOldBibles(self, backupdirectory):
|
def backupOldBibles(self, backup_directory):
|
||||||
"""
|
"""
|
||||||
Backup old bible databases in a given folder.
|
Backup old bible databases in a given folder.
|
||||||
"""
|
"""
|
||||||
|
check_directory_exists(backup_directory)
|
||||||
|
success = True
|
||||||
for filename in self.files:
|
for filename in self.files:
|
||||||
try:
|
try:
|
||||||
shutil.copy(os.path.join(self.path, filename[0]),
|
shutil.copy(os.path.join(self.path, filename[0]),
|
||||||
backupdirectory)
|
backup_directory)
|
||||||
except:
|
except:
|
||||||
return False
|
success = False
|
||||||
return True
|
return success
|
||||||
|
|
||||||
def customInit(self):
|
def customInit(self):
|
||||||
"""
|
"""
|
||||||
|
@ -318,7 +321,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||||
QtGui.QFormLayout.FieldRole, self.versionNameEdit[number])
|
QtGui.QFormLayout.FieldRole, self.versionNameEdit[number])
|
||||||
self.versionNameEdit[number].setText(bible.get_name())
|
self.versionNameEdit[number].setText(bible.get_name())
|
||||||
self.formLayout.addWidget(self.formWidget[number])
|
self.formLayout.addWidget(self.formWidget[number])
|
||||||
#Set up the Signal for the checkbox
|
# Set up the Signal for the checkbox.
|
||||||
QtCore.QObject.connect(self.checkBox[number],
|
QtCore.QObject.connect(self.checkBox[number],
|
||||||
QtCore.SIGNAL(u'stateChanged(int)'),
|
QtCore.SIGNAL(u'stateChanged(int)'),
|
||||||
self.onCheckBoxIndexChanged)
|
self.onCheckBoxIndexChanged)
|
||||||
|
@ -414,29 +417,23 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||||
return True
|
return True
|
||||||
elif self.currentPage() == self.backupPage:
|
elif self.currentPage() == self.backupPage:
|
||||||
if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked:
|
if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked:
|
||||||
if not unicode(self.backupDirectoryEdit.text()):
|
backup_path = unicode(self.backupDirectoryEdit.text())
|
||||||
|
if not backup_path:
|
||||||
critical_error_message_box(UiStrings().EmptyField,
|
critical_error_message_box(UiStrings().EmptyField,
|
||||||
translate('BiblesPlugin.UpgradeWizardForm',
|
translate('BiblesPlugin.UpgradeWizardForm',
|
||||||
'You need to specify a Backup Directory for your '
|
'You need to specify a Backup Directory for your '
|
||||||
'Bibles.'))
|
'Bibles.'))
|
||||||
self.backupDirectoryEdit.setFocus()
|
self.backupDirectoryEdit.setFocus()
|
||||||
return False
|
return False
|
||||||
elif not os.path.exists(unicode(
|
|
||||||
self.backupDirectoryEdit.text())):
|
|
||||||
critical_error_message_box(UiStrings().Error,
|
|
||||||
translate('BiblesPlugin.UpgradeWizardForm',
|
|
||||||
'The given path is not an existing directory.'))
|
|
||||||
self.backupDirectoryEdit.setFocus()
|
|
||||||
return False
|
|
||||||
else:
|
else:
|
||||||
if not self.backupOldBibles(unicode(
|
if not self.backupOldBibles(backup_path):
|
||||||
self.backupDirectoryEdit.text())):
|
|
||||||
critical_error_message_box(UiStrings().Error,
|
critical_error_message_box(UiStrings().Error,
|
||||||
translate('BiblesPlugin.UpgradeWizardForm',
|
translate('BiblesPlugin.UpgradeWizardForm',
|
||||||
'The backup was not successfull.\nTo backup your '
|
'The backup was not successfull.\nTo backup your '
|
||||||
'Bibles you need the permission to write in the given '
|
'Bibles you need the permission to write in the '
|
||||||
'directory. If you have a permissions to write and '
|
'given directory. If you have a permissions to '
|
||||||
'this error still occurs, please report a bug.'))
|
'write and this error still occurs, please report '
|
||||||
|
'a bug.'))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
elif self.currentPage() == self.selectPage:
|
elif self.currentPage() == self.selectPage:
|
||||||
|
|
|
@ -70,15 +70,15 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
|
||||||
self.onCheckBoxIndexChanged)
|
self.onCheckBoxIndexChanged)
|
||||||
|
|
||||||
def onCheckBoxIndexChanged(self, index):
|
def onCheckBoxIndexChanged(self, index):
|
||||||
'''
|
"""
|
||||||
Reload Combobox if CheckBox state has changed
|
Reload Combobox if CheckBox state has changed
|
||||||
'''
|
"""
|
||||||
self.reloadComboBox()
|
self.reloadComboBox()
|
||||||
|
|
||||||
def reloadComboBox(self):
|
def reloadComboBox(self):
|
||||||
'''
|
"""
|
||||||
Reload the Combobox items
|
Reload the Combobox items
|
||||||
'''
|
"""
|
||||||
self.correspondingComboBox.clear()
|
self.correspondingComboBox.clear()
|
||||||
items = BiblesResourcesDB.get_books()
|
items = BiblesResourcesDB.get_books()
|
||||||
for item in items:
|
for item in items:
|
||||||
|
|
Loading…
Reference in New Issue