提交 11f296b7 编写于 作者: P Pablo Hoffman

removed hack for switching standard descriptors in favor of using LOG_STDOUT=False by default

上级 8ed743f2
......@@ -5,7 +5,6 @@ See documentation in docs/topics/logging.rst
"""
import sys
from traceback import format_exc
from contextlib import contextmanager
from twisted.python import log
from scrapy.xlib.pydispatch import dispatcher
......@@ -73,13 +72,3 @@ def err(*args, **kwargs):
component = kwargs.pop('component', BOT_NAME)
kwargs['system'] = domain if domain else component
log.err(*args, **kwargs)
_std_descriptors_backup = (sys.stdout, sys.stderr)
@contextmanager
def _std_descriptors():
cur = (sys.stdout, sys.stderr)
sys.stdout, sys.stderr = _std_descriptors_backup
yield
sys.stdout, sys.stderr = cur
......@@ -4,8 +4,6 @@ Scrapy Shell
See documentation in docs/topics/shell.rst
"""
from __future__ import with_statement
import os
import urllib
import urlparse
......@@ -22,7 +20,6 @@ from scrapy.core.manager import scrapymanager
from scrapy.core.engine import scrapyengine
from scrapy.http import Request
from scrapy.fetcher import get_or_create_spider
from scrapy import log
def relevant_var(varname):
return varname not in ['shelp', 'fetch', 'view', '__builtins__', 'In', \
......@@ -151,6 +148,4 @@ class Shell(object):
def inspect_response(response):
"""Open a shell to inspect the given response"""
with log._std_descriptors():
shell = Shell(nofetch=True)
shell.inspect_response(response)
Shell(nofetch=True).inspect_response(response)
"""
Function for invoking the Python Debugger from Scrapy
"""
from __future__ import absolute_import, with_statement
from pdb import Pdb
from scrapy import log
class ScrapyPdb(Pdb):
def setup(self, f, t):
Pdb.setup(self, f, t)
self.curindex -= 2
def set_trace():
"""Like pdb.set_trace() but works nice with the Scrapy log"""
with log._std_descriptors():
ScrapyPdb().set_trace()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册