Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Added support for setting exit code in Scrapy commands. Closes #248

Pablo Hoffmana5ee05e8140e
diff --git a/scrapy/cmdline.py b/scrapy/cmdline.py
index 134d88bb0..6884aad88 100644
--- a/scrapy/cmdline.py
+++ b/scrapy/cmdline.py
@@ -128,6 +128,7 @@ def execute(argv=None):
opts, args = parser.parse_args(args=argv[1:])
_run_print_help(parser, cmd.process_options, args, opts)
_run_print_help(parser, _run_command, cmd, args, opts)
+ sys.exit(cmd.exitcode)
def _run_command(cmd, args, opts):
if opts.profile or opts.lsprof:
diff --git a/scrapy/command.py b/scrapy/command.py
index a9c447e38..dc2de9ac8 100644
--- a/scrapy/command.py
+++ b/scrapy/command.py
@@ -21,6 +21,8 @@ class ScrapyCommand(object):
# default settings to be used for this command instead of global defaults
default_settings = {}
+ exitcode = 0
+
def set_crawler(self, crawler):
self._crawler = crawler