Added check for successful PyOpenSSL import in Twisted driver and increased log level

This commit is contained in:
Ali Afshar 2005-03-04 15:47:22 +00:00
parent 32e0b29fcd
commit eb970c09d7

View File

@ -44,7 +44,8 @@ from twisted.internet.protocol import ReconnectingClientFactory
try: try:
from OpenSSL import SSL from OpenSSL import SSL
except ImportError: except ImportError:
drivers.log.debug('PyOpenSSL is not available, can not connect to SSL servers.') drivers.log.warning('PyOpenSSL is not available, can not connect to SSL servers.')
SSL = None
class TwistedRunnerDriver(drivers.IrcDriver): class TwistedRunnerDriver(drivers.IrcDriver):
def name(self): def name(self):
@ -125,9 +126,12 @@ class SupyReconnectingFactory(ReconnectingClientFactory, drivers.ServersMixin):
def connectSSL(self, server, port, vhost): def connectSSL(self, server, port, vhost):
"""Connect to the server using an SSL socket.""" """Connect to the server using an SSL socket."""
drivers.log.debug('Attempting an SSL connection.') drivers.log.info('Attempting an SSL connection.')
if SSL:
reactor.connectSSL(server, port, self, reactor.connectSSL(server, port, self,
ssl.ClientContextFactory(), bindAddress=(vhost, 0)) ssl.ClientContextFactory(), bindAddress=(vhost, 0))
else:
drivers.log.error('PyOpenSSL is not available. Not connecting.')
def clientConnectionFailed(self, connector, r): def clientConnectionFailed(self, connector, r):
drivers.log.connectError(self.currentServer, errorMsg(r)) drivers.log.connectError(self.currentServer, errorMsg(r))