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

This commit is contained in:
Pablo Hoffman 2009-09-02 16:22:45 -03:00
parent 8ed743f265
commit 11f296b753
4 changed files with 1 additions and 38 deletions

View File

@ -1 +0,0 @@
LOG_STDOUT = True

View File

@ -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

View File

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

View File

@ -1,20 +0,0 @@
"""
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()