def run_engine(args): if "sigpipe" in args: signal.signal(signal.SIGPIPE, signal.SIG_DFL) def handle_wait(args): time.sleep(1) return "done waiting" engine = gtp_engine.Gtp_engine_protocol() engine.add_protocol_commands() engine.add_command('wait', handle_wait) if "silent" in args: try: gtp_engine.run_interactive_gtp_session(engine) except gtp_engine.ControllerDisconnected: print >>sys.stderr, "[controller disconnected]" sys.exit(3) else: gtp_engine.run_interactive_gtp_session(engine)
def run(self): """Run a GTP session on stdin and stdout, using the proxy engine. This is provided for convenience; it's also ok to use the proxy engine directly. Returns either when EOF is seen on stdin, or when a handler (such as the default 'quit' handler) raises GtpQuit. Closes the channel to the back end before it returns. When it is meaningful (eg, for subprocess channels) this waits for the back end to exit. Propagates ControllerDisconnected if a pipe connected to stdout goes away. """ gtp_engine.run_interactive_gtp_session(self.engine) self.close()
def run_engine(args): if "sigpipe" in args: signal.signal(signal.SIGPIPE, signal.SIG_DFL) def handle_wait(args): time.sleep(1) return "done waiting" engine = gtp_engine.Gtp_engine_protocol() engine.add_protocol_commands() engine.add_command('wait', handle_wait) if "silent" in args: try: gtp_engine.run_interactive_gtp_session(engine) except gtp_engine.ControllerDisconnected: print >> sys.stderr, "[controller disconnected]" sys.exit(3) else: gtp_engine.run_interactive_gtp_session(engine)