better handle an unlikely error in the Complete Individual report
This commit is contained in:
parent
d9ec7d5e2a
commit
eeaaac060e
@ -29,6 +29,7 @@ The User class provides basic interaction with the user.
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gramps.gen.const import URL_BUGHOME
|
||||
from gramps.gen import user
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@ -182,7 +183,7 @@ class User(user.User):
|
||||
if self.error_function:
|
||||
self.error_function(title, error)
|
||||
else:
|
||||
self._fileout.write("%s %s" % (title, error))
|
||||
self._fileout.write("%s\n%s\n" % (title, error))
|
||||
|
||||
def notify_db_error(self, error):
|
||||
"""
|
||||
@ -191,6 +192,8 @@ class User(user.User):
|
||||
:param error: the error message
|
||||
:type error: str
|
||||
:returns: none
|
||||
|
||||
These exact strings are also in gui/dialog.py -- keep them in sync
|
||||
"""
|
||||
self.notify_error(
|
||||
_("Low level database corruption detected"),
|
||||
@ -199,6 +202,26 @@ class User(user.User):
|
||||
"the Family Tree Manager. Select the database and "
|
||||
'click on the Repair button') + '\n\n' + error)
|
||||
|
||||
def notify_db_repair(self, error):
|
||||
"""
|
||||
Notify the user their DB might need repair.
|
||||
|
||||
:param error: the error message
|
||||
:type error: str
|
||||
:returns: none
|
||||
|
||||
These exact strings are also in gui/dialog.py -- keep them in sync
|
||||
"""
|
||||
self.notify_error(
|
||||
_('Error detected in database'),
|
||||
_('Gramps has detected an error in the database. This can '
|
||||
'usually be resolved by running the "Check and Repair Database" '
|
||||
'tool.\n\nIf this problem continues to exist after running this '
|
||||
'tool, please file a bug report at '
|
||||
'%(gramps_bugtracker_url)s\n\n'
|
||||
) % {'gramps_bugtracker_url' : URL_BUGHOME}
|
||||
+ error + '\n\n')
|
||||
|
||||
def info(self, msg1, infotext, parent=None, monospaced=False):
|
||||
"""
|
||||
Displays information to the CLI
|
||||
|
@ -172,6 +172,16 @@ class User(metaclass=ABCMeta):
|
||||
:returns: none
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def notify_db_repair(self, error):
|
||||
"""
|
||||
Notify the user their DB might need repair.
|
||||
|
||||
:param error: the error message
|
||||
:type error: str
|
||||
:returns: none
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def info(self, msg1, infotext, parent=None, monospaced=False):
|
||||
"""
|
||||
|
@ -198,18 +198,21 @@ class ErrorDialog(Gtk.MessageDialog): # parent-OK
|
||||
class RunDatabaseRepair(ErrorDialog): # parent-OK
|
||||
def __init__(self, msg, parent=None):
|
||||
ErrorDialog.__init__(
|
||||
# These exact strings are also in cli/user.py -- keep them in sync
|
||||
self,
|
||||
_('Error detected in database'),
|
||||
_('Gramps has detected an error in the database. This can '
|
||||
'usually be resolved by running the "Check and Repair Database" '
|
||||
'tool.\n\nIf this problem continues to exist after running this '
|
||||
'tool, please file a bug report at '
|
||||
'%(gramps_bugtracker_url)s\n\n')
|
||||
% {'gramps_bugtracker_url' : URL_BUGHOME} + msg, parent)
|
||||
'%(gramps_bugtracker_url)s\n\n'
|
||||
) % {'gramps_bugtracker_url' : URL_BUGHOME}
|
||||
+ msg, parent)
|
||||
|
||||
class DBErrorDialog(ErrorDialog): # parent-OK
|
||||
def __init__(self, msg, parent=None):
|
||||
ErrorDialog.__init__(
|
||||
# These exact strings are also in cli/user.py -- keep them in sync
|
||||
self,
|
||||
_("Low level database corruption detected"),
|
||||
_("Gramps has detected a problem in the underlying "
|
||||
|
@ -37,7 +37,7 @@ import sys
|
||||
from gramps.gen import user
|
||||
from .utils import ProgressMeter
|
||||
from .dialog import (WarningDialog, ErrorDialog, DBErrorDialog,
|
||||
InfoDialog, QuestionDialog2)
|
||||
RunDatabaseRepair, InfoDialog, QuestionDialog2)
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# User class
|
||||
@ -162,6 +162,19 @@ class User(user.User):
|
||||
else:
|
||||
DBErrorDialog(error, parent=None) # parent-OK
|
||||
|
||||
def notify_db_repair(self, error):
|
||||
"""
|
||||
Notify the user their DB might need repair.
|
||||
|
||||
:param error: the DB error message
|
||||
:type error: str
|
||||
:returns: none
|
||||
"""
|
||||
if self.uistate:
|
||||
RunDatabaseRepair(error, parent=self.uistate.window) # parent-OK
|
||||
else:
|
||||
RunDatabaseRepair(error, parent=None) # parent-OK
|
||||
|
||||
def info(self, msg1, infotext, parent=None, monospaced=False):
|
||||
"""
|
||||
Calls the GUI InfoDialog
|
||||
|
@ -548,9 +548,11 @@ class IndivCompleteReport(Report):
|
||||
media_handle = media_ref.get_reference_handle()
|
||||
media = self._db.get_media_from_handle(media_handle)
|
||||
if media is None:
|
||||
from gramps.gui.dialog import RunDatabaseRepair
|
||||
RunDatabaseRepair( # no-parent
|
||||
self._user.notify_db_repair(
|
||||
_('Non existing media found in the Gallery'))
|
||||
self.doc.end_table()
|
||||
self.doc.start_paragraph('IDS-Normal')
|
||||
self.doc.end_paragraph()
|
||||
return
|
||||
mime_type = media.get_mime_type()
|
||||
if not mime_type or not mime_type.startswith("image"):
|
||||
|
Loading…
Reference in New Issue
Block a user