def __init__(self, quit_cb=None): log("ChildReaper(%s)", quit_cb) from xpra.gtk_common.gobject_compat import import_glib self.glib = import_glib() self._quit = quit_cb self._proc_info = [] if USE_PROCESS_POLLING: log("using process polling every %s seconds", POLL_DELAY) self.glib.timeout_add(POLL_DELAY * 1000, self.poll) else: # with a less buggy python, we can just check the list of pids # whenever we get a SIGCHLD # however.. subprocess.Popen will no longer work as expected # see: http://bugs.python.org/issue9127 # so we must ensure certain things that exec happen first: from xpra.version_util import get_platform_info get_platform_info() signal.signal(signal.SIGCHLD, self.sigchld) # Check once after the mainloop is running, just in case the exit # conditions are satisfied before we even enter the main loop. # (Programming with unix the signal API sure is annoying.) def check_once(): self.check() return False # Only call once self.glib.timeout_add(0, check_once)
def __init__(self, quit_cb=None): log("ChildReaper(%s)", quit_cb) self._quit = quit_cb self._proc_info = [] if USE_PROCESS_POLLING: POLL_DELAY = int(os.environ.get("XPRA_POLL_DELAY", 2)) if BUGGY_PYTHON: log.warn("Warning: outdated/buggy version of Python: %s", ".".join(str(x) for x in sys.version_info)) log.warn("switching to process polling every %s seconds to support 'exit-with-children'", POLL_DELAY) else: log("using process polling every %s seconds", POLL_DELAY) gobject.timeout_add(POLL_DELAY * 1000, self.poll) else: # with a less buggy python, we can just check the list of pids # whenever we get a SIGCHLD # however.. subprocess.Popen will no longer work as expected # see: http://bugs.python.org/issue9127 # so we must ensure certain things that exec happen first: from xpra.version_util import get_platform_info get_platform_info() signal.signal(signal.SIGCHLD, self.sigchld) # Check once after the mainloop is running, just in case the exit # conditions are satisfied before we even enter the main loop. # (Programming with unix the signal API sure is annoying.) def check_once(): self.check() return False # Only call once gobject.timeout_add(0, check_once)
def __init__(self, quit_cb): self._quit = quit_cb self._children_pids = {} self._dead_pids = set() self._ignored_pids = set() from xpra.log import Logger self._logger = Logger("server", "util") if USE_PROCESS_POLLING: POLL_DELAY = int(os.environ.get("XPRA_POLL_DELAY", 2)) self._logger.warn("Warning: outdated/buggy version of Python: %s", ".".join(str(x) for x in sys.version_info)) self._logger.warn( "switching to process polling every %s seconds to support 'exit-with-children'", POLL_DELAY) gobject.timeout_add(POLL_DELAY * 1000, self.check) else: #with a less buggy python, we can just check the list of pids #whenever we get a SIGCHLD #however.. subprocess.Popen will no longer work as expected #see: http://bugs.python.org/issue9127 #so we must ensure certain things that exec happen first: from xpra.version_util import get_platform_info get_platform_info() signal.signal(signal.SIGCHLD, self.sigchld) # Check once after the mainloop is running, just in case the exit # conditions are satisfied before we even enter the main loop. # (Programming with unix the signal API sure is annoying.) def check_once(): self.check() return False # Only call once gobject.timeout_add(0, check_once)
def __init__(self, quit_cb=None): log("ChildReaper(%s)", quit_cb) from xpra.gtk_common.gobject_compat import import_glib self.glib = import_glib() self._quit = quit_cb self._proc_info = [] if USE_PROCESS_POLLING: log("using process polling every %s seconds", POLL_DELAY) self.glib.timeout_add(POLL_DELAY * 1000, self.poll) else: #with a less buggy python, we can just check the list of pids #whenever we get a SIGCHLD #however.. subprocess.Popen will no longer work as expected #see: http://bugs.python.org/issue9127 #so we must ensure certain things that exec happen first: from xpra.version_util import get_platform_info get_platform_info() signal.signal(signal.SIGCHLD, self.sigchld) # Check once after the mainloop is running, just in case the exit # conditions are satisfied before we even enter the main loop. # (Programming with unix the signal API sure is annoying.) def check_once(): self.check() return False # Only call once self.glib.timeout_add(0, check_once)
def init(self, opts): log("ProxyServer.init(%s)", opts) self.video_encoders = opts.video_encoders self.csc_modules = opts.csc_modules ServerCore.init(self, opts) #ensure we cache the platform info before intercepting SIGCHLD #as this will cause a fork and SIGCHLD to be emitted: from xpra.version_util import get_platform_info get_platform_info() self.child_reaper = getChildReaper()
def init(self, opts): log("ProxyServer.init(%s)", opts) self.video_encoders = opts.proxy_video_encoders self.csc_modules = opts.csc_modules self._start_sessions = opts.proxy_start_sessions ServerCore.init(self, opts) #ensure we cache the platform info before intercepting SIGCHLD #as this will cause a fork and SIGCHLD to be emitted: from xpra.version_util import get_platform_info get_platform_info() self.child_reaper = getChildReaper()
def init(self, opts): log("ProxyServer.init(%s)", opts) self.pings = int(opts.pings) self.video_encoders = opts.proxy_video_encoders self._start_sessions = opts.proxy_start_sessions super().init(opts) #ensure we cache the platform info before intercepting SIGCHLD #as this will cause a fork and SIGCHLD to be emitted: from xpra.version_util import get_platform_info get_platform_info() self.child_reaper = getChildReaper()
def init(self, opts): log("ProxyServer.init(%s)", opts) if not opts.tcp_auth: raise InitException("The proxy server requires an authentication mode (use 'none' to disable authentication)") self.video_encoders = opts.video_encoders self.csc_modules = opts.csc_modules ServerCore.init(self, opts) #ensure we cache the platform info before intercepting SIGCHLD #as this will cause a fork and SIGCHLD to be emitted: from xpra.version_util import get_platform_info get_platform_info() self.child_reaper = getChildReaper()
def init(self, opts): log("ProxyServer.init(%s)", opts) if not opts.tcp_auth: raise InitException( "The proxy server requires an authentication mode (use 'none' to disable authentication)" ) self.video_encoders = opts.video_encoders self.csc_modules = opts.csc_modules ServerCore.init(self, opts) #ensure we cache the platform info before intercepting SIGCHLD #as this will cause a fork and SIGCHLD to be emitted: from xpra.version_util import get_platform_info get_platform_info() self.child_reaper = getChildReaper()
def get_server_info(prefix=""): #this function is for non UI thread info info = {} info.update(get_host_info(prefix)) info.update(get_platform_info(mk(prefix, "platform"))) info.update(get_version_info(mk(prefix, "build"))) return info
def main(): def print_dict(d): for k in sorted(d.keys()): v = d[k] print("* %s : %s" % (k.ljust(32), nonl(pver(v)))) from xpra.platform import init, clean try: init("Version-Info", "Version Info") print("Build:") print_dict(get_version_info()) print("") print("Platform:") pi = get_platform_info() #ugly workaround for the fact that "sys.platform" has no key.. if "" in pi: pi["sys"] = pi[""] del pi[""] print_dict(pi) print("") print("Host:") d = get_host_info() #add os specific version info: try: from xpra.platform.info import get_version_info as pvinfo d.update(pvinfo()) except: pass print_dict(d) finally: clean()
def make_hello(self): caps = XpraClientBase.make_hello(self) caps["session-type"] = get_session_type() #don't try to find the server uuid if this platform cannot run servers.. #(doing so causes lockups on win32 and startup errors on osx) if POSIX and not is_Wayland(): #we may be running inside another server! try: from xpra.server.server_uuid import get_uuid caps["server_uuid"] = get_uuid() or "" except ImportError: pass for x in ( #generic feature flags: "wants_events", "setting-change", "xdg-menu-update", ): caps[x] = True caps.update({ #generic server flags: "share": self.client_supports_sharing, "lock": self.client_lock, }) caps.update({"mouse": True}) caps.update(self.get_keyboard_caps()) for c in CLIENT_BASES: caps.update(c.get_caps(self)) def u(prefix, c): updict(caps, prefix, c, flatten_dicts=False) u("control_commands", self.get_control_commands_caps()) u("platform", get_platform_info()) u("opengl", self.opengl_props) return caps
def threaded_init(self): log("threaded_init() start") from xpra.platform import threaded_server_init threaded_server_init() for c in SERVER_BASES: if c != ServerCore: try: c.threaded_setup(self) except Exception: log.error("Error during threaded setup of %s", c, exc_info=True) #populate the platform info cache: from xpra.version_util import get_platform_info get_platform_info() log("threaded_init() end")
def make_hello(self): caps = XpraClientBase.make_hello(self) caps["session-type"] = get_session_type() #don't try to find the server uuid if this platform cannot run servers.. #(doing so causes lockups on win32 and startup errors on osx) if MMAP_SUPPORTED: #we may be running inside another server! try: from xpra.server.server_uuid import get_uuid caps["server_uuid"] = get_uuid() or "" except: pass for x in ( #generic feature flags: "notify-startup-complete", "wants_events", "setting-change", ): caps[x] = True #FIXME: the messy bits without proper namespace: caps.update({ #generic server flags: "share": self.client_supports_sharing, "lock": self.client_lock, }) caps.update(self.get_keyboard_caps()) for c in CLIENT_BASES: caps.update(c.get_caps(self)) def u(prefix, c): updict(caps, prefix, c, flatten_dicts=False) u("control_commands", self.get_control_commands_caps()) u("platform", get_platform_info()) return caps
def get_server_info(): #this function is for non UI thread info info = { "platform" : get_platform_info(), "build" : get_version_info_full(), } info.update(get_host_info()) return info
def get_server_info(): #this function is for non UI thread info info = { "platform": get_platform_info(), "build": get_version_info_full(), } info.update(get_host_info()) return info
def get_server_info(): #this function is for non UI thread info info = {} info.update(get_host_info()) def up(prefix, d): updict(info, prefix, d) up("platform", get_platform_info()) up("build", get_version_info()) return info
def __init__(self): debug("ProxyServer.__init__()") ServerCore.__init__(self) self._max_connections = MAX_CONCURRENT_CONNECTIONS self.main_loop = None #keep track of the proxy process instances #the display they're on and the message queue we can # use to communicate with them self.processes = {} self.idle_add = gobject.idle_add self.timeout_add = gobject.timeout_add self.source_remove = gobject.source_remove self._socket_timeout = PROXY_SOCKET_TIMEOUT self.control_commands = ["hello", "stop"] #ensure we cache the platform info before intercepting SIGCHLD #as this will cause a fork and SIGCHLD to be emitted: from xpra.version_util import get_platform_info get_platform_info() signal.signal(signal.SIGCHLD, self.sigchld)
def __init__(self): log.info("Xpra %s client version %s %i-bit", self.client_toolkit(), full_version_str(), BITS) for c in UIXpraClient.__bases__: c.__init__(self) try: pinfo = get_platform_info() osinfo = "%s" % platform_name( sys.platform, pinfo.get("linux_distribution") or pinfo.get("sysrelease", "")) log.info(" running on %s", osinfo) except: log("platform name error:", exc_info=True) wm = get_wm_name() if wm: log.info(" window manager is '%s'", wm) self._ui_events = 0 self.title = "" self.session_name = u"" self.server_platform = "" self.server_session_name = None #features: self.opengl_enabled = False self.opengl_props = {} self.readonly = False self.xsettings_enabled = False self.server_start_new_commands = False #in WindowClient - should it be? #self.server_is_desktop = False self.server_sharing = False self.server_sharing_toggle = False self.server_lock = False self.server_lock_toggle = False self.server_window_filters = False self.client_supports_opengl = False self.client_supports_sharing = False self.client_lock = False #helpers and associated flags: self.client_extras = None self.keyboard_helper_class = KeyboardHelper self.keyboard_helper = None self.keyboard_grabbed = False self.pointer_grabbed = False self.kh_warning = False self.menu_helper = None #state: self._on_handshake = [] self._on_server_setting_changed = {}
def get_sys_info(): d = {} for k, v in { "version": get_version_info(), "platform": get_platform_info(), "host": get_host_info(), "paths": get_path_info(), "gtk": get_gtk_version_info(), "user": get_user_info(), "env": os.environ, }.items(): updict(d, k, v) return d
def make_hello_base(self): capabilities = get_network_caps() capabilities.update({ "version": local_version, "encoding.generic": True, "namespace": True, "file-transfer": self.file_transfer, "file-size-limit": self.file_size_limit, "printing": self.printing, "hostname": socket.gethostname(), "uuid": self.uuid, "username": self.username, "name": get_name(), "client_type": self.client_type(), "python.version": sys.version_info[:3], "compression_level": self.compression_level, }) if self.display: capabilities["display"] = self.display def up(prefix, d): updict(capabilities, prefix, d) up("platform", get_platform_info()) up("build", get_version_info()) mid = get_machine_id() if mid: capabilities["machine_id"] = mid if self.encryption: assert self.encryption in ENCRYPTION_CIPHERS iv = get_hex_uuid()[:16] key_salt = get_hex_uuid() + get_hex_uuid() iterations = 1000 capabilities.update({ "cipher": self.encryption, "cipher.iv": iv, "cipher.key_salt": key_salt, "cipher.key_stretch_iterations": iterations, }) key = self.get_encryption_key() if key is None: self.warn_and_quit(EXIT_ENCRYPTION, "encryption key is missing") return self._protocol.set_cipher_in(self.encryption, iv, key, key_salt, iterations) log("encryption capabilities: %s", [(k, v) for k, v in capabilities.items() if k.startswith("cipher")]) return capabilities
def print_run_info(self): try: from xpra.src_info import REVISION rev_info = "-r%s" % REVISION except: rev_info = "" log.info("xpra %s version %s%s", self.get_server_mode(), local_version, rev_info) try: pinfo = get_platform_info() osinfo = " on %s" % platform_name(sys.platform, pinfo.get("linux_distribution") or pinfo.get("release", "")) except: log("platform name error:", exc_info=True) osinfo = "" log.info(" running with pid %s%s", os.getpid(), osinfo)
def threaded_init(self): log("threaded_init() start") from xpra.platform import threaded_server_init threaded_server_init() for c in SERVER_BASES: if c != ServerCore: try: c.threaded_setup(self) except Exception: log.error("Error during threaded setup of %s", c, exc_info=True) #populate the platform info cache: from xpra.version_util import get_platform_info get_platform_info() with self.init_thread_lock: for cb in self.init_thread_callbacks: try: cb() except Exception as e: log("threaded_init()", exc_info=True) log.error("Error in initialization thread callback %s", cb) log.error(" %s", e) log("threaded_init() end")
def make_hello(self): caps = XpraClientBase.make_hello(self) caps["session-type"] = get_session_type() #don't try to find the server uuid if this platform cannot run servers.. #(doing so causes lockups on win32 and startup errors on osx) if MMAP_SUPPORTED: #we may be running inside another server! try: from xpra.server.server_uuid import get_uuid caps["server_uuid"] = get_uuid() or "" except: pass for x in ( #generic feature flags: "notify-startup-complete", "wants_events", "setting-change", ): caps[x] = True #FIXME: the messy bits without proper namespace: caps.update({ #generic server flags: "share": self.client_supports_sharing, "lock": self.client_lock, }) #messy unprefixed: caps.update(WindowClient.get_caps(self)) caps.update(DisplayClient.get_caps(self)) caps.update(NetworkState.get_caps(self)) caps.update(Encodings.get_caps(self)) caps.update(ClipboardClient.get_caps(self)) caps.update(self.get_keyboard_caps()) #nicely prefixed: def u(prefix, c): updict(caps, prefix, c, flatten_dicts=False) u("sound", AudioClient.get_audio_capabilities(self)) u("notifications", self.get_notifications_caps()) u("control_commands", self.get_control_commands_caps()) u("platform", get_platform_info()) mmap_caps = MmapClient.get_caps(self) u("mmap", mmap_caps) #pre 2.3 servers only use underscore instead of "." prefix for mmap caps: for k, v in mmap_caps.items(): caps["mmap_%s" % k] = v return caps
def print_run_info(self): try: from xpra.src_info import REVISION rev_info = "-r%s" % REVISION except: rev_info = "" log.info("xpra %s version %s%s", self.get_server_mode(), local_version, rev_info) try: pinfo = get_platform_info() osinfo = " on %s" % platform_name( sys.platform, pinfo.get("linux_distribution") or pinfo.get("release", "")) except: log("platform name error:", exc_info=True) osinfo = "" log.info(" running with pid %s%s", os.getpid(), osinfo)
def make_hello_base(self): capabilities = get_network_caps() capabilities.update({ "version" : local_version, "encoding.generic" : True, "namespace" : True, "file-transfer" : self.file_transfer, "file-size-limit" : self.file_size_limit, "printing" : self.printing, "hostname" : socket.gethostname(), "uuid" : self.uuid, "username" : self.username, "name" : get_name(), "client_type" : self.client_type(), "python.version" : sys.version_info[:3], "compression_level" : self.compression_level, }) if self.display: capabilities["display"] = self.display def up(prefix, d): updict(capabilities, prefix, d) up("platform", get_platform_info()) up("build", get_version_info()) mid = get_machine_id() if mid: capabilities["machine_id"] = mid if self.encryption: assert self.encryption in ENCRYPTION_CIPHERS iv = get_hex_uuid()[:16] key_salt = get_hex_uuid()+get_hex_uuid() iterations = 1000 capabilities.update({ "cipher" : self.encryption, "cipher.iv" : iv, "cipher.key_salt" : key_salt, "cipher.key_stretch_iterations": iterations, }) key = self.get_encryption_key() if key is None: self.warn_and_quit(EXIT_ENCRYPTION, "encryption key is missing") return self._protocol.set_cipher_in(self.encryption, iv, key, key_salt, iterations) log("encryption capabilities: %s", [(k,v) for k,v in capabilities.items() if k.startswith("cipher")]) return capabilities
def get_server_info(prefix=""): #this function is for non UI thread info info = { prefix + "pid": os.getpid(), prefix + "byteorder": sys.byteorder, prefix + "hostname": socket.gethostname(), prefix + "python.full_version": sys.version, prefix + "python.version": sys.version_info[:3], } for x in ("uid", "gid"): if hasattr(os, "get%s" % x): try: info[prefix + x] = getattr(os, "get%s" % x)() except: pass info.update(get_platform_info(prefix)) add_version_info(info, prefix) return info
def get_server_info(prefix=""): #this function is for non UI thread info info = { prefix+"pid" : os.getpid(), prefix+"byteorder" : sys.byteorder, prefix+"hostname" : socket.gethostname(), prefix+"python.full_version": sys.version, prefix+"python.version" : sys.version_info[:3], } for x in ("uid", "gid"): if hasattr(os, "get%s" % x): try: info[prefix+x] = getattr(os, "get%s" % x)() except: pass info.update(get_platform_info(prefix)) add_version_info(info, prefix) return info
def get_sys_info(): from xpra.platform.info import get_user_info from xpra.scripts.config import read_xpra_defaults return { "argv": sys.argv, "path": sys.path, "exec_prefix": sys.exec_prefix, "executable": sys.executable, "version": get_version_info(), "platform": get_platform_info(), "host": get_host_info(), "paths": get_path_info(), "gtk": get_gtk_version_info(), "gui": get_gui_info(), "display": get_display_info(), "user": get_user_info(), "env": os.environ, "config": read_xpra_defaults(), }
def get_sys_info(): from xpra.platform.info import get_user_info from xpra.scripts.config import read_xpra_defaults return { "argv" : sys.argv, "path" : sys.path, "exec_prefix" : sys.exec_prefix, "executable" : sys.executable, "version" : get_version_info(), "platform" : get_platform_info(), "host" : get_host_info(), "paths" : get_path_info(), "gtk" : get_gtk_version_info(), "gui" : get_gui_info(), "display" : get_display_info(), "user" : get_user_info(), "env" : os.environ, "config" : read_xpra_defaults(), }
def main(): from xpra.platform import program_context with program_context("Version-Info", "Version Info"): print("Build:") print_nested_dict(get_version_info()) print("") print("Platform:") pi = get_platform_info() #ugly workaround for the fact that "sys.platform" has no key.. if "" in pi: pi["sys"] = pi[""] del pi[""] print_nested_dict(pi) print("") print("Host:") d = get_host_info() #add os specific version info: from xpra.platform.info import get_version_info as pvinfo d.update(pvinfo()) print_nested_dict(d) return 0
def get_sys_info(): d = { "argv" : sys.argv, "path" : sys.path, "exec_prefix" : sys.exec_prefix, "executable" : sys.executable, } for k,v in { "version" : get_version_info(), "platform" : get_platform_info(), "host" : get_host_info(), "paths" : get_path_info(), "gtk" : get_gtk_version_info(), "gui" : get_gui_info(), "display" : get_display_info(), "user" : get_user_info(), "env" : os.environ, "config" : read_xpra_defaults(), }.items(): updict(d, k, v) return d
def main(): from xpra.platform import program_context with program_context("Version-Info", "Version Info"): print("Build:") print_nested_dict(get_version_info()) print("") print("Platform:") pi = get_platform_info() #ugly workaround for the fact that "sys.platform" has no key.. if "" in pi: pi["sys"] = pi[""] del pi[""] print_nested_dict(pi) print("") print("Host:") d = get_host_info() #add os specific version info: try: from xpra.platform.info import get_version_info as pvinfo d.update(pvinfo()) except: pass print_nested_dict(d)
def __init__(self): log.info("Xpra %s client version %s %i-bit", self.client_toolkit(), full_version_str(), BITS) #mmap_enabled belongs in the MmapClient mixin, #but it is used outside it, so make sure we define it: self.mmap_enabled = False #same for tray: self.tray = None for c in CLIENT_BASES: log("calling %s.__init__()", c) c.__init__(self) try: pinfo = get_platform_info() osinfo = "%s" % platform_name(sys.platform, pinfo.get("linux_distribution") or pinfo.get("sysrelease", "")) log.info(" running on %s", osinfo) except Exception: log("platform name error:", exc_info=True) wm = get_wm_name() #pylint: disable=assignment-from-none if wm: log.info(" window manager is '%s'", wm) self._ui_events = 0 self.title = "" self.session_name = u"" self.server_platform = "" self.server_session_name = None #features: self.opengl_enabled = False self.opengl_props = {} self.readonly = False self.xsettings_enabled = False self.server_start_new_commands = False self.server_xdg_menu = None self.start_new_commands = [] self.start_child_new_commands = [] #in WindowClient - should it be? #self.server_is_desktop = False self.server_sharing = False self.server_sharing_toggle = False self.server_lock = False self.server_lock_toggle = False self.server_window_filters = False self.server_keyboard = True self.server_toggle_keyboard_sync = False self.server_pointer = True self.client_supports_opengl = False self.client_supports_sharing = False self.client_lock = False #helpers and associated flags: self.client_extras = None self.keyboard_helper_class = KeyboardHelper self.keyboard_helper = None self.keyboard_grabbed = False self.keyboard_sync = False self.pointer_grabbed = False self.kh_warning = False self.menu_helper = None #state: self._on_handshake = [] self._on_server_setting_changed = {}
def test_get_platform_info(self): for x in ("release", "name"): self.assertTrue(x in get_platform_info())
def test_get_platform_info(self): for x in ("release", "name"): self.assertTrue(x in get_platform_info(), "%s not found in platform info" % x)