From d76276408e3d0a4ad5fee8bd6e6b151667136a9c Mon Sep 17 00:00:00 2001 From: Pablo Hoffman Date: Thu, 10 Jun 2010 14:50:06 -0300 Subject: [PATCH] scrapy.service: fixed minor logging bug on win32 platform with different line endings --- scrapy/service.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scrapy/service.py b/scrapy/service.py index 483e6ec30..086b1ce7b 100644 --- a/scrapy/service.py +++ b/scrapy/service.py @@ -75,13 +75,14 @@ class ScrapyProcessProtocol(protocol.ProcessProtocol): self.deferred.callback(self) def _log_ended(self, msg): + tolog = [msg] if self.outdata: - msg += "\n>>> stdout (last %d lines) <<<\n%s" % (self.TAIL_LINES, \ - self.outdata) + tolog += [">>> stdout (last %d lines) <<<" % self.TAIL_LINES] + tolog += [self.outdata] if self.errdata: - msg += "\n>>> stderr (last %d lines) <<<\n%s" % (self.TAIL_LINES, \ - self.errdata) - log.msg(msg) + tolog += [">>> stderr (last %d lines) <<<" % self.TAIL_LINES] + tolog += [self.errdata] + log.msg(os.linesep.join(tolog)) def _tail(self, data, lines=TAIL_LINES): - return os.linesep.join(data.splitlines()[-lines:]) + return os.linesep.join(data.split(os.linesep)[-lines:])