How to use the twisted.python.log 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 mozilla / build-tools / mozilla / tools / buildbotcustom / buildbotcustom / status / l10n.py View on Github external
def addBuild(buildstatus):
  try:
    b = Build(buildstatus)
  except Exception, e:
    log.msg("Creating build database object raised " + str(e))
    return
  session.save(b)
  session.commit()
  # check if we need to add this to our active table
  aq = session.query(Active)
  if aq.filter_by(**b.dict()).count():
    # we already have this one
    return
  a = Active(b)
  session.save(a)
  session.commit()
github scrapinghub / splash / splash / server.py View on Github external
def force_shutdown():
                log.msg("Reactor didn't stop cleanly, doing unclean shutdown.")
                os._exit(0)
            reactor.callLater(2.0, force_shutdown)
github honza / nigel / nigel.py View on Github external
message = argv[2]

            bot = FakeBot()

            brain = Brain(bot, [BrbMatcher(), SifterMatcher(), GifterMatcher(),
                JenkinsMatcher(), VolunteerMatcher(), TimezoneMatcher(),
                PointsMatcher(), SillyMatcher()])

            brain.set_channel(None)

            brain.handle('', message, 'le-user')

        sys.exit(1)

    # initialize logging
    log.startLogging(sys.stdout)

    # create factory protocol and application
    room = os.environ.get('ROOM')
    if not room:
        room = sys.argv[1]
    f = LogBotFactory(room)

    # connect factory to this host and port
    reactor.connectTCP("irc.freenode.net", 6667, f)

    # run bot
    reactor.run()
github livenson / vcdm / src / vcdm / authz.py View on Github external
def strict(avatar, resource, action, acls):
    """Only allows operation if a user has the corresponding bit set"""
    log.msg("Strict authorization of %s to perform %s on %s. ACLs: %s" %
            (avatar, action, resource, acls))
    if resource == '/':
        return avatar != 'Anonymous'  # for / resource we expect a real user name
    if acls is None:
        return False  # disallowed by default
    for prefix in ['read', 'write', 'delete']:
        if action.startswith(prefix):
            user_acls = acls.get(avatar)
            if user_acls is None:
                return False  # disallowed by default
            return rights[prefix] in user_acls
    return False
github twisted / twisted / src / twisted / words / protocols / irc.py View on Github external
def quirkyMessage(self, s):
        """
        This is called when I receive a message which is peculiar, but not
        wholly indecipherable.

        @param s: The peculiar message.
        @type s: L{bytes}
        """
        log.msg(s + '\n')
github praekeltfoundation / vumi / vumi / transports / twitter / twitter.py View on Github external
def handle_inbound_dm(self, dm):
        if self.is_own_dm(dm):
            log.msg("Received own DM on user stream: %r" % (dm,))
        elif 'dms' not in self.endpoints:
            log.msg(
                "Discarding DM received on user stream, no endpoint "
                "configured for DMs: %r" % (dm,))
        else:
            log.msg("Received DM on user stream: %r" % (dm,))
            self.publish_dm(dm)
github kyrios / knive / python-src / knive / gstreamer.py View on Github external
def __init__(self, name='unknown gst-source', pipeline="audiotestsrc ! audioconvert ! lame ! ffmux_mpegts ! appsink name=\"sink\""):
        super(GstInlet, self).__init__(name=name)
        self.pipeline = pipeline
        log.msg("initializing", system=self.name)
github twisted / twisted / src / twisted / internet / _producer_helpers.py View on Github external
unregistered, which should result in streaming stopping.
        """
        while True:
            try:
                self._producer.resumeProducing()
            except:
                log.err(None, "%s failed, producing will be stopped:" %
                        (safe_str(self._producer),))
                try:
                    self._consumer.unregisterProducer()
                    # The consumer should now call stopStreaming() on us,
                    # thus stopping the streaming.
                except:
                    # Since the consumer blew up, we may not have had
                    # stopStreaming() called, so we just stop on our own:
                    log.err(None, "%s failed to unregister producer:" %
                            (safe_str(self._consumer),))
                    self._finished = True
                    return
            yield None
github smira / fmspy / fmspy / rtmp / protocol / base.py View on Github external
def _pinger(self):
        """
        Regular 'ping' service.

        We send 'pings' to other end of RTMP protocol, expecting to receive
        'pong'. If we receive some data, we assume 'ping' is sent. If other end
        of protocol doesn't send anything in reply to our 'ping' for some timeout,
        we disconnect connection.
        """
        noDataInterval = _time.seconds() - self.lastReceived

        if noDataInterval > config.getint('RTMP', 'keepAliveTimeout'):
            log.msg('Closing connection due too much inactivity (%d)' % noDataInterval)
            self.transport.loseConnection()
            return

        if noDataInterval > config.getint('RTMP', 'pingInterval'):
            self.pushPacket(Ping(Ping.PING_CLIENT, [int(_time.seconds()*1000) & 0x7fffffff]))

        self.pushPacket(BytesRead(self.bytesReceived))
github andrewbird / wader / core / middleware.py View on Github external
def _do_disable_device(self):
        self.clean_signals()

        if self.device.status == MM_MODEM_STATE_CONNECTED:

            def on_disconnect_from_internet(_):
                if self.device.status >= MM_MODEM_STATE_REGISTERED:
                    self.device.set_status(MM_MODEM_STATE_REGISTERED)
                self.device.close()

            d = self.disconnect_from_internet()
            d.addCallback(on_disconnect_from_internet)
            d.addErrback(log.err)
            return d

        if self.device.status >= MM_MODEM_STATE_ENABLED:
            self.device.close()

        return defer.succeed(None)