mirror of https://github.com/scrapy/scrapy.git
backwards compatibility support for scrapy.conf.settings singleton for when scrapy.conf is imported *before* calling scrapy.cmdline.execute(), such as in custom bot runners
This commit is contained in:
parent
768a483953
commit
7afedb89e9
|
|
@ -84,13 +84,22 @@ def _run_print_help(parser, func, *a, **kw):
|
|||
def execute(argv=None, settings=None):
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
|
||||
# --- backwards compatibility for scrapy.conf.settings singleton ---
|
||||
if settings is None and 'scrapy.conf' in sys.modules:
|
||||
from scrapy import conf
|
||||
if hasattr(conf, 'settings'):
|
||||
settings = conf.settings
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
if settings is None:
|
||||
settings = get_project_settings()
|
||||
check_deprecated_settings(settings)
|
||||
|
||||
# backwards compatibility to support scrapy.conf.settings
|
||||
# --- backwards compatibility for scrapy.conf.settings singleton ---
|
||||
from scrapy import conf
|
||||
conf.settings = settings
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
crawler = CrawlerProcess(settings)
|
||||
crawler.install()
|
||||
|
|
|
|||
|
|
@ -3,3 +3,9 @@
|
|||
#
|
||||
# TODO: Add deprecation warning once all scrapy.conf instances have been
|
||||
# removed from Scrapy codebase.
|
||||
|
||||
import sys
|
||||
|
||||
if 'scrapy.cmdline' not in sys.modules:
|
||||
from scrapy.utils.project import get_project_settings
|
||||
settings = get_project_settings()
|
||||
|
|
|
|||
Loading…
Reference in New Issue