diff --git a/linkcheck/log/CSVLogger.py b/linkcheck/log/CSVLogger.py index bacad2f7..be16b6ff 100644 --- a/linkcheck/log/CSVLogger.py +++ b/linkcheck/log/CSVLogger.py @@ -59,7 +59,7 @@ class CSVLogger (StandardLogger): "# dlsize;"+self.lineterminator+\ "# checktime;"+self.lineterminator+\ "# cached;"+self.lineterminator) - self.fd.flush() + self.flush() self.writer = csv.writer(self.fd, dialect='excel', delimiter=self.separator, lineterminator=self.lineterminator) @@ -75,7 +75,7 @@ class CSVLogger (StandardLogger): urlData.dlsize, urlData.checktime, urlData.cached] self.writer.writerow(row) - self.fd.flush() + self.flush() def endOfOutput (self, linknumber=-1): @@ -85,6 +85,6 @@ class CSVLogger (StandardLogger): duration = self.stoptime - self.starttime self.fd.write("# "+i18n._("Stopped checking at %s (%s)%s")%\ (strtime(self.stoptime), strduration(duration), self.lineterminator)) - self.fd.flush() + self.flush() self.fd.close() self.fd = None diff --git a/linkcheck/log/ColoredLogger.py b/linkcheck/log/ColoredLogger.py index 33cb548c..af0c9b78 100644 --- a/linkcheck/log/ColoredLogger.py +++ b/linkcheck/log/ColoredLogger.py @@ -142,7 +142,7 @@ class ColoredLogger (StandardLogger): self.errors += 1 self.fd.write(self.colorinvalid+urlData.errorString+ self.colorreset+"\n") - self.fd.flush() + self.flush() def endOfOutput (self, linknumber=-1): if self.fd is None: return diff --git a/linkcheck/log/GMLLogger.py b/linkcheck/log/GMLLogger.py index 7613a9cb..cc661ca5 100644 --- a/linkcheck/log/GMLLogger.py +++ b/linkcheck/log/GMLLogger.py @@ -43,7 +43,7 @@ class GMLLogger (StandardLogger): self.fd.write("# "+(i18n._("Write comments and bugs to %s\n\n") % \ Config.Email)) self.fd.write("graph [\n directed 1\n") - self.fd.flush() + self.flush() def newUrl (self, urlData): @@ -85,7 +85,7 @@ class GMLLogger (StandardLogger): if self.has_field("result"): self.fd.write(" valid %d\n" % (node.valid and 1 or 0)) self.fd.write(" ]\n") - self.fd.flush() + self.flush() def endOfOutput (self, linknumber=-1): @@ -96,5 +96,5 @@ class GMLLogger (StandardLogger): duration = self.stoptime - self.starttime self.fd.write("# "+i18n._("Stopped checking at %s (%s)\n")%\ (strtime(self.stoptime), strduration(duration))) - self.fd.flush() + self.flush() self.fd = None diff --git a/linkcheck/log/HtmlLogger.py b/linkcheck/log/HtmlLogger.py index 6e4b311a..c6ef2569 100644 --- a/linkcheck/log/HtmlLogger.py +++ b/linkcheck/log/HtmlLogger.py @@ -61,7 +61,7 @@ class HtmlLogger (StandardLogger): "
"+Config.Freeware+"

"+ (i18n._("Start checking at %s\n") % strtime(self.starttime))+ "
") - self.fd.flush() + self.flush() def newUrl (self, urlData): @@ -136,7 +136,7 @@ class HtmlLogger (StandardLogger): "\n"+self.tableerror+ urlData.errorString+"\n\n") self.fd.write("
") - self.fd.flush() + self.flush() def endOfOutput (self, linknumber=-1): @@ -169,5 +169,5 @@ class HtmlLogger (StandardLogger): self.fd.write(i18n._("Write comments and bugs to %s\n\n") %\ (''+Config.Email+".")) self.fd.write("") - self.fd.flush() + self.flush() self.fd = None diff --git a/linkcheck/log/SQLLogger.py b/linkcheck/log/SQLLogger.py index bbbfdd0d..477d5c03 100644 --- a/linkcheck/log/SQLLogger.py +++ b/linkcheck/log/SQLLogger.py @@ -40,7 +40,7 @@ class SQLLogger (StandardLogger): self.fd.write("-- "+(i18n._("Get the newest version at %s\n") % Config.Url)) self.fd.write("-- "+(i18n._("Write comments and bugs to %s\n\n") % \ Config.Email)) - self.fd.flush() + self.flush() def newUrl (self, urlData): @@ -69,7 +69,7 @@ class SQLLogger (StandardLogger): urlData.dlsize, urlData.cached, self.separator)) - self.fd.flush() + self.flush() def endOfOutput (self, linknumber=-1): @@ -79,5 +79,5 @@ class SQLLogger (StandardLogger): duration = self.stoptime - self.starttime self.fd.write("-- "+i18n._("Stopped checking at %s (%s)\n")%\ (strtime(self.stoptime), strduration(duration))) - self.fd.flush() + self.flush() self.fd = None diff --git a/linkcheck/log/StandardLogger.py b/linkcheck/log/StandardLogger.py index 47ecea18..9e1b7cf5 100644 --- a/linkcheck/log/StandardLogger.py +++ b/linkcheck/log/StandardLogger.py @@ -77,7 +77,7 @@ __init__(self, **args) self.fd.write(i18n._("Get the newest version at %s\n") % Config.Url) self.fd.write(i18n._("Write comments and bugs to %s\n\n") % Config.Email) self.fd.write(i18n._("Start checking at %s\n") % strtime(self.starttime)) - self.fd.flush() + self.flush() def newUrl (self, urlData): @@ -132,11 +132,12 @@ __init__(self, **args) else: self.errors += 1 self.fd.write(urlData.errorString+"\n") - self.fd.flush() + self.flush() def endOfOutput (self, linknumber=-1): - if self.fd is None: return + if self.fd is None: + return if self.has_field('outro'): self.fd.write(i18n._("\nThats it. ")) #if self.warnings==1: @@ -157,5 +158,15 @@ __init__(self, **args) duration = self.stoptime - self.starttime self.fd.write(i18n._("Stopped checking at %s (%s)\n") % \ (strtime(self.stoptime), strduration(duration))) - self.fd.flush() + self.flush() self.fd = None + + + def flush (self): + """ignore flush errors since we are not responsible for proper + flushing of log output streams""" + if self.fd: + try: + self.fd.flush() + except IOError: + pass diff --git a/linkcheck/log/XMLLogger.py b/linkcheck/log/XMLLogger.py index db020384..555e1adb 100644 --- a/linkcheck/log/XMLLogger.py +++ b/linkcheck/log/XMLLogger.py @@ -46,7 +46,7 @@ class XMLLogger (StandardLogger): Config.Email) self.fd.write("-->\n\n") self.fd.write('\n\n') - self.fd.flush() + self.flush() def newUrl (self, urlData): @@ -98,7 +98,7 @@ class XMLLogger (StandardLogger): (node.valid and 1 or 0)) self.fd.write(" \n") self.fd.write(" \n") - self.fd.flush() + self.flush() def endOfOutput (self, linknumber=-1): @@ -111,5 +111,5 @@ class XMLLogger (StandardLogger): self.fd.write(i18n._("Stopped checking at %s (%s)\n")%\ (strtime(self.stoptime), strduration(duration))) self.fd.write("-->") - self.fd.flush() + self.flush() self.fd = None