def connectionLost(self, reason): "" doLog(self.logger, "Transport", "debug", "connectionLost") # no connection -> no use draining the queue self.egressQueueTask.stop() self._drainEgressQueue()
def clientConnectionFailed(self, connector, reason): doLog(self.logger, "TransportFactory", "debug", "clientConnectionFailed, reason [%s]" % reason)
def clientConnectionLost(self, connector, reason): doLog(self.logger, "TransportFactory", "debug", "clientConnectionLost, reason [%s]" % reason) connector.connect()
def buildProtocol(self, addr): """ Builds a Transport protocol instance """ doLog(self.logger, "TransportFactory", "debug", "buildProtocol") return Transport(self.iq, self.eq, self.logger)
def startedConnecting(self, connector): doLog(self.logger, "TransportFactory", "debug", "startedConnecting")
def dataReceived(self, data): """ Simply queue the received data """ self.iq.put(data) doLog(self.logger, "Transport", "debug", "dataReceived, len[%s]" % len(data))
def connectionMade(self): "" doLog(self.logger, "Transport", "debug", "connectionMade")
except Queue.Empty, e: return except Exception, e: doLog(self.logger, "Transport", "error", "_procressEgressQueue: error dequeuing [%s]" % e) return print "class: %s" % self.__class__ print "_processEgressQueue: type: %s" % type(self.transport) try: self.transport.write(data_to_send) except Exception, e: doLog( self.logger, "Transport", "error", "_procressEgressQueue: transport write error[%s] type[%s] data_to_send[%s]" % (e, type(data_to_send), data_to_send), ) return try: self.eq.task_done() doLog(self.logger, "Transport", "debug", "sent data, len[%s]" % len(data_to_send)) except Exception, e: doLog( self.logger, "Transport", "error", "_procressEgressQueue: task_done error[%s] type[%s] data_to_send[%s]" % (type(e), type(data_to_send), data_to_send),
def logInfo(info): if 'logger' in sys.modules.keys(): from logger import doLog doLog(str(info)) else: print(str(info))