def traps(self, argv): """traps Enable receiving and display of traps.""" from pycopia import asyncio from pycopia.SNMP import traps traps.get_dispatcher(self._trap_handler) asyncio.start_sigio()
def start_proc_manager(config, logfile): from pycopia import proctools from pycopia import scheduler from pycopia import asyncio asyncio.start_sigio() pm = proctools.get_procmanager() for name, serverlist in config.VHOSTS.items(): for servername in serverlist: print "Starting %s for %s." % (servername, name) p = pm.spawnpipe("%s/fcgi_server -n %s" % (config.LIBEXEC, servername), persistent=True, logfile=logfile) asyncio.poller.register(p) scheduler.sleep(1.0) # give it time to init... if config.USEFRONTEND: lighttpd = proctools.which("lighttpd") pm.spawnpipe("%s -D -f %s" % (lighttpd, LTCONFIG), persistent=True, logfile=logfile) try: while 1: asyncio.poller.loop() for proc in pm.getprocs(): if proc.readable(): print proc.read(4096) except KeyboardInterrupt: asyncio.poller.unregister_all() for proc in pm.getprocs(): proc.kill() proc.wait() if os.path.exists(config.PIDFILE): os.unlink(config.PIDFILE)
def main(argv): for mibname in argv[1:]: load(mibname) traps.get_dispatcher(_handler) asyncio.start_sigio()