Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 7b973fb3c8298f606d9b435aff551ab6 > files > 2811

python2-twisted-19.2.1-1.1.mga7.armv7hl.rpm

# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.


"""Test logging.

Message should only be printed second time around.
"""

from __future__ import print_function

from twisted.python import log
from twisted.internet import reactor

import sys, warnings

def test(i):
    print("printed", i)
    log.msg("message {}".format(i))
    warnings.warn("warning {}".format(i))
    try:
        raise RuntimeError("error {}".format(i))
    except:
        log.err()

def startlog():
    log.startLogging(sys.stdout)

def end():
    reactor.stop()

# pre-reactor run
test(1)

# after reactor run
reactor.callLater(0.1, test, 2)
reactor.callLater(0.2, startlog)

# after startLogging
reactor.callLater(0.3, test, 3)
reactor.callLater(0.4, end)

reactor.run()