提交 30a3df0c 编写于 作者: P Pablo Hoffman

added documentation about --set and small improvement

--HG--
extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%401010
上级 cbe8f8ff
......@@ -41,11 +41,18 @@ Example::
>>> from scrapy.conf import settings
>>> settings.overrides['LOG_ENABLED'] = True
2. Environment variables
------------------------
You can also override one (or more) settings from command line using the
``--set`` command line argument.
.. highlight:: sh
Example::
scrapy-ctl.py crawl domain.com --set=LOG_FILE:/tmp/scrapy.log
2. Environment variables
------------------------
You can populate settings using environment variables prefixed with
``SCRAPY_``. For example, to change the log file location::
......
......@@ -46,7 +46,7 @@ class ScrapyCommand(object):
parser.add_option("--profile", dest="profile", default=None, help="write profiling stats in FILE, to analyze later with: python -m pstats FILE", metavar="FILE")
parser.add_option("--pidfile", dest="pidfile", help="Write process pid to file FILE", metavar="FILE")
parser.add_option("--set", dest="settings", action="append", metavar="SETTING:VALUE", default=[],
help="Override Scrapy setting SETTING with VALUE")
help="Override Scrapy setting SETTING with VALUE. May be repeated.")
def process_options(self, args, opts):
if opts.logfile:
......@@ -74,10 +74,10 @@ class ScrapyCommand(object):
for setting in opts.settings:
if ':' in setting:
name, val = setting.split(':')
name, val = setting.split(':', 1)
settings.overrides[name] = val
else:
sys.stderr.write("%s: invalid argument --set=%s - proper format is -set=SETTING:VALUE'\n" % (sys.argv[0], setting))
sys.stderr.write("%s: invalid argument --set=%s - proper format is --set=SETTING:VALUE'\n" % (sys.argv[0], setting))
sys.exit(2)
def run(self, args, opts):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册