scrapy.service: fixed minor logging bug on win32 platform with different line endings

This commit is contained in:
Pablo Hoffman 2010-06-10 14:50:06 -03:00
parent a8b80f3e2f
commit d76276408e
1 changed files with 7 additions and 6 deletions

View File

@ -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:])