示例#1
0
def move():
    head = snake[-1].copy()
    head.move(aim)
    if not inside(head) or head in snake:
        square(head.x, head.y, 9, 'red')
        update()
        return
    snake.append()
    if head == food:
        print('snake', len(snake))
        food.x = randrange(-15, 15) * 10
        food.y = randrange(-15, 15) * 10
    else:
        snake.pop(0)
    clear()
    for body in snake:
        square(body.x, body.y, 9, 'green')
    square(food.x, food.y, 9, 'red')
    update()
    ontimer(move, 100)

    hideturtle()
    tracer(False)
    listen()
    onkey(lambda: change(10, 0), 'Right')
    onkey(lambda: change(-10, 0), 'Left')
    onkey(lambda: change(0, 10), 'Up')
    onkey(lambda: change(0, -10), 'Down')
    move()
    done()
示例#2
0
    def __init__(self, log_level='INFO'):

        # Configure the logging with the default config.
        setup_logger(log_level)

        self.log_server = None

        log_cfg_port = os.environ.get('CC_LOG_CONFIG_PORT')

        if log_cfg_port:
            self.log_server = config.listen(int(log_cfg_port))
            self.log_server.start()
def receive():
    import time
    import logging
    from logging import config

    listener = config.listen()
    listener.start()

    try:
        while True:
            logging.debug('debug')
            logging.info('info')
            some_logger = logging.getLogger('some')
            some_logger.warning('warning')
            some_logger.error('error')
            other_logger = some_logger.getChild('other')
            other_logger.critical('critical')

            time.sleep(5)

    except KeyboardInterrupt:
        # Stop listening and finish the listening thread
        logging.config.stopListening()
        listener.join()
示例#4
0
#!/usr/bin/env python

import logging as log
import logging.config as logcfg

port = 9999

if __name__ == '__main__':
    logcfg.fileConfig('src/log.conf')
    thr = logcfg.listen(port)
    thr.daemon = True  # Don't hangup
    thr.start()

    while True:
        line = raw_input('>>> ')
        level, message = line.split(' ', 1)
        fn = getattr(log, level, None)
        fn(message)
airtonsena.shapesize(3, 3)
airtonsena.penup()
airtonsena.shape('turtle')
airtonsena.color('blue')
airtonsena.goto(-500, -165)

pygame.init()
pygame.mixer.music.load('papaleguas.mp3')
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
    pass
pygame.quit()

play = False

listen()


def Play():
    while True:
        barrichello.fd(randint(1, 10))
        schumacher.fd(randint(1, 10))
        vetel.fd(randint(1, 10))
        raikonen.fd(randint(1, 10))
        felipemassa.fd(randint(1, 10))
        airtonsena.fd(randint(1, 10))
        if barrichello.xcor() > 475 or schumacher.xcor() > 475 or vetel.xcor(
        ) > 475 or raikonen.xcor() > 475 or felipemassa.xcor(
        ) > 475 or airtonsena.xcor() > 475:
            pygame.init()
            pygame.mixer.music.load('Ayrton Senna.mp3')
import logging
from logging import config as logging_config

import flask

app = flask.Flask(__name__)


@app.route('/')
def index():
    app.logger.info('Index page hit.')
    app.logger.debug('Helpful debug output!')
    return 'Hello, World!'


if __name__ == '__main__':
    log_server = logging_config.listen()
    log_server.start()
    # Set the level to INFO by default.
    app.logger.setLevel(logging.INFO)
    try:
        app.run()
    finally:
        logging_config.stopListening()
        log_server.join()
示例#7
0
def start_log():
    # ruleid: listen-eval
    t = listen(PORT_NUMBER)
    t.start()