Catch SyntaxError as well when importing manhole

Also give a more detailed reason why telnet is not enabled (for the
future).
This commit is contained in:
Konstantin Lopuhin 2018-07-09 12:26:09 +03:00
parent 722e1afcdb
commit 17e9914b8a
2 changed files with 4 additions and 3 deletions

View File

@ -1,4 +1,4 @@
git+https://github.com/lopuhin/twisted.git@9384-remove-async-param
Twisted>=17.9.0
lxml>=3.2.4
pyOpenSSL>=0.13.1
cssselect>=0.9

View File

@ -12,7 +12,7 @@ try:
from twisted.conch import manhole, telnet
from twisted.conch.insults import insults
TWISTED_CONCH_AVAILABLE = True
except ImportError:
except (ImportError, SyntaxError):
TWISTED_CONCH_AVAILABLE = False
from scrapy.exceptions import NotConfigured
@ -40,7 +40,8 @@ class TelnetConsole(protocol.ServerFactory):
if not crawler.settings.getbool('TELNETCONSOLE_ENABLED'):
raise NotConfigured
if not TWISTED_CONCH_AVAILABLE:
raise NotConfigured
raise NotConfigured('TelnetConsole not enabled: failed to import '
'required twisted modules.')
self.crawler = crawler
self.noisy = False
self.portrange = [int(x) for x in crawler.settings.getlist('TELNETCONSOLE_PORT')]