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