diff --git a/src/Errors.py b/src/Errors.py index 66139bed4..04eaa9bf3 100644 --- a/src/Errors.py +++ b/src/Errors.py @@ -20,13 +20,17 @@ class ReportError(Exception): """Error used to report Report errors""" - def __init__(self,value): + def __init__(self,value,value2=""): Exception.__init__(self) self.value = value + self.value2 = value2 def __str__(self): return self.value + def messages(self): + return (self.value,self.value2) + class GedcomError(Exception): """Error used to report GEDCOM errors""" def __init__(self,value): diff --git a/src/QuestionDialog.py b/src/QuestionDialog.py index af56bf8f6..a03a96724 100644 --- a/src/QuestionDialog.py +++ b/src/QuestionDialog.py @@ -106,9 +106,9 @@ class ErrorDialog: label1 = self.xml.get_widget('label1') label2 = self.xml.get_widget('label2') - label1.set_text('%s' % msg1) + label1.set_text('%s' % str(msg1)) label1.set_use_markup(gtk.TRUE) - label2.set_text(msg2) + label2.set_text(str(msg2)) self.top.show() self.top.run() self.top.destroy() diff --git a/src/Report.py b/src/Report.py index 2840b7226..901e9e383 100644 --- a/src/Report.py +++ b/src/Report.py @@ -451,6 +451,12 @@ class ReportDialog: self.output_notebook.set_current_page(self.notebook_page) + if not self.get_target_is_directory(): + fname = self.target_fileentry.get_full_path(0) + (path,ext) = os.path.splitext(fname) + fname = path + obj.get_data('ext') + self.target_fileentry.set_filename(fname) + # Does this report format use styles? if self.style_button: self.style_button.set_sensitive(obj.get_data("styles")) diff --git a/src/docgen/AbiWordDoc.py b/src/docgen/AbiWordDoc.py index 1a24146ee..a8b6353bd 100644 --- a/src/docgen/AbiWordDoc.py +++ b/src/docgen/AbiWordDoc.py @@ -63,7 +63,14 @@ class AbiWordDoc(TextDoc.TextDoc): else: self.filename = filename - self.f = open(self.filename,"w") + try: + self.f = open(self.filename,"w") + except IOError,msg: + errmsg = "%s\n%s" % (_("Could not create %s") % self.filename, msg) + raise Errors.ReportError(errmsg) + except: + raise Errors.ReportError(_("Could not create %s") % self.filename) + self.f.write('\n') self.f.write('\n') diff --git a/src/docgen/HtmlDoc.py b/src/docgen/HtmlDoc.py index 369aa680e..85802aa3e 100644 --- a/src/docgen/HtmlDoc.py +++ b/src/docgen/HtmlDoc.py @@ -217,7 +217,14 @@ class HtmlDoc(TextDoc.TextDoc): self.base = os.path.dirname(self.filename) - self.f = open(self.filename,"w") + try: + self.f = open(self.filename,"w") + except IOError,msg: + errmsg = "%s\n%s" % (_("Could not create %s") % self.filename, msg) + raise Errors.ReportError(errmsg) + except: + raise Errors.ReportError(_("Could not create %s") % self.filename) + if self.meta: match = t_keyword_line_re.match(self.file_header) if match: @@ -319,9 +326,15 @@ class HtmlDoc(TextDoc.TextDoc): if name == 'template.html': continue fname = '%s/%s' % (self.base,name) - f = open(fname, 'wb') - f.write(self.map[name].read()) - f.close() + try: + f = open(fname, 'wb') + f.write(self.map[name].read()) + f.close() + except IOError,msg: + errmsg = "%s\n%s" % (_("Could not create %s") % fname, msg) + raise Errors.ReportError(errmsg) + except: + raise Errors.ReportError(_("Could not create %s") % fname) def add_photo(self,name,pos,x,y): self.empty = 0 diff --git a/src/docgen/LaTeXDoc.py b/src/docgen/LaTeXDoc.py index ad45b8ef7..7fff048f4 100644 --- a/src/docgen/LaTeXDoc.py +++ b/src/docgen/LaTeXDoc.py @@ -74,7 +74,14 @@ class LaTeXDoc(TextDoc.TextDoc): self.filename = filename + ".tex" else: self.filename = filename - self.f = open(self.filename,"w") + + try: + self.f = open(self.filename,"w") + except IOError,msg: + errmsg = "%s\n%s" % (_("Could not create %s") % self.filename, msg) + raise Errors.ReportError(errmsg) + except: + raise Errors.ReportError(_("Could not create %s") % self.filename) # Font size control seems to be limited. For now, ignore # any style constraints, and use 12pt has the default diff --git a/src/docgen/OpenDrawDoc.py b/src/docgen/OpenDrawDoc.py index 174ef5b73..de76eaf80 100644 --- a/src/docgen/OpenDrawDoc.py +++ b/src/docgen/OpenDrawDoc.py @@ -72,6 +72,9 @@ class OpenDrawDoc(DrawDoc.DrawDoc): try: self.content_xml = tempfile.mktemp() self.f = open(self.content_xml,"wb") + except IOError,msg: + errmsg = "%s\n%s" % (_("Could not create %s") % self.filename, msg) + raise Errors.ReportError(errmsg) except: raise Errors.ReportError("Could not create %s" % self.filename) diff --git a/src/docgen/OpenOfficeDoc.py b/src/docgen/OpenOfficeDoc.py index 640b9a5f9..2f570dadc 100644 --- a/src/docgen/OpenOfficeDoc.py +++ b/src/docgen/OpenOfficeDoc.py @@ -77,8 +77,11 @@ class OpenOfficeDoc(TextDoc.TextDoc): try: self.content_xml = tempfile.mktemp() self.f = open(self.content_xml,"wb") + except IOError,msg: + errmsg = "%s\n%s" % (_("Could not create %s") % self.content_xml, msg) + raise Errors.ReportError(errmsg) except: - raise Errors.ReportError("Could not create %s" % self.filename) + raise Errors.ReportError("Could not create %s" % self.content_xml) self.f.write('\n') self.f.write('\n') self.f.write('\n') self.f.write('') @@ -533,7 +551,15 @@ class OpenOfficeDoc(TextDoc.TextDoc): def _write_meta_file(self): name = self.name self.meta_xml = tempfile.mktemp() - self.f = open(self.meta_xml,"wb") + + try: + self.f = open(self.meta_xml,"wb") + except IOError,msg: + errmsg = "%s\n%s" % (_("Could not create %s") % self.meta_xml, msg) + raise Errors.ReportError(errmsg) + except: + raise Errors.ReportError(_("Could not create %s") % self.meta_xml) + self.f.write('\n') self.f.write('\n') self.f.write('