Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

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

Pablo Hoffmand76276408e3d
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:])