mirror of https://github.com/scrapy/scrapy.git
scrapyd: do not set SCRAPY_FEED_URI/SCRAPY_LOG_FILE if items_dir/logs_dir settings are not set
This commit is contained in:
parent
43732e5042
commit
58e88ed246
|
|
@ -192,7 +192,10 @@ spider queues).
|
|||
logs_dir
|
||||
--------
|
||||
|
||||
The directory where the Scrapy processes logs will be stored.
|
||||
The directory where the Scrapy logs will be stored. If you want to disable
|
||||
storing logs set this option empty, like this::
|
||||
|
||||
logs_dir =
|
||||
|
||||
items_dir
|
||||
---------
|
||||
|
|
|
|||
|
|
@ -28,8 +28,10 @@ class Environment(object):
|
|||
env['SCRAPY_JOB'] = message['_job']
|
||||
if project in self.settings:
|
||||
env['SCRAPY_SETTINGS_MODULE'] = self.settings[project]
|
||||
env['SCRAPY_LOG_FILE'] = self._get_file(message, self.logs_dir, 'log')
|
||||
env['SCRAPY_FEED_URI'] = self._get_file(message, self.items_dir, 'jl')
|
||||
if self.logs_dir:
|
||||
env['SCRAPY_LOG_FILE'] = self._get_file(message, self.logs_dir, 'log')
|
||||
if self.items_dir:
|
||||
env['SCRAPY_FEED_URI'] = self._get_file(message, self.items_dir, 'jl')
|
||||
return env
|
||||
|
||||
def _get_file(self, message, dir, ext):
|
||||
|
|
|
|||
|
|
@ -32,3 +32,14 @@ class EnvironmentTest(unittest.TestCase):
|
|||
self.assert_(env['SCRAPY_LOG_FILE'].endswith(os.path.join('mybot', 'myspider', 'ID.log')))
|
||||
self.assert_(env['SCRAPY_FEED_URI'].endswith(os.path.join('mybot', 'myspider', 'ID.jl')))
|
||||
self.failIf('SCRAPY_SETTINGS_MODULE' in env)
|
||||
|
||||
def test_get_environment_with_no_items_dir(self):
|
||||
config = Config(values={'items_dir': '', 'logs_dir': ''})
|
||||
config.cp.add_section('settings')
|
||||
config.cp.set('settings', 'newbot', 'newbot.settings')
|
||||
msg = {'_project': 'mybot', '_spider': 'myspider', '_job': 'ID'}
|
||||
slot = 3
|
||||
environ = Environment(config, initenv={})
|
||||
env = environ.get_environment(msg, slot)
|
||||
self.failUnless('SCRAPY_FEED_URI' not in env)
|
||||
self.failUnless('SCRAPY_LOG_FILE' not in env)
|
||||
|
|
|
|||
Loading…
Reference in New Issue