def emit(self, record): try: yateproxy.debug("pymodule(%s)" % record.name, record.levelno, self.format(record)) except: self.handleError(record)
def __init__(self, interpreter, scripts, timeout = 1): """ Create a dispatcher. Execute script in another thread. It should run Twisted reactor. """ ## hdlr = YateLogHandler() ## root_logger = logging.getLogger() ## root_logger.setLevel(logging.INFO) ## root_logger.addHandler(hdlr) ## logger_messages.setLevel(logging.INFO) Dispatcher.__init__(self) self._timeout = timeout global embeddedStart embeddedStart = lambda start, args, kwargs: reactor.callLater(0, start, self, *args, **kwargs) for i, script in enumerate(scripts): try: name = "__embedded_yaypm_module__%d" % i yateproxy.debug("yaypm", logging.DEBUG, "Loading script: %s as %s" % (script, name)) imp.load_source(name, script) except Exception: yateproxy.debug("pymodule(%s)" % "yaypm", logging.ERROR, "Exception while loading: %s\n%s\n%s" % (script, sys.exc_info()[1], string.join(traceback.format_tb(sys.exc_info()[2])))) yateproxy.debug("pymodule(%s)" % "yaypm", logging.WARN, "Reactor thread not started!") self.thread = None return self.thread = Thread( name = "pymodule script thread", target = reactor.run, kwargs = {"installSignalHandlers": 0}) self.interpreter = interpreter self.thread.start() yateproxy.debug("pymodule(%s)" % "yaypm", logging.INFO, "Reactor thread started!")
def __init__(self, interpreter, scripts, timeout=1): """ Create a dispatcher. Execute script in another thread. It should run Twisted reactor. """ ## hdlr = YateLogHandler() ## root_logger = logging.getLogger() ## root_logger.setLevel(logging.INFO) ## root_logger.addHandler(hdlr) ## logger_messages.setLevel(logging.INFO) Dispatcher.__init__(self) self._timeout = timeout global embeddedStart embeddedStart = lambda start, args, kwargs: reactor.callLater( 0, start, self, *args, **kwargs) for i, script in enumerate(scripts): try: name = "__embedded_yaypm_module__%d" % i yateproxy.debug("yaypm", logging.DEBUG, "Loading script: %s as %s" % (script, name)) imp.load_source(name, script) except Exception: yateproxy.debug( "pymodule(%s)" % "yaypm", logging.ERROR, "Exception while loading: %s\n%s\n%s" % (script, sys.exc_info()[1], string.join(traceback.format_tb(sys.exc_info()[2])))) yateproxy.debug("pymodule(%s)" % "yaypm", logging.WARN, "Reactor thread not started!") self.thread = None return self.thread = Thread(name="pymodule script thread", target=reactor.run, kwargs={"installSignalHandlers": 0}) self.interpreter = interpreter self.thread.start() yateproxy.debug("pymodule(%s)" % "yaypm", logging.INFO, "Reactor thread started!")