def read_xpra_defaults(): """ Reads the global "xpra.conf" and then the user-specific one. (the latter overrides values from the former) returns a dict with values as strings and arrays of strings. """ #first, read the global defaults: from xpra.platform.paths import get_resources_dir, get_default_conf_dir if sys.platform.startswith("win") or sys.platform.startswith("darwin"): #OSX and win32 use binary installers, #we must look for the default config in the bundled resource location: conf_dir = get_resources_dir() elif sys.prefix == '/usr': #default posix config location: conf_dir = '/etc/xpra' else: #hope the prefix is something like "/usr/local": conf_dir = sys.prefix + '/etc/xpra/' defaults = {} if conf_dir: defaults = read_xpra_conf(conf_dir) #now load the per-user config over it: def_dir = get_default_conf_dir() if def_dir and def_dir != conf_dir: user_defaults = read_xpra_conf(get_default_conf_dir()) defaults.update(user_defaults) return defaults
def read_xpra_defaults(): """ Reads the global <xpra_conf_filename> from the <conf_dir> and then the user-specific one. (the latter overrides values from the former) returns a dict with values as strings and arrays of strings. If the <conf_dir> is not specified, we figure out its location. """ from xpra.platform.paths import get_default_conf_dir, get_system_conf_dir, get_user_conf_dir # load config files in this order (the later ones override earlier ones): # * application defaults (ie: "/Volumes/Xpra/Xpra.app/Contents/Resources/" on OSX) # (ie: "C:\Program Files\Xpra\" on win32) # (ie: None on others) # * system defaults (ie: "/etc/xpra" on Posix - not on OSX) # (ie: "/Library/Application Support/Xpra" on OSX) # (ie: "C:\Documents and Settings\All Users\Application Data\Xpra" with XP) # (ie: "C:\ProgramData\Xpra" with Vista onwards) # * user config (ie: "~/.xpra/" on all Posix, including OSX) # (ie: "C:\Documents and Settings\Username\Application Data\Xpra" with XP) # (ie: "C:\Users\<user name>\AppData\Roaming" with Visa onwards) dirs = [get_default_conf_dir(), get_system_conf_dir(), get_user_conf_dir()] defaults = {} for d in dirs: if not d: continue ad = os.path.expanduser(d) if not os.path.exists(ad): debug("read_xpra_defaults: skipping %s", ad) continue defaults.update(read_xpra_conf(ad)) debug("read_xpra_defaults: updated defaults with %s", ad) return defaults
def read_xpra_defaults(): """ Reads the global <xpra_conf_filename> from the <conf_dir> and then the user-specific one. (the latter overrides values from the former) returns a dict with values as strings and arrays of strings. If the <conf_dir> is not specified, we figure out its location. """ from xpra.platform.paths import get_default_conf_dir, get_system_conf_dir, get_user_conf_dir # load config files in this order (the later ones override earlier ones): # * application defaults (ie: "/Volumes/Xpra/Xpra.app/Contents/Resources/" on OSX) # (ie: "C:\Program Files\Xpra\" on win32) # (ie: None on others) # * system defaults (ie: "/etc/xpra" on Posix - not on OSX) # (ie: "/Library/Application Support/Xpra" on OSX) # (ie: "C:\Documents and Settings\All Users\Application Data\Xpra" with XP) # (ie: "C:\ProgramData\Xpra" with Vista onwards) # * user config (ie: "~/.xpra/" on all Posix, including OSX) # (ie: "C:\Documents and Settings\Username\Application Data\Xpra" with XP) # (ie: "C:\Users\<user name>\AppData\Roaming" with Visa onwards) dirs = [get_default_conf_dir(), get_system_conf_dir(), get_user_conf_dir()] defaults = {} for d in dirs: if not d: continue ad = os.path.expanduser(d) if not os.path.exists(ad): debug("read_xpra_defaults: skipping %s", ad) continue defaults.update(read_xpra_conf(ad)) debug("read_xpra_defaults: updated defaults with %s", ad) return defaults
def __init__(self, sockdir=None, confdir=None, actual_username=""): from xpra.platform.paths import get_default_socket_dir, get_default_conf_dir self._confdir = osexpand(confdir or get_default_conf_dir(), actual_username) self._sockdir = osexpand(sockdir or get_default_socket_dir(), actual_username) 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(),)
def __init__(self, sockdir=None, confdir=None, actual_username=""): from xpra.platform.paths import get_default_socket_dir, get_default_conf_dir self._confdir = osexpand(confdir or get_default_conf_dir(), actual_username) self._sockdir = osexpand(sockdir or get_default_socket_dir(), actual_username) 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(),)
def __init__(self, sockdir=None, confdir=None): from xpra.platform.paths import get_default_socket_dir, get_default_conf_dir def expand(s): return os.path.expandvars(os.path.expanduser(s)) self._confdir = expand(confdir or get_default_conf_dir()) self._sockdir = expand(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(),)
def __init__(self, sockdir=None, confdir=None): from xpra.platform.paths import get_default_socket_dir, get_default_conf_dir def expand(s): return os.path.expandvars(os.path.expanduser(s)) self._confdir = expand(confdir or get_default_conf_dir()) self._sockdir = expand(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(), )
def read_xpra_defaults(): """ Reads the global "xpra.conf" and then the user-specific one. (the latter overrides values from the former) returns a dict with values as strings and arrays of strings. """ #first, read the global defaults: if sys.platform.startswith("win"): conf_dir = os.path.dirname(os.path.abspath(sys.executable)) elif sys.prefix == '/usr': conf_dir = '/etc/xpra' else: conf_dir = sys.prefix + '/etc/xpra/' defaults = read_xpra_conf(conf_dir) #now load the per-user config over it: from xpra.platform.paths import get_default_conf_dir user_defaults = read_xpra_conf(get_default_conf_dir()) for k,v in user_defaults.items(): defaults[k] = v return defaults
def get_nvenc_license_keys(nvenc_version=0): global nvenc_license_keys keys = nvenc_license_keys.get(nvenc_version) if keys is not None: return keys env_keys = os.environ.get("XPRA_NVENC_CLIENT_KEY", "") if env_keys: keys = [x.strip() for x in os.environ.get("XPRA_NVENC_CLIENT_KEY", "").split(",")] log("using nvenc keys from environment variable XPRA_NVENC_CLIENT_KEY: %s", nvenc_license_keys) else: #try the license file keys = [] try: #see read_xpra_defaults for an explanation of paths from xpra.platform.paths import get_default_conf_dir, get_system_conf_dir, get_user_conf_dir dirs = [get_default_conf_dir(), get_system_conf_dir(), get_user_conf_dir()] for d in dirs: if not d: continue keys_file = os.path.join(d, "nvenc%s.keys" % (nvenc_version or "")) keys_file = os.path.expanduser(keys_file) if not os.path.exists(keys_file): log("get_nvenc_license_keys(%s) '%s' does not exist", nvenc_version, keys_file) continue log("loading nvenc%s keys from %s", nvenc_version, keys_file) with open(keys_file, "rU") as f: for line in f: sline = line.strip().rstrip('\r\n').strip() if len(sline) == 0: log("skipping empty line") continue if sline[0] in ( '!', '#' ): log("skipping comments") continue keys.append(sline) log("added key: %s", sline) except Exception as e: log.error("error loading nvenc license keys: %s", e, exc_info=True) nvenc_license_keys[nvenc_version] = keys log("get_nvenc_license_keys(%s)=%s", nvenc_version, keys) return keys