How to use the twisted.python.log.msg function in Twisted

To help you get started, we’ve selected a few Twisted examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tomerfiliba / rpyc / rpyc / utils / twisted_integration.py View on Github external
def connectionLost(self, reason=None):
        if self.conn:
            if self.factory.logging:
                log.msg("%s: closing connection %s" % (self, self.conn))
            c = self.conn
            self.conn = None
            c.close(_catchall = True)
    def dataReceived(self, data):
github crossbario / crossbar / v1 / crossbar / freebsd / netstat.py View on Github external
def stopService(self):
      log.msg("Stopping %s service .." % self.SERVICENAME)
      self.netstat.transport.signalProcess('KILL')
      self.isRunning = False
github scanlime / navi-misc / cia / LibCIA / IRC / Bots.py View on Github external
def cancel(self):
        """Indicate that this request is no longer needed. It is removed from the bot network."""
        self.botNet.removeRequest(self)
        self._active = False
        log.msg("Cancelled %r" % self)
github buildbot / buildbot / master / buildbot / db / logs.py View on Github external
def _splitBigChunk(self, content, logid):
        """
        Split CONTENT on a line boundary into a prefix smaller than 64k and
        a suffix containing the remainder, omitting the splitting newline.
        """
        # if it's small enough, just return it
        if len(content) < self.MAX_CHUNK_SIZE:
            return content, None

        # find the last newline before the limit
        i = content.rfind(b'\n', 0, self.MAX_CHUNK_SIZE)
        if i != -1:
            return content[:i], content[i + 1:]

        log.msg('truncating long line for log %d' % logid)

        # first, truncate this down to something that decodes correctly
        truncline = content[:self.MAX_CHUNK_SIZE]
        while truncline:
            try:
                truncline.decode('utf-8')
                break
            except UnicodeDecodeError:
                truncline = truncline[:-1]

        # then find the beginning of the next line
        i = content.find(b'\n', self.MAX_CHUNK_SIZE)
        if i == -1:
            return truncline, None
        return truncline, content[i + 1:]
github hpfeeds / hpfeeds / appsupport / kippo / hpfeeds.py View on Github external
try: d = self.s.recv(BUFSIZ)
        except socket.timeout:
            return

        if not d:
            if self.debug: log.msg('hpclient connection closed?')
            self.close()
            return

        self.unpacker.feed(d)
        try:
            for opcode, data in self.unpacker:
                if self.debug: log.msg('hpclient msg opcode {0} data {1}'.format(opcode, data))
                if opcode == OP_INFO:
                    name, rand = strunpack8(data)
                    if self.debug: log.msg('hpclient server name {0} rand {1}'.format(name, rand))
                    self.send(msgauth(rand, self.ident, self.secret))
                    self.state = 'GOTINFO'

                elif opcode == OP_PUBLISH:
                    ident, data = strunpack8(data)
                    chan, data = strunpack8(data)
                    if self.debug: log.msg('publish to {0} by {1}: {2}'.format(chan, ident, data))

                elif opcode == OP_ERROR:
                    log.err('errormessage from server: {0}'.format(data))
                else:
                    log.err('unknown opcode message: {0}'.format(opcode))
        except BadClient:
            log.err('unpacker error, disconnecting.')
            self.close()
github bravoserver / bravo / bravo / beta / protocol.py View on Github external
def enable_chunk(self, x, z):
        """
        Request a chunk.

        This function will asynchronously obtain the chunk, and send it on the
        wire.

        :returns: `Deferred` that will be fired when the chunk is obtained,
                  with no arguments
        """

        log.msg("Enabling chunk %d, %d" % (x, z))

        if (x, z) in self.chunks:
            log.msg("...But the chunk was already loaded!")
            return succeed(None)

        d = self.factory.world.request_chunk(x, z)

        @d.addCallback
        def cb(chunk):
            self.chunks[x, z] = chunk
            return chunk
        d.addCallback(self.send_chunk)

        return d
github twisted / twisted / twisted / words / ircservice.py View on Github external
def irc_TOPIC(self, prefix, params):
        """Topic message

        Parameters:  [  ]

        [REQUIRED]
        """
        #<< TOPIC #python
        #>> :benford.openprojects.net 332 glyph #python : I really did. I sprained all my toes.
        #>> :benford.openprojects.net 333 glyph #python itamar|nyc 994713482
        ### and
        #<< TOPIC #divunal :foo
        #>> :glyph!glyph@adsl-64-123-27-108.dsl.austtx.swbell.net TOPIC #divunal :foo
        log.msg('topic %s %s' % (prefix, params))
        if len(params) == 1:
            if params[0][0] != '#':
                self.receiveDirectMessage("*error*", "invalid channel name")
                return
            channame = params[0][1:]
            group = self.service.getGroup(channame)
            self.sendMessage(irc.RPL_TOPIC,
                             "#" + group.name, ":" + group.metadata['topic'])
            self.sendMessage('333', # not in the RFC
                             "#" + group.name, group.metadata['topic_author'], "1")
        else:
            #<< TOPIC #qdf :test
            #>> :glyph!glyph@adsl-64-123-27-108.dsl.austtx.swbell.net TOPIC #qdf :test
            groupName = params[0][1:]
            # XXX: Eek, invasion of privacy!
            group = self.service.getGroup(groupName)
github bravoserver / bravo / bravo / beta / factory.py View on Github external
        @d.addCallback
        def cb(chunk):
            chunk.entities.add(entity)
            log.msg("Created entity %s" % entity)
            # XXX Maybe just send the entity object to the manager instead of
            # the following?
            if hasattr(entity,'loop'):
                self.world.mob_manager.start_mob(entity)
github buildbot / buildbot / buildbot / slave / commands.py View on Github external
def start(self):
        if self.debug:
            log.msg('SlaveDirectoryUploadCommand started')

        self.path = os.path.join(self.builder.basedir,
                                 self.workdir,
                                 os.path.expanduser(self.dirname))
        if self.debug:
            log.msg("path: %r" % self.path)

        # Create temporary archive
        fd, self.tarname = tempfile.mkstemp()
        fileobj = os.fdopen(fd, 'w')
        if self.compress == 'bz2':
            mode='w|bz2'
        elif self.compress == 'gz':
            mode='w|gz'
        else:
            mode = 'w'