Ejemplo n.º 1
0
 def __init__(self, sockdir=None, confdir=None):
     from xpra.platform import get_default_socket_dir, get_default_conf_dir
     self._confdir = os.path.expanduser(confdir or get_default_conf_dir())
     self._sockdir = os.path.expanduser(sockdir or get_default_socket_dir())
     if not os.path.exists(self._confdir):
         os.mkdir(self._confdir, o0700)
     if not os.path.exists(self._sockdir):
         os.mkdir(self._sockdir, o0700)
     self._prefix = "%s-" % (socket.gethostname(),)
Ejemplo n.º 2
0
 def __init__(self, sockdir=None, confdir=None):
     from xpra.platform import get_default_socket_dir, get_default_conf_dir
     self._confdir = os.path.expanduser(confdir or get_default_conf_dir())
     self._sockdir = os.path.expanduser(sockdir or get_default_socket_dir())
     if not os.path.exists(self._confdir):
         os.mkdir(self._confdir, o0700)
     if not os.path.exists(self._sockdir):
         os.mkdir(self._sockdir, o0700)
     self._prefix = "%s-" % (socket.gethostname(), )
Ejemplo n.º 3
0
def pick_display(parser, opts, extra_args):
    if len(extra_args) == 0:
        # Pick a default server
        sockdir = DotXpra(opts.socket_dir or get_default_socket_dir())
        servers = sockdir.sockets()
        live_servers = [
            display for (state, display) in servers if state is DotXpra.LIVE
        ]
        if len(live_servers) == 0:
            parser.error("cannot find a live server to connect to")
        elif len(live_servers) == 1:
            return parse_display_name(parser.error, opts, live_servers[0])
        else:
            parser.error("there are multiple servers running, please specify")
    elif len(extra_args) == 1:
        return parse_display_name(parser.error, opts, extra_args[0])
    else:
        parser.error("too many arguments")
Ejemplo n.º 4
0
def pick_display(parser, opts, extra_args):
    if len(extra_args) == 0:
        # Pick a default server
        sockdir = DotXpra(opts.socket_dir or get_default_socket_dir())
        servers = sockdir.sockets()
        live_servers = [display
                        for (state, display) in servers
                        if state is DotXpra.LIVE]
        if len(live_servers) == 0:
            parser.error("cannot find a live server to connect to")
        elif len(live_servers) == 1:
            return parse_display_name(parser.error, opts, live_servers[0])
        else:
            parser.error("there are multiple servers running, please specify")
    elif len(extra_args) == 1:
        return parse_display_name(parser.error, opts, extra_args[0])
    else:
        parser.error("too many arguments")
Ejemplo n.º 5
0
                 opts.password_file):
         try:
             try:
                 passwordFile = open(opts.password_file, "rb")
                 desc["password"] = passwordFile.read()
             finally:
                 passwordFile.close()
         except Exception, e:
             print("failed to read password file %s: %s",
                   opts.password_file, e)
     return desc
 elif display_name.startswith(":"):
     desc["type"] = "unix-domain"
     desc["local"] = True
     desc["display"] = display_name
     desc["socket_dir"] = opts.socket_dir or get_default_socket_dir()
     return desc
 elif display_name.startswith("tcp:") or display_name.startswith("tcp/"):
     separator = display_name[3]  # ":" or "/"
     desc["type"] = "tcp"
     desc["local"] = False
     parts = display_name.split(separator)
     if len(parts) != 3:
         error_cb(
             "invalid tcp connection string, use tcp/HOST/PORT or tcp:host:port"
         )
     port = int(parts[-1])
     if port <= 0 or port >= 65536:
         error_cb("invalid port number: %s" % port)
     desc["port"] = port
     desc["host"] = separator.join(parts[1:-1])
Ejemplo n.º 6
0
     desc["remote_xpra"] = remote_xpra
     if desc.get("password") is None and opts.password_file and os.path.exists(opts.password_file):
         try:
             try:
                 passwordFile = open(opts.password_file, "rb")
                 desc["password"] = passwordFile.read()
             finally:
                 passwordFile.close()
         except Exception, e:
             print("failed to read password file %s: %s", opts.password_file, e)
     return desc
 elif display_name.startswith(":"):
     desc["type"] = "unix-domain"
     desc["local"] = True
     desc["display"] = display_name
     desc["socket_dir"] = opts.socket_dir or get_default_socket_dir()
     return desc
 elif display_name.startswith("tcp:") or display_name.startswith("tcp/"):
     separator = display_name[3] # ":" or "/"
     desc["type"] = "tcp"
     desc["local"] = False
     parts = display_name.split(separator)
     if len(parts)!=3:
         error_cb("invalid tcp connection string, use tcp/HOST/PORT or tcp:host:port")
     port = int(parts[-1])
     if port<=0 or port>=65536:
         error_cb("invalid port number: %s" % port)
     desc["port"] = port
     desc["host"] = separator.join(parts[1:-1])
     if desc["host"] == "":
         desc["host"] = "127.0.0.1"