Пример #1
0
def slog(argv):
    if len(argv) > 1:
        port = int(argv[1])
    else:
        port = 514
    get_dispatcher(("", port))
    try:
        while 1:
            asyncio.pause()
    except KeyboardInterrupt:
        return
Пример #2
0
def slog(argv):
    if len(argv) > 1:
        port = int(argv[1])
    else:
        port = 514
    get_dispatcher(("", port))
    try:
        while 1:
            asyncio.pause()
    except KeyboardInterrupt:
        return
Пример #3
0
    # package.
    import os

    if port != 162:
        cmd = "daemonize -f /tmp/straps_%s.log straps %d" % (os.getpid(), port)
    else:
        cmd = "daemonize -f /tmp/straps_%s.log straps" % (os.getpid(),)
    rv = os.system(cmd)
    return rv


def get_dispatcher(*handlers):
    """Return a TrapDispatcher instance ready to respond to traps.
    """
    from pycopia import scheduler
    from pycopia import asyncio

    start_straps()
    scheduler.sleep(2)
    dispatcher = TrapDispatcher(list(handlers))
    asyncio.register(dispatcher)
    return dispatcher


if __name__ == "__main__":
    from pycopia import asyncio

    get_dispatcher([_default_trap_handler])
    while True:
        asyncio.pause()
Пример #4
0
def start_straps(port=162):
    # the daemonize and straps program source code is in the pycopia-utils
    # package.
    import os
    if port != 162:
        cmd = "daemonize -f /tmp/straps.log straps %d" % port
    else:
        cmd = "daemonize -f /tmp/straps.log straps"
    rv =  os.system(cmd)
    return rv

def get_dispatcher(*handlers):
    """Return a TrapDispatcher instance ready to respond to traps.
    """
    from pycopia import scheduler
    from pycopia import asyncio
    start_straps()
    scheduler.sleep(2)
    dispatcher = TrapDispatcher(list(handlers))
    asyncio.register(dispatcher)
    return dispatcher


if __name__ == "__main__":
    from pycopia import asyncio
    get_dispatcher([_default_trap_handler])
    while True:
        asyncio.pause()