0002542: Crash whilst generating web pages from command line
Throwing Report Error if center person is not in database. Added catching of Report Error to CommandLineReport if using GUI it is not possible to cause this, as you have to select a person that is in the DB. However on the command line you can specify any PID and even no person with that pid exists an error was thrown. svn: r13004
This commit is contained in:
@@ -36,15 +36,16 @@ from gettext import gettext as _
|
||||
# gramps modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from BasicUtils import name_displayer
|
||||
from Errors import ReportError
|
||||
from gen.lib import ChildRefType
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug.menu import BooleanOption, NumberOption, PersonOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
|
||||
from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
FONT_SANS_SERIF,
|
||||
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
|
||||
from BasicUtils import name_displayer
|
||||
FONT_SANS_SERIF, INDEX_TYPE_TOC,
|
||||
PARA_ALIGN_CENTER)
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
|
||||
|
||||
from gen.lib import ChildRefType
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@@ -89,6 +90,8 @@ class AncestorReport(Report):
|
||||
self.opt_namebrk = menu.get_option_by_name('namebrk').get_value()
|
||||
pid = menu.get_option_by_name('pid').get_value()
|
||||
self.center_person = database.get_person_from_gramps_id(pid)
|
||||
if (self.center_person == None) :
|
||||
raise ReportError(_("Person %s is not in the Database") % pid )
|
||||
|
||||
def apply_filter(self, person_handle, index, generation=1):
|
||||
"""
|
||||
|
||||
@@ -35,18 +35,19 @@ import datetime, time
|
||||
# GRAMPS modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from BasicUtils import name_displayer as _nd
|
||||
from Errors import ReportError
|
||||
from gen.lib import NameType, EventType, Name, Date, Person
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle,
|
||||
FONT_SERIF, PARA_ALIGN_RIGHT,
|
||||
PARA_ALIGN_LEFT, PARA_ALIGN_CENTER)
|
||||
from BasicUtils import name_displayer as _nd
|
||||
from gen.plug import PluginManager
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
|
||||
from gen.plug.menu import BooleanOption, StringOption, NumberOption, \
|
||||
EnumeratedListOption, FilterOption, PersonOption
|
||||
import GrampsLocale
|
||||
from gen.lib import NameType, EventType, Name, Date, Person
|
||||
from Utils import probably_alive
|
||||
from gen.plug.menu import (BooleanOption, StringOption, NumberOption,
|
||||
EnumeratedListOption, FilterOption, PersonOption)
|
||||
from gui.utils import ProgressMeter
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
|
||||
from Utils import probably_alive
|
||||
import GrampsLocale
|
||||
|
||||
import libholiday
|
||||
|
||||
@@ -81,6 +82,8 @@ class CalendarReport(Report):
|
||||
self.filter = self.filter_option.get_filter()
|
||||
pid = mgobn('pid')
|
||||
self.center_person = database.get_person_from_gramps_id(pid)
|
||||
if (self.center_person == None) :
|
||||
raise ReportError(_("Person %s is not in the Database") % pid )
|
||||
|
||||
def get_name(self, person, maiden_name = None):
|
||||
"""
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Reports/Text Reports/Descendant Report
|
||||
Reports/Text Reports/Descendant Report.
|
||||
"""
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@@ -39,14 +39,14 @@ from gettext import gettext as _
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug.menu import NumberOption, PersonOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
|
||||
from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
FONT_SANS_SERIF,
|
||||
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
|
||||
import Sort
|
||||
FONT_SANS_SERIF, INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
|
||||
from gen.plug.menu import NumberOption, PersonOption
|
||||
from BasicUtils import name_displayer
|
||||
from Errors import ReportError
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
|
||||
import DateHandler
|
||||
import Sort
|
||||
|
||||
_BORN = _('b.')
|
||||
_DIED = _('d.')
|
||||
@@ -80,6 +80,8 @@ class DescendantReport(Report):
|
||||
self.max_generations = menu.get_option_by_name('gen').get_value()
|
||||
pid = menu.get_option_by_name('pid').get_value()
|
||||
self.center_person = database.get_person_from_gramps_id(pid)
|
||||
if (self.center_person == None) :
|
||||
raise ReportError(_("Person %s is not in the Database") % pid )
|
||||
sort = Sort.Sort(self.database)
|
||||
self.by_birthdate = sort.by_birthdate
|
||||
|
||||
@@ -128,16 +130,16 @@ class DescendantReport(Report):
|
||||
self.doc.start_paragraph("DR-Title")
|
||||
name = name_displayer.display(self.center_person)
|
||||
title = _("Descendants of %s") % name
|
||||
mark = IndexMark(title,INDEX_TYPE_TOC,1)
|
||||
self.doc.write_text(title,mark)
|
||||
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
|
||||
self.doc.write_text(title, mark)
|
||||
self.doc.end_paragraph()
|
||||
self.dump(1,self.center_person)
|
||||
self.dump(1, self.center_person)
|
||||
|
||||
def dump(self,level,person):
|
||||
def dump(self, level, person):
|
||||
|
||||
self.doc.start_paragraph("DR-Level%d" % min(level,32),"%d." % level)
|
||||
mark = ReportUtils.get_person_mark(self.database,person)
|
||||
self.doc.write_text(name_displayer.display(person),mark)
|
||||
self.doc.start_paragraph("DR-Level%d" % min(level, 32), "%d." % level)
|
||||
mark = ReportUtils.get_person_mark(self.database, person)
|
||||
self.doc.write_text(name_displayer.display(person), mark)
|
||||
self.dump_dates(person)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
@@ -147,20 +149,20 @@ class DescendantReport(Report):
|
||||
for family_handle in person.get_family_handle_list():
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
|
||||
spouse_handle = ReportUtils.find_spouse(person,family)
|
||||
spouse_handle = ReportUtils.find_spouse(person, family)
|
||||
if spouse_handle:
|
||||
spouse = self.database.get_person_from_handle(spouse_handle)
|
||||
mark = ReportUtils.get_person_mark(self.database,person)
|
||||
self.doc.start_paragraph("DR-Spouse%d" % min(level,32))
|
||||
mark = ReportUtils.get_person_mark(self.database, person)
|
||||
self.doc.start_paragraph("DR-Spouse%d" % min(level, 32))
|
||||
name = name_displayer.display(spouse)
|
||||
self.doc.write_text(_("sp. %(spouse)s") % {'spouse':name},mark)
|
||||
self.doc.write_text(_("sp. %(spouse)s") % {'spouse':name}, mark)
|
||||
self.dump_dates(spouse)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
childlist = family.get_child_ref_list()[:]
|
||||
for child_ref in childlist:
|
||||
child = self.database.get_person_from_handle(child_ref.ref)
|
||||
self.dump(level+1,child)
|
||||
self.dump(level+1, child)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@@ -183,11 +185,11 @@ class DescendantOptions(MenuReportOptions):
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
gen = NumberOption(_("Generations"),10,1,15)
|
||||
gen = NumberOption(_("Generations"), 10, 1, 15)
|
||||
gen.set_help(_("The number of generations to include in the report"))
|
||||
menu.add_option(category_name,"gen",gen)
|
||||
menu.add_option(category_name, "gen", gen)
|
||||
|
||||
def make_default_style(self,default_style):
|
||||
def make_default_style(self, default_style):
|
||||
"""Make the default output style for the Descendant Report."""
|
||||
f = FontStyle()
|
||||
f.set_size(12)
|
||||
@@ -201,29 +203,29 @@ class DescendantOptions(MenuReportOptions):
|
||||
p.set_font(f)
|
||||
p.set_alignment(PARA_ALIGN_CENTER)
|
||||
p.set_description(_("The style used for the title of the page."))
|
||||
default_style.add_paragraph_style("DR-Title",p)
|
||||
default_style.add_paragraph_style("DR-Title", p)
|
||||
|
||||
f = FontStyle()
|
||||
f.set_size(10)
|
||||
for i in range(1,33):
|
||||
for i in range(1, 33):
|
||||
p = ParagraphStyle()
|
||||
p.set_font(f)
|
||||
p.set_top_margin(ReportUtils.pt2cm(f.get_size()*0.125))
|
||||
p.set_bottom_margin(ReportUtils.pt2cm(f.get_size()*0.125))
|
||||
p.set_first_indent(-0.5)
|
||||
p.set_left_margin(min(10.0,float(i-0.5)))
|
||||
p.set_left_margin(min(10.0, float(i-0.5)))
|
||||
p.set_description(_("The style used for the "
|
||||
"level %d display.") % i)
|
||||
default_style.add_paragraph_style("DR-Level%d" % min(i,32), p)
|
||||
default_style.add_paragraph_style("DR-Level%d" % min(i, 32), p)
|
||||
|
||||
p = ParagraphStyle()
|
||||
p.set_font(f)
|
||||
p.set_top_margin(ReportUtils.pt2cm(f.get_size()*0.125))
|
||||
p.set_bottom_margin(ReportUtils.pt2cm(f.get_size()*0.125))
|
||||
p.set_left_margin(min(10.0,float(i-0.5)))
|
||||
p.set_left_margin(min(10.0, float(i-0.5)))
|
||||
p.set_description(_("The style used for the "
|
||||
"spouse level %d display.") % i)
|
||||
default_style.add_paragraph_style("DR-Spouse%d" % min(i,32), p)
|
||||
default_style.add_paragraph_style("DR-Spouse%d" % min(i, 32), p)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
@@ -38,16 +38,17 @@ from gettext import gettext as _
|
||||
# GRAMPS modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from BasicUtils import name_displayer as _nd
|
||||
from Errors import ReportError
|
||||
from gen.lib import EventType, FamilyRelType, Person
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug.menu import BooleanOption, NumberOption, PersonOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
|
||||
from ReportBase import Bibliography, Endnotes
|
||||
from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
FONT_SANS_SERIF, FONT_SERIF,
|
||||
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
|
||||
from gen.plug.menu import BooleanOption, NumberOption, PersonOption
|
||||
from ReportBase import (Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT,
|
||||
Bibliography, Endnotes)
|
||||
import DateHandler
|
||||
from BasicUtils import name_displayer as _nd
|
||||
import Utils
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@@ -118,6 +119,8 @@ class DetAncestorReport(Report):
|
||||
self.inc_attrs = menu.get_option_by_name('incattrs').get_value()
|
||||
pid = menu.get_option_by_name('pid').get_value()
|
||||
self.center_person = database.get_person_from_gramps_id(pid)
|
||||
if (self.center_person == None) :
|
||||
raise ReportError(_("Person %s is not in the Database") % pid )
|
||||
|
||||
self.gen_handles = {}
|
||||
self.prev_gen_handles = {}
|
||||
@@ -184,7 +187,7 @@ class DetAncestorReport(Report):
|
||||
mother_handle = family.get_mother_handle()
|
||||
if (mother_handle is None or
|
||||
mother_handle not in self.map.itervalues() or
|
||||
person.get_gender() == gen.lib.Person.FEMALE):
|
||||
person.get_gender() == Person.FEMALE):
|
||||
# The second test above also covers the 1. person's
|
||||
# mate, which is not an ancestor and as such is not
|
||||
# included in the self.map dictionary
|
||||
@@ -578,7 +581,7 @@ class DetAncestorReport(Report):
|
||||
for family_handle in person.get_family_handle_list():
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
ind_handle = None
|
||||
if person.get_gender() == gen.lib.Person.MALE:
|
||||
if person.get_gender() == Person.MALE:
|
||||
ind_handle = family.get_mother_handle()
|
||||
else:
|
||||
ind_handle = family.get_father_handle()
|
||||
@@ -588,10 +591,10 @@ class DetAncestorReport(Report):
|
||||
event = self.database.get_event_from_handle(event_ref.ref)
|
||||
if event:
|
||||
etype = event.get_type()
|
||||
if etype == gen.lib.EventType.BAPTISM or \
|
||||
etype == gen.lib.EventType.BURIAL or \
|
||||
etype == gen.lib.EventType.BIRTH or \
|
||||
etype == gen.lib.EventType.DEATH :
|
||||
if etype == EventType.BAPTISM or \
|
||||
etype == EventType.BURIAL or \
|
||||
etype == EventType.BIRTH or \
|
||||
etype == EventType.DEATH :
|
||||
has_info = True
|
||||
break
|
||||
if not has_info:
|
||||
@@ -614,7 +617,7 @@ class DetAncestorReport(Report):
|
||||
name = _nd.display_formal(ind)
|
||||
mark = ReportUtils.get_person_mark(self.database, ind)
|
||||
|
||||
if family.get_relationship() == gen.lib.FamilyRelType.MARRIED:
|
||||
if family.get_relationship() == FamilyRelType.MARRIED:
|
||||
self.doc.write_text(_("Spouse: %s") % name, mark)
|
||||
else:
|
||||
self.doc.write_text(_("Relationship with: %s") % name, mark)
|
||||
|
||||
@@ -39,16 +39,17 @@ from gettext import gettext as _
|
||||
# GRAMPS modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from BasicUtils import name_displayer as _nd
|
||||
from Errors import ReportError
|
||||
from gen.lib import FamilyRelType, Person
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug.menu import BooleanOption, NumberOption, PersonOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
|
||||
from ReportBase import Bibliography, Endnotes
|
||||
from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
FONT_SANS_SERIF, FONT_SERIF,
|
||||
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
|
||||
from ReportBase import (Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT,
|
||||
Bibliography, Endnotes)
|
||||
import DateHandler
|
||||
from BasicUtils import name_displayer as _nd
|
||||
import Utils
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@@ -125,6 +126,8 @@ class DetDescendantReport(Report):
|
||||
self.inc_paths = menu.get_option_by_name('incpaths').get_value()
|
||||
pid = menu.get_option_by_name('pid').get_value()
|
||||
self.center_person = database.get_person_from_gramps_id(pid)
|
||||
if (self.center_person == None) :
|
||||
raise ReportError(_("Person %s is not in the Database") % pid )
|
||||
|
||||
self.gen_handles = {}
|
||||
self.prev_gen_handles = {}
|
||||
@@ -435,7 +438,7 @@ class DetDescendantReport(Report):
|
||||
"""
|
||||
Write information about the person's spouse/mate.
|
||||
"""
|
||||
if person.get_gender() == gen.lib.Person.MALE:
|
||||
if person.get_gender() == Person.MALE:
|
||||
mate_handle = family.get_mother_handle()
|
||||
else:
|
||||
mate_handle = family.get_father_handle()
|
||||
@@ -446,7 +449,7 @@ class DetDescendantReport(Report):
|
||||
self.doc.start_paragraph("DDR-MoreHeader")
|
||||
name = _nd.display_formal(mate)
|
||||
mark = ReportUtils.get_person_mark(self.database, mate)
|
||||
if family.get_relationship() == gen.lib.FamilyRelType.MARRIED:
|
||||
if family.get_relationship() == FamilyRelType.MARRIED:
|
||||
self.doc.write_text(_("Spouse: %s") % name, mark)
|
||||
else:
|
||||
self.doc.write_text(_("Relationship with: %s") % name, mark)
|
||||
|
||||
@@ -34,13 +34,14 @@ from gettext import gettext as _
|
||||
# gramps modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from BasicUtils import name_displayer
|
||||
from Errors import ReportError
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug.menu import PersonOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
|
||||
from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle, TableStyle,
|
||||
TableCellStyle, FONT_SANS_SERIF, INDEX_TYPE_TOC,
|
||||
PARA_ALIGN_CENTER)
|
||||
from BasicUtils import name_displayer
|
||||
from gen.plug.menu import PersonOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
|
||||
import DateHandler
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@@ -69,6 +70,8 @@ class EndOfLineReport(Report):
|
||||
menu = options_class.menu
|
||||
pid = menu.get_option_by_name('pid').get_value()
|
||||
self.center_person = database.get_person_from_gramps_id(pid)
|
||||
if (self.center_person == None) :
|
||||
raise ReportError(_("Person %s is not in the Database") % pid )
|
||||
|
||||
# eol_map is a map whose:
|
||||
# keys are the generations of the people
|
||||
|
||||
@@ -61,7 +61,6 @@ class IndivCompleteReport(Report):
|
||||
The arguments are:
|
||||
|
||||
database - the GRAMPS database instance
|
||||
person - currently selected person
|
||||
options_class - instance of the Options class for this report
|
||||
|
||||
This report needs the following parameters (class variables)
|
||||
@@ -70,7 +69,7 @@ class IndivCompleteReport(Report):
|
||||
filter - Filter to be applied to the people of the database.
|
||||
The option class carries its number, and the function
|
||||
returning the list of filters.
|
||||
cites - Whether or not to include source informaiton.
|
||||
cites - Whether or not to include source information.
|
||||
"""
|
||||
|
||||
Report.__init__(self, database, options_class)
|
||||
|
||||
@@ -36,12 +36,13 @@ from gettext import gettext as _
|
||||
# gramps modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from BasicUtils import name_displayer
|
||||
from Errors import ReportError
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
FONT_SANS_SERIF, INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
|
||||
from gen.plug.menu import NumberOption, BooleanOption, PersonOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
|
||||
from BasicUtils import name_displayer
|
||||
import DateHandler
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@@ -80,6 +81,8 @@ class KinshipReport(Report):
|
||||
self.inc_aunts = menu.get_option_by_name('incaunts').get_value()
|
||||
pid = menu.get_option_by_name('pid').get_value()
|
||||
self.person = database.get_person_from_gramps_id(pid)
|
||||
if (self.person == None) :
|
||||
raise ReportError(_("Person %s is not in the Database") % pid )
|
||||
|
||||
self.__db = database
|
||||
self.rel_calc = PluginManager.get_instance().get_relationship_calculator()
|
||||
|
||||
@@ -40,13 +40,14 @@ import math
|
||||
# GRAMPS modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from BasicUtils import name_displayer
|
||||
from Errors import ReportError
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug.menu import PersonOption
|
||||
from ReportBase import Report, MenuReportOptions, ReportUtils, CATEGORY_TEXT
|
||||
from BasicUtils import name_displayer
|
||||
from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
FONT_SANS_SERIF, PARA_ALIGN_CENTER,
|
||||
INDEX_TYPE_TOC)
|
||||
from ReportBase import Report, MenuReportOptions, ReportUtils, CATEGORY_TEXT
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@@ -71,6 +72,8 @@ class NumberOfAncestorsReport(Report):
|
||||
self.__db = database
|
||||
pid = options_class.menu.get_option_by_name('pid').get_value()
|
||||
self.__person = database.get_person_from_gramps_id(pid)
|
||||
if (self.__person == None) :
|
||||
raise ReportError(_("Person %s is not in the Database") % pid )
|
||||
|
||||
def write_report(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user