added documentation about --set and small improvement

--HG--
extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%401010
This commit is contained in:
Pablo Hoffman 2009-03-22 19:25:08 +00:00
parent cbe8f8ff45
commit 30a3df0c9d
2 changed files with 12 additions and 5 deletions

View File

@ -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::

View File

@ -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):