mirror of https://github.com/scrapy/scrapy.git
More visible telnet conch message
Capture traceback when trying to import required twisted modules, print it in case telnet is enabled, and mention settings variable that can be used to supress the message. Thanks @kmike!
This commit is contained in:
parent
92b504eae5
commit
9428a4a3aa
|
|
@ -6,6 +6,7 @@ See documentation in docs/topics/telnetconsole.rst
|
|||
|
||||
import pprint
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
from twisted.internet import protocol
|
||||
try:
|
||||
|
|
@ -13,6 +14,7 @@ try:
|
|||
from twisted.conch.insults import insults
|
||||
TWISTED_CONCH_AVAILABLE = True
|
||||
except (ImportError, SyntaxError):
|
||||
_TWISTED_CONCH_TRACEBACK = traceback.format_exc()
|
||||
TWISTED_CONCH_AVAILABLE = False
|
||||
|
||||
from scrapy.exceptions import NotConfigured
|
||||
|
|
@ -40,8 +42,9 @@ class TelnetConsole(protocol.ServerFactory):
|
|||
if not crawler.settings.getbool('TELNETCONSOLE_ENABLED'):
|
||||
raise NotConfigured
|
||||
if not TWISTED_CONCH_AVAILABLE:
|
||||
raise NotConfigured('TelnetConsole not enabled: failed to import '
|
||||
'required twisted modules.')
|
||||
raise NotConfigured(
|
||||
'TELNETCONSOLE_ENABLED setting is True but required twisted '
|
||||
'modules failed to import:\n' + _TWISTED_CONCH_TRACEBACK)
|
||||
self.crawler = crawler
|
||||
self.noisy = False
|
||||
self.portrange = [int(x) for x in crawler.settings.getlist('TELNETCONSOLE_PORT')]
|
||||
|
|
|
|||
Loading…
Reference in New Issue