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