def run_proxy(parser, opts, extra_args): from xpra.proxy import XpraProxy assert "gtk" not in sys.modules server_conn = connect_or_fail(pick_display(parser, opts, extra_args)) app = XpraProxy(TwoFileConnection(sys.stdout, sys.stdin), server_conn) app.run() return 0
def connect_or_fail(display_desc): if display_desc["type"] == "ssh": cmd = (display_desc["full_remote_xpra"] + ["_proxy"] + display_desc["display_as_args"]) try: child = Popen(cmd, stdin=PIPE, stdout=PIPE) except OSError, e: sys.exit("Error running ssh program '%s': %s" % (cmd[0], e)) return TwoFileConnection(child.stdin, child.stdout)
def connect_or_fail(display_desc): if display_desc["type"] == "ssh": cmd = (display_desc["full_remote_xpra"] + ["_proxy"] + display_desc["display_as_args"]) try: child = Popen(cmd, stdin=PIPE, stdout=PIPE) except OSError, e: sys.exit("Error running ssh program '%s': %s" % (cmd[0], e)) def abort_test(action): """ if ssh dies, we don't need to try to read/write from its sockets """ e = child.poll() if e is not None: error_message = "cannot %s using %s: the SSH process has terminated with exit code=%s" % ( action, display_desc["full_ssh"], e) print(error_message) from wimpiggy.util import gtk_main_quit_really gtk_main_quit_really() raise IOError(error_message) return TwoFileConnection(child.stdin, child.stdout, abort_test)