From 8e5ede717945921a0302fdbefd9561a3e0f476d7 Mon Sep 17 00:00:00 2001 From: Daniel Grana Date: Tue, 7 Jul 2009 16:22:23 -0300 Subject: [PATCH] shell command was broken by recent commits because scrapyengine.crawl does not returns a deferred anymore, now we use scrapyengine.schedule that returns the deferred of the download response --- scrapy/command/commands/shell.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/scrapy/command/commands/shell.py b/scrapy/command/commands/shell.py index 8ef9eb94e..12af9c155 100644 --- a/scrapy/command/commands/shell.py +++ b/scrapy/command/commands/shell.py @@ -34,12 +34,8 @@ class Command(ScrapyCommand): """ You can use this function to update the Scrapy objects that will be available in the shell""" pass - def _get_response(self, response): - self.response = response - return [] - def get_url(self, url): - self.response = None + response = None url = url.strip() if url: @@ -52,15 +48,15 @@ class Command(ScrapyCommand): if u.scheme not in ('http', 'https', 'file'): print "Unsupported scheme '%s' in URL: <%s>" % (u.scheme, url) return - request = Request(url, callback=self._get_response) + request = Request(url) else: - request = self.user_ns['request'].replace(callback=self._get_response) + request = self.user_ns['request'] spider = get_or_create_spider(url) print "Fetching %s..." % request - threads.blockingCallFromThread(reactor, scrapyengine.crawl, request, spider) - if self.response: - self.generate_vars(url, self.response, request) + response = threads.blockingCallFromThread(reactor, scrapyengine.schedule, request, spider) + if response: + self.generate_vars(url, response, request) return True def generate_vars(self, url=None, response=None, request=None):