def sendLine(self, line): # Si la linea ya viene con \r\n, se la quieto por que # sendLine se lo agrega. if line.endswith('\r\n'): line = line[:-2] log.msg("=> %s" % line, system=self.get_ccc()) LineOnlyReceiver.sendLine(self, line)
def sendLine(self, line): """ Log sent lines. """ log.msg("%s < %r" % (self.sid, line)) LineOnlyReceiver.sendLine(self, line)
def connectionLost(self, reason): """Clean up and let the superclass handle it.""" Telnet.connectionLost(self, reason) LineOnlyReceiver.connectionLost(self, reason) #flush out the buffer if self._buffer: self.lineReceived(self._buffer) self.factory.realm.connectionLost()
def connectionMade(self): """Call our superclasses. Late initialisation should also go here. """ self.factory.realm.connectionMade() Telnet.connectionMade(self) LineOnlyReceiver.connectionMade(self)
def connectionMade(self): """ Notify our factory that we're ready to accept connections. """ LineOnlyReceiver.connectionMade(self) self.factory.connectionPool.clientFree(self) if self.factory.deferred is not None: self.factory.deferred.callback(self) self.factory.deferred = None
def bytesDelimitedBy(delimiter): """ Consumes a stream of bytes and produces frames delimited by the given delimiter. @param delimiter: an octet sequence that separates frames in the incoming stream of bytes. @type delimiter: L{bytes} @return: a tube that converts a stream of bytes into a sequence of frames. @rtype: L{ITube} """ receiver = LineOnlyReceiver() receiver.delimiter = delimiter return _SegmentsToFrames(receiver, "lineReceived")
def sendLine(self, line): """ Override sendLine method """ if not self._current: self.setTimeout(self.persistentTimeOut) if not isinstance(line, str): return fail( ClientError("Invalid type for value: %s, expecting a string" % (type(line), ))) LineOnlyReceiver.sendLine(self, line) cmdObj = Command(line) self._current.append(cmdObj) return cmdObj._deferred
def dataReceived(self, data: bytes): self._buffer += data # something weird to do with the brainboxes? if self._buffer[:9] == b'\xff\xfd\x03\xff\xfd\x00\xff\xfd,': self._buffer = self._buffer[9:] return LineOnlyReceiver.dataReceived(self, b"")
def dataReceived (self, data): self._buffer += data # something weird to do with the brainboxes? if self._buffer[:9] == '\xff\xfd\x03\xff\xfd\x00\xff\xfd,': self._buffer = self._buffer[9:] return LineOnlyReceiver.dataReceived(self, "")
def connectionLost(self,reason): print(self) if reason.check(twisted.internet.error.ConnectionDone): print('%s: connection closed.' % self.name) else: print('%s: connection lost: %s' % (self.name,reason)) self.connectedSince = None return Receiver.connectionLost(self,reason)
def linesToBytes(): """ Convert lines into bytes. @return: Create a new tube for adding CRLF delimiters to a sequence of lines (frames) to produce bytes (segments). """ return _FramesToSegments(LineOnlyReceiver(), "sendLine")
def connectionLost(self, reason): print(self) if reason.check(twisted.internet.error.ConnectionDone): print('%s: connection closed.' % self.name) else: print('%s: connection lost: %s' % (self.name, reason)) self.connectedSince = None return Receiver.connectionLost(self, reason)
def dataReceived(self, data): """ Overridden to stop trying to read data while outputting a response. This stops netcat from quitting before it gets the output! """ reactor.removeReader(self.reader) retval = LineOnlyReceiver.dataReceived(self, data) reactor.getThreadPool().callInThreadWithCallback( self.processLinesDone, self.processLines) return retval
def connectionLost(self, reason): """When TCP connection is lost, remove shutdown handler """ if reason.type == ConnectionLost: msg = 'Disconnected' else: msg = 'Disconnected: %s' % reason.getErrorMessage() self.log.debug(msg) #Remove connect timeout if set if self.connectTimeoutDelayedCall is not None: self.log.debug("Cancelling connect timeout after TCP connection was lost") self.connectTimeoutDelayedCall.cancel() self.connectTimeoutDelayedCall = None #Callback for failed connect if self.connectedDeferred: if self.connectError: self.log.debug("Calling connectedDeferred errback: %s" % self.connectError) self.connectedDeferred.errback(self.connectError) self.connectError = None else: self.log.error("Connection lost with outstanding connectedDeferred") error = StompError("Unexpected connection loss") self.log.debug("Calling connectedDeferred errback: %s" % error) self.connectedDeferred.errback(error) self.connectedDeferred = None #Callback for disconnect if self.disconnectedDeferred: if self.disconnectError: #self.log.debug("Calling disconnectedDeferred errback: %s" % self.disconnectError) self.disconnectedDeferred.errback(self.disconnectError) self.disconnectError = None else: #self.log.debug("Calling disconnectedDeferred callback") self.disconnectedDeferred.callback(self) self.disconnectedDeferred = None LineOnlyReceiver.connectionLost(self, reason)
def connectionMade(self): """When TCP connection is made, register shutdown handler """ LineOnlyReceiver.connectionMade(self)
def connectionMade(self): LineOnlyReceiver.connectionMade(self) self.started = False self.lines = [] self.pendingActions = {}
def lineLengthExceeded(self, message): print('%s: max line length exceeded: %d > %d' % (self.name, len(message), self.MAX_LENGTH)) return Receiver.lineLengthExceeded(self, message)
def sendLine(self, line): line = line.replace("\r", "").replace("\n", "") if self.showirc: LOG.log(5, "<: %s" % line) LineOnlyReceiver.sendLine(self, line)
def dataReceived(self, data): LineOnlyReceiver.dataReceived(self, data) self.timeout_handler.refresh()
def sendLine(self, line): self.log.trace("-> %s" % repr(line)) LineOnlyReceiver.sendLine(self, line)
def lineLengthExceeded(self, line): LineOnlyReceiver.lineLengthExceeded(self, line)
def connectionMade(self): self.connectedSince = datetime.now() print('%s: connected to %s' % (self.name, self.transport.getPeer())) return Receiver.connectionMade(self)
def sendLine(self, line): line = line.replace('\r', '').replace('\n', '') if self.showirc: LOG.log(5, "<: %s" % line) LineOnlyReceiver.sendLine(self, line)
def sendLine(self, line): #print "<:", line LineOnlyReceiver.sendLine(self, line.replace('|','|'))
def sendLine(self, line): print 'S: ' + line print "Enviar?" raw_input() LineOnlyReceiver.sendLine(self, line)
def connectionMade(self): "Start the timeout once the connection has been established." self.setTimeout(self.timeoutPeriod) LineOnlyReceiver.connectionMade(self)
def sendLine(self, line): if not isinstance(line, str): line = str(line) LineOnlyReceiver.sendLine(self, line)
def dataReceived(self, data): "Reset the timeout and parse the received data." self.resetTimeout() LineOnlyReceiver.dataReceived(self, data)
def sendLine(self, line): LineOnlyReceiver.sendLine(self, str(line))
def sendLine(self, line): #print "<:", line LineOnlyReceiver.sendLine(self, line.replace('|', '|'))
def sendLine(self, line): print 'S: ' + line if not self.saludo: LineOnlyReceiver.sendLine(self, line) # Saludo y nada m?s para no hacer tanto ruido
def sendLine(self, line): # overrides twisted function peer = self.transport.getPeer() logging.debug("Sending line '{}' to {}:{}:{}".format(line, peer.type, peer.host, peer.port)) return LineOnlyReceiver.sendLine(self, line)
def lineLengthExceeded(self, line): # overrides twisted function peer = self.transport.getPeer() logging.warning("Incomming line of length {} exceeded MAX_LENGTH of {}, dropping unvalidated connection to {}:{}:{}".format(len(line), self.MAX_LENGTH, peer.type, peer.host, peer.port)) return LineOnlyReceiver.lineLengthExceeded(self, line)
def dataReceived(self, data): LineOnlyReceiver.dataReceived(self, data)
def connectionMade(self): logger.debug('<TelegrafProtocol.connectionMade> %s', self) self.closed_d = Deferred() self.connected = 1 LineOnlyReceiver.connectionMade(self)
def connectionMade(self): self.connectedSince = datetime.now() print('%s: connected to %s' % (self.name,self.transport.getPeer())) return Receiver.connectionMade(self)
def connectionLost(self, reason): self.connected = 0 self.closed_d.callback(0) logger.debug('<TelegrafProtocol.connectionLost> %s %s', reason, self) LineOnlyReceiver.connectionLost(self)
def lineLengthExceeded(self,message): print('%s: max line length exceeded: %d > %d' % ( self.name,len(message),self.MAX_LENGTH )) return Receiver.lineLengthExceeded(self,message)