- Fixed bug 1624661

This commit is contained in:
Olli Suutari 2016-10-02 14:31:35 +03:00
parent 238397fa3c
commit 4471338a19
3 changed files with 38 additions and 22 deletions

View File

@ -208,8 +208,8 @@ class OpenLP(OpenLPMixin, QtWidgets.QApplication):
# If data_version is different from the current version ask if we should backup the data folder
elif data_version != openlp_version:
if QtWidgets.QMessageBox.question(None, translate('OpenLP', 'Backup'),
translate('OpenLP', 'OpenLP has been upgraded, do you want to create '
'a backup of OpenLPs data folder?'),
translate('OpenLP', 'OpenLP has been upgraded, do you want to\ncreate '
'a backup of the old data folder?'),
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.Yes:
# Create copy of data folder
@ -223,8 +223,8 @@ class OpenLP(OpenLPMixin, QtWidgets.QApplication):
translate('OpenLP', 'Backup of the data folder failed!'))
return
message = translate('OpenLP',
'A backup of the data folder has been created'
'at {text}').format(text=data_folder_backup_path)
'A backup of the data folder has been created in:\n\n'
'{text}').format(text=data_folder_backup_path)
QtWidgets.QMessageBox.information(None, translate('OpenLP', 'Backup'), message)
# Update the version in the settings

View File

@ -75,19 +75,26 @@ def get_db_path(plugin_name, db_file_name=None):
name=db_file_name)
def handle_db_error(plugin_name, db_file_name):
def handle_db_error(self, plugin_name, db_file_name):
"""
Log and report to the user that a database cannot be loaded
:param self: Allows the usage of other functions.
:param plugin_name: Name of plugin
:param db_file_name: File name of database
:return: None
"""
db_path = get_db_path(plugin_name, db_file_name)
log.exception('Error loading database: {db}'.format(db=db_path))
critical_error_message_box(translate('OpenLP.Manager', 'Database Error'),
translate('OpenLP.Manager',
'OpenLP cannot load your database.\n\nDatabase: {db}').format(db=db_path))
# Check if the path (Eg. C:/ or D:/) exists in the system, if not: 'pass' so def load will handle the missing
# drive in advancedtab.py. Otherwise check for "Normal" database errors.
self.current_data_path = AppLocation.get_data_path()
if not os.path.exists(self.current_data_path):
pass
else:
db_path = get_db_path(plugin_name, db_file_name)
log.exception('Error loading database: {db}'.format(db=db_path))
critical_error_message_box(translate('OpenLP.Manager', 'Database Error'),
translate('OpenLP.Manager',
'OpenLP cannot load your database.\n\nDatabase: {db}').format(db=db_path))
def init_url(plugin_name, db_file_name=None):

View File

@ -401,23 +401,32 @@ class AdvancedTab(SettingsTab):
log.error('Data path not found {path}'.format(path=self.current_data_path))
answer = QtWidgets.QMessageBox.critical(
self, translate('OpenLP.AdvancedTab', 'Data Directory Error'),
translate('OpenLP.AdvancedTab', 'OpenLP data directory was not found\n\n{path}\n\n'
'This data directory was previously changed from the OpenLP '
'default location. If the new location was on removable '
'media, that media needs to be made available.\n\n'
'Click "No" to stop loading OpenLP. allowing you to fix the the problem.\n\n'
'Click "Yes" to reset the data directory to the default '
'location.').format(path=self.current_data_path),
translate('OpenLP.AdvancedTab', 'OpenLP data folder was not found in:\n\n{path}\n\n'
'The location of the data folder was previously changed from the OpenLP\'s\n'
'default location. If the data was stored on removable device, that device\nneeds to '
'be made available.\n\n You may reset the data location '
'back to the default settings, or you can try to make the current '
'location available.\n\n'
'Do you want to reset the default data location?\n\n'
'If you click "No" you can try to fix the the problem.\n'
'If you click "Yes" the data will be reset to the default location. \n\n'
'You will need to re-start OpenLP after this decision.').format(path=self.current_data_path),
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No),
QtWidgets.QMessageBox.No)
if answer == QtWidgets.QMessageBox.No:
log.info('User requested termination')
self.main_window.clean_up()
# self.main_window.clean_up() is causing tracebacks, not sure if it's required in some cases.
try:
self.main_window.clean_up()
except:
pass
sys.exit()
# If answer was yes, Set data location to default and shut down OpenLP.
if answer == QtWidgets.QMessageBox.Yes:
settings.remove('advanced/data path')
self.current_data_path = AppLocation.get_data_path()
log.warning('User requested data path set to default {path}'.format(path=self.current_data_path))
sys.exit()
# Set data location to default.
settings.remove('advanced/data path')
self.current_data_path = AppLocation.get_data_path()
log.warning('User requested data path set to default {path}'.format(path=self.current_data_path))
self.data_directory_label.setText(os.path.abspath(self.current_data_path))
# Don't allow data directory move if running portable.
if settings.value('advanced/is portable'):