From 5971333a9371e0c8049a0cf4d90061718a3aff3e Mon Sep 17 00:00:00 2001 From: Rolando Espinoza La fuente Date: Mon, 11 Feb 2013 12:34:29 -0400 Subject: [PATCH] added --pdb command option to enable pdb debugger on failure. --- scrapy/command.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scrapy/command.py b/scrapy/command.py index 872e59a5a..9a80dae9f 100644 --- a/scrapy/command.py +++ b/scrapy/command.py @@ -4,6 +4,7 @@ Base class for Scrapy commands import os from optparse import OptionGroup +from twisted.python import failure from scrapy import log from scrapy.utils.conf import arglist_to_dict @@ -80,6 +81,7 @@ class ScrapyCommand(object): help="write process ID to FILE") group.add_option("-s", "--set", action="append", default=[], metavar="NAME=VALUE", \ help="set/override setting (may be repeated)") + group.add_option("--pdb", action="store_true", help="enable pdb on failure") parser.add_option_group(group) def process_options(self, args, opts): @@ -103,6 +105,9 @@ class ScrapyCommand(object): with open(opts.pidfile, "w") as f: f.write(str(os.getpid()) + os.linesep) + if opts.pdb: + failure.startDebugMode() + def run(self, args, opts): """ Entry point for running commands