def log_screen_sizes(root_w, root_h, sizes): try: do_log_screen_sizes(root_w, root_h, sizes) except Exception: from xpra.log import Logger log = Logger("util") log.warn("failed to parse screen size information: %s", sys.exc_info()[1])
def log_screen_sizes(root_w, root_h, sizes): try: do_log_screen_sizes(root_w, root_h, sizes) except Exception as e: from xpra.log import Logger log = Logger("screen") log.warn("failed to parse screen size information: %s", e, exc_info=True)
def log_screen_sizes(root_w, root_h, ss): try: do_log_screen_sizes(root_w, root_h, ss) except Exception, e: from xpra.log import Logger log = Logger() log.warn("failed to parse screen size information: %s", e)
def find_ssl_cert(filename="ssl-cert.pem"): from xpra.log import Logger ssllog = Logger("ssl") #try to locate the cert file from known locations from xpra.platform.paths import get_ssl_cert_dirs #pylint: disable=import-outside-toplevel dirs = get_ssl_cert_dirs() ssllog("find_ssl_cert(%s) get_ssl_cert_dirs()=%s", filename, dirs) for d in dirs: p = osexpand(d) if not os.path.exists(p): ssllog("ssl cert dir '%s' does not exist", p) continue f = os.path.join(p, "ssl-cert.pem") if not os.path.exists(f): ssllog("ssl cert '%s' does not exist", f) continue if not os.path.isfile(f): ssllog.warn("Warning: '%s' is not a file", f) continue if not os.access(p, os.R_OK): ssllog.info("SSL certificate file '%s' is not accessible", f) continue ssllog("found ssl cert '%s'", f) return f return None
def log_screen_sizes(sizes): try: do_log_screen_sizes(sizes) except Exception, e: from xpra.log import Logger log = Logger() log.warn("failed to parse screen size information: %s", e)
def parse_hello(self, c: typedict): self.ui_client = c.boolget("ui_client", True) self.wants_encodings = c.boolget("wants_encodings", self.ui_client) self.wants_display = c.boolget("wants_display", self.ui_client) self.wants_events = c.boolget("wants_events", False) self.wants_aliases = c.boolget("wants_aliases", True) self.wants_versions = c.boolget("wants_versions", True) self.wants_features = c.boolget("wants_features", True) self.wants_default_cursor = c.boolget("wants_default_cursor", False) for bc in CC_BASES: log("%s.parse_client_caps(..)", bc) bc.parse_client_caps(self, c) #log client info: cinfo = self.get_connect_info() for i, ci in enumerate(cinfo): log.info("%s%s", ["", " "][int(i > 0)], ci) if self.client_proxy: from xpra.version_util import version_compat_check msg = version_compat_check(self.proxy_version) if msg: proxylog = Logger("proxy") proxylog.warn( "Warning: proxy version may not be compatible: %s", msg)
def log_screen_sizes(root_w, root_h, sizes): try: do_log_screen_sizes(root_w, root_h, sizes) except Exception as e: from xpra.log import Logger log = Logger("screen") log.warn("failed to parse screen size information: %s", e, exc_info=True)
def do_get_keycode(self, client_keycode, keyname, pressed, modifiers, keyval, keystr, group): from xpra.log import Logger log = Logger("keyboard") log("do_get_keycode%s", (client_keycode, keyname, pressed, modifiers, keyval, keystr, group)) log.warn("Warning: %s does not implement get_keycode!", type(self)) return -1
def Logon(username, password): #sys.path.insert(0, "E:\\DesktopLogon\\") #desktop_logon = ctypes.cdll.LoadLibrary("E:\\DesktopLogon\\DesktopLogon.dll") desktop_logon = ctypes.cdll.LoadLibrary("DesktopLogon.dll") desktop_logon.Logon(username, password) r = desktop_logon.getErrorCode() if r: from xpra.log import Logger log = Logger("win32") log.warn("Logon(..) error %i : '%s'", r, ERROR_CODES.get(r, "unknown error"))
def get_icc_info(): from xpra.log import Logger log = Logger("platform") info = {} try: from PIL.ImageCms import ( get_display_profile, getProfileName, getProfileInfo, getProfileCopyright, getProfileManufacturer, getProfileModel, getProfileDescription, getDefaultIntent, INTENT_PERCEPTUAL, INTENT_RELATIVE_COLORIMETRIC, INTENT_SATURATION, INTENT_ABSOLUTE_COLORIMETRIC, ) INTENT_STR = { INTENT_PERCEPTUAL: "perceptual", INTENT_RELATIVE_COLORIMETRIC: "relative-colorimetric", INTENT_SATURATION: "saturation", INTENT_ABSOLUTE_COLORIMETRIC: "absolute-colorimetric", } def getDefaultIntentStr(_p): return INTENT_STR.get(getDefaultIntent(_p), "unknown") def getData(_p): return _p.tobytes() p = get_display_profile() if p: for (k, fn) in { "name": getProfileName, "info": getProfileInfo, "copyright": getProfileCopyright, "manufacturer": getProfileManufacturer, "model": getProfileModel, "description": getProfileDescription, "default-intent": getDefaultIntentStr, "data": getData, }.items(): try: v = fn(p) info[k] = v except Exception as e: log("ICC profile error on %s using %s: %s", k, fn, e) except Exception as e: log.warn("Warning: cannot query ICC profiles:") log.warn(" %s", e) return info
def default_get_icc_info(): ENV_ICC_DATA = os.environ.get("XPRA_ICC_DATA") if ENV_ICC_DATA: import binascii return { "source" : "environment-override", "data" : binascii.unhexlify(ENV_ICC_DATA), } from xpra.os_util import bytestostr from xpra.log import Logger screenlog = Logger("screen") info = {} try: from PIL import ImageCms from PIL.ImageCms import get_display_profile INTENT_STR = {} for x in ("PERCEPTUAL", "RELATIVE_COLORIMETRIC", "SATURATION", "ABSOLUTE_COLORIMETRIC"): v = getattr(ImageCms, "INTENT_%s" % x, None) if v: INTENT_STR[v] = x.lower().replace("_", "-") screenlog("get_icc_info() intents=%s", INTENT_STR) p = get_display_profile() screenlog("get_icc_info() display_profile=%s", p) if p: def getDefaultIntentStr(v): return INTENT_STR.get(v, "unknown") def getData(v): return v.tobytes() for (k, fn, conv) in ( ("name", "getProfileName", None), ("info", "getProfileInfo", None), ("copyright", "getProfileCopyright", None), ("manufacturer", "getProfileManufacturer", None), ("model", "getProfileModel", None), ("description", "getProfileDescription", None), ("default-intent", "getDefaultIntent", getDefaultIntentStr), ("data", "getData", getData), ): m = getattr(ImageCms, fn, None) if m is None: screenlog("%s lacks %s", ImageCms, fn) continue try: v = m(p) if conv: v = conv(v) info[k] = bytestostr(v).rstrip("\n\r") except Exception as e: screenlog("get_icc_info()", exc_info=True) screenlog("ICC profile error on %s using %s: %s", k, fn, e) except Exception as e: screenlog("get_icc_info()", exc_info=True) screenlog.warn("Warning: cannot query ICC profiles:") screenlog.warn(" %s", e) return info
def get_icc_info(): from xpra.log import Logger log = Logger("platform") ENV_ICC_DATA = os.environ.get("XPRA_ICC_DATA") if ENV_ICC_DATA: import binascii return { "source": "environment-override", "data": binascii.unhexlify(ENV_ICC_DATA), } info = {} try: from PIL import ImageCms from PIL.ImageCms import get_display_profile, getDefaultIntent INTENT_STR = {} for x in ("PERCEPTUAL", "RELATIVE_COLORIMETRIC", "SATURATION", "ABSOLUTE_COLORIMETRIC"): v = getattr(ImageCms, "INTENT_%s" % x, None) if v: INTENT_STR[v] = x.lower().replace("_", "-") log("get_icc_info() intents=%s", INTENT_STR) def getDefaultIntentStr(_p): return INTENT_STR.get(getDefaultIntent(_p), "unknown") def getData(_p): return _p.tobytes() p = get_display_profile() log("get_icc_info() display_profile=%s", p) if p: for (k, fn) in { "name": "getProfileName", "info": "getProfileInfo", "copyright": "getProfileCopyright", "manufacturer": "getProfileManufacturer", "model": "getProfileModel", "description": "getProfileDescription", "default-intent": "getDefaultIntentStr", "data": "getData", }.items(): m = getattr(ImageCms, fn, None) if not m: log("%s lacks %s", ImageCms, fn) continue try: v = m(p) info[k] = v except Exception as e: log("ICC profile error on %s using %s: %s", k, fn, e) except Exception as e: log("get_icc_info()", exc_info=True) log.warn("Warning: cannot query ICC profiles:") log.warn(" %s", e) return info
def sanity_checks(): if not use_lzo and not use_lz4: from xpra.log import Logger logger = Logger("network", "protocol") if not use_zlib: logger.warn("Warning: all the compressors are disabled,") logger.warn(" unless you use mmap or have a gigabit connection or better") logger.warn(" performance will suffer") else: logger.warn("Warning: zlib is the only compressor enabled") logger.warn(" install and enable lzo or lz4 support for better performance")
def get_notifier_classes(self): ncs = GTKXpraClient.get_notifier_classes(self) if not OSX: try: from xpra.client.gtk3.gtk3_notifier import GTK3_Notifier ncs.append(GTK3_Notifier) except Exception as e: from xpra.log import Logger log = Logger("gtk", "client") log.warn("Warning: failed to load the GTK3 notification class") log.warn(" %s", e) return ncs
def load_binary_file(filename): if not os.path.exists(filename): return None try: with open(filename, "rb") as f: return f.read() except Exception as e: from xpra.log import Logger log = Logger("util") log.warn("Warning: failed to load '%s':", filename) log.warn(" %s", e) return None
def make_instance(self): from xpra.log import Logger log = Logger("encoding") cur = self.get_instance_count() if (self.max_instances>0 and cur>=self.max_instances) or cur>=_codec_spec.WARN_LIMIT: log.warn("Warning: already %s active instances of %s: %s", cur, self.codec_class, tuple(self.instances.keys())) from xpra.util import dump_references dump_references(log, self.instances.keys()) else: log("make_instance() %s - instance count=%s", self.codec_type, cur) v = self.codec_class() self.instances[v] = True return v
def get_icc_info(): from xpra.log import Logger log = Logger("platform") ENV_ICC_DATA = os.environ.get("XPRA_ICC_DATA") if ENV_ICC_DATA: import binascii return { "source" : "environment-override", "data" : binascii.unhexlify(ENV_ICC_DATA), } info = {} try: from PIL import ImageCms from PIL.ImageCms import get_display_profile, getDefaultIntent INTENT_STR = {} for x in ("PERCEPTUAL", "RELATIVE_COLORIMETRIC", "SATURATION", "ABSOLUTE_COLORIMETRIC"): v = getattr(ImageCms, "INTENT_%s" % x, None) if v: INTENT_STR[v] = x.lower().replace("_", "-") log("get_icc_info() intents=%s", INTENT_STR) def getDefaultIntentStr(_p): return INTENT_STR.get(getDefaultIntent(_p), "unknown") def getData(_p): return _p.tobytes() p = get_display_profile() log("get_icc_info() display_profile=%s", p) if p: for (k, fn) in { "name" : "getProfileName", "info" : "getProfileInfo", "copyright" : "getProfileCopyright", "manufacturer" : "getProfileManufacturer", "model" : "getProfileModel", "description" : "getProfileDescription", "default-intent": "getDefaultIntentStr", "data" : "getData", }.items(): m = getattr(ImageCms, fn, None) if not m: log("%s lacks %s", ImageCms, fn) continue try: v = m(p) info[k] = v except Exception as e: log("ICC profile error on %s using %s: %s", k, fn, e) except Exception as e: log("get_icc_info()", exc_info=True) log.warn("Warning: cannot query ICC profiles:") log.warn(" %s", e) return info
def get_pillow_icc_info(): screenlog = Logger("screen") info = {} try: from PIL import ImageCms from PIL.ImageCms import get_display_profile INTENT_STR = {} for x in ("PERCEPTUAL", "RELATIVE_COLORIMETRIC", "SATURATION", "ABSOLUTE_COLORIMETRIC"): intent = getattr(ImageCms, "Intent", None) if intent: v = getattr(intent, x, None) else: v = getattr(ImageCms, "INTENT_%s" % x, None) if v: INTENT_STR[v] = x.lower().replace("_", "-") screenlog("get_icc_info() intents=%s", INTENT_STR) p = get_display_profile() screenlog("get_icc_info() display_profile=%s", p) if p: def getDefaultIntentStr(v): return INTENT_STR.get(v, "unknown") def getData(v): return v.tobytes() for (k, fn, conv) in ( ("name", "getProfileName", None), ("info", "getProfileInfo", None), ("copyright", "getProfileCopyright", None), ("manufacturer", "getProfileManufacturer", None), ("model", "getProfileModel", None), ("description", "getProfileDescription", None), ("default-intent", "getDefaultIntent", getDefaultIntentStr), ("data", "getData", getData), ): m = getattr(ImageCms, fn, None) if m is None: screenlog("%s lacks %s", ImageCms, fn) continue try: v = m(p) if conv: v = conv(v) info[k] = bytestostr(v).rstrip("\n\r") except Exception as e: screenlog("get_icc_info()", exc_info=True) screenlog("ICC profile error on %s using %s: %s", k, fn, e) except Exception as e: screenlog("get_icc_info()", exc_info=True) screenlog.warn("Warning: cannot query ICC profiles:") screenlog.warn(" %s", e) return info
def ival(key, default, minv=0, maxv=None): try: v = os.environ.get("XPRA_BATCH_%s" % key) if v is None: return default iv = int(v) assert minv is None or minv<=iv, "value for %s is too small: %s (minimum is %s)" % (key, iv, minv) assert maxv is None or maxv>=iv, "value for %s is too high: %s (maximum is %s)" % (key, iv, maxv) return iv except Exception as e: from xpra.log import Logger log = Logger("util") log.warn("failed to parse value '%s' for %s: %s", v, key, e) return default
def print_DE_warnings(desktop_display, pulseaudio, notifications, dbus_launch): de = os.environ.get("XDG_SESSION_DESKTOP") or os.environ.get( "SESSION_DESKTOP") if not de: return warnings = [] from xpra.log import Logger log = Logger("server") if pulseaudio is not False: try: xprop = subprocess.Popen( ["xprop", "-root", "-display", desktop_display], stdout=subprocess.PIPE) out, _ = xprop.communicate() for x in out.splitlines(): if x.startswith("PULSE_SERVER"): #found an existing pulseaudio server warnings.append("pulseaudio") break except: pass #don't care, this is just to decide if we show an informative warning or not if notifications and not dbus_launch: warnings.append("notifications") if warnings: log.warn("Warning: xpra start from an existing '%s' desktop session", de) log.warn(" %s forwarding may not work", " and ".join(warnings)) log.warn(" try using a clean environment, a dedicated user,") log.warn(" or disable xpra's %s option", " and ".join(['"%s"' % x for x in warnings]))
def parse_simple_dict(s="", sep=","): #parse the options string and add the pairs: d = {} for s in s.split(sep): if not s: continue try: k, v = s.split("=", 1) d[k] = v except Exception as e: from xpra.log import Logger log = Logger("util") log.warn("Warning: failed to parse dictionary option '%s':", s) log.warn(" %s", e) return d
def set_application_name(name): global NAME_SET if NAME_SET: return NAME_SET = True from xpra.log import Logger log = Logger() if sys.version_info[:2]<(2,5): log.warn("Python %s is too old!", sys.version_info) return try: import glib glib.set_application_name(name or "Xpra") except ImportError, e: log.warn("glib is missing, cannot set the application name, please install glib's python bindings: %s", e)
def parse_simple_dict(s="", sep=","): #parse the options string and add the pairs: d = {} for s in s.split(sep): if not s: continue try: k,v = s.split("=", 1) d[k] = v except Exception as e: from xpra.log import Logger log = Logger("util") log.warn("Warning: failed to parse dictionary option '%s':", s) log.warn(" %s", e) return d
def ival(key, default, minv=0, maxv=None): try: v = os.environ.get("XPRA_BATCH_%s" % key) if v is None: return default iv = int(v) assert minv is None or minv <= iv, "value for %s is too small: %s (minimum is %s)" % ( key, iv, minv) assert maxv is None or maxv >= iv, "value for %s is too high: %s (maximum is %s)" % ( key, iv, maxv) return iv except Exception as e: from xpra.log import Logger log = Logger("util") log.warn("failed to parse value '%s' for %s: %s", v, key, e) return default
def init_encoders(*names): for x in names: if x not in ALL_ENCODERS: logger = Logger("network", "protocol") logger.warn("Warning: invalid encoder '%s'", x) continue if not envbool("XPRA_%s" % (x.upper()), True): continue fn = globals().get("init_%s" % x) try: e = fn() assert e ENCODERS[x] = e except (ImportError, AttributeError): logger = Logger("network", "protocol") logger.debug("no %s", x, exc_info=True)
def mdns_publish(display_name, listen_on, text_dict=None): global MDNS_WARNING if MDNS_WARNING is True: return () from xpra.log import Logger log = Logger("mdns") log("mdns_publish%s", (display_name, listen_on, text_dict)) try: from xpra.net import mdns assert mdns from xpra.net.mdns import XPRA_MDNS_TYPE, RFB_MDNS_TYPE PREFER_ZEROCONF = envbool("XPRA_PREFER_ZEROCONF", False) or WIN32 or OSX if PREFER_ZEROCONF: from xpra.net.mdns.zeroconf_publisher import ZeroconfPublishers as MDNSPublishers, get_interface_index else: from xpra.net.mdns.avahi_publisher import AvahiPublishers as MDNSPublishers, get_interface_index except ImportError as e: MDNS_WARNING = True log("mdns import failure", exc_info=True) log.warn("Warning: failed to load the mdns publisher") try: einfo = str(e) except Exception: einfo = str(type(e)) log.warn(" %s", einfo) log.warn(" either install the 'python-avahi' module") log.warn(" or use the 'mdns=no' option") return () d = dict(text_dict or {}) #ensure we don't have duplicate interfaces: f_listen_on = {} for host, port in listen_on: f_listen_on[(get_interface_index(host), port)] = (host, port) try: name = socket.gethostname() except (IOError, OSError): name = "Xpra" if display_name and not (OSX or WIN32): name += " %s" % display_name mode = d.get("mode", "tcp") service_type = {"rfb": RFB_MDNS_TYPE}.get(mode, XPRA_MDNS_TYPE) index = 0 aps = [] for host, port in listen_on: sn = name mode_str = mode if index > 0: mode_str = "%s-%i" % (mode, index + 1) if mode not in ("tcp", "rfb"): sn += " (%s)" % mode_str listen = ((host, port), ) index += 1 aps.append( MDNSPublishers(listen, sn, service_type=service_type, text_dict=d)) return aps
def mdns_publish(display_name, mode, listen_on, text_dict={}): try: from xpra.net.avahi_publisher import AvahiPublishers except Exception as e: global MDNS_WARNING if not MDNS_WARNING: MDNS_WARNING = True from xpra.log import Logger log = Logger("mdns") log.warn("Warning: failed to load the mdns avahi publisher: %s", e) log.warn(" either fix your installation or use the 'mdns=no' option") return d = text_dict.copy() d["mode"] = mode ap = AvahiPublishers(listen_on, "Xpra %s %s" % (mode, display_name), text_dict=d) _when_ready.append(ap.start) _cleanups.append(ap.stop)
def sanity_checks(): if not use("lzo") and not use("lz4"): from xpra.log import Logger logger = Logger("network", "protocol") if not use("zlib"): logger.warn("Warning: all the compressors are unavailable or disabled,") logger.warn(" performance may suffer in some cases") else: logger.warn("Warning: zlib is the only compressor enabled") logger.warn(" install and enable lz4 support for better performance")
def mdns_publish(display_name, mode, listen_on, text_dict={}): global MDNS_WARNING if MDNS_WARNING is True: return try: from xpra.net import mdns assert mdns from xpra.net.mdns import XPRA_MDNS_TYPE, RFB_MDNS_TYPE PREFER_PYBONJOUR = envbool("XPRA_PREFER_PYBONJOUR", False) or WIN32 or OSX PREFER_ZEROCONF = envbool("XPRA_PREFER_ZEROCONF", False) if PREFER_PYBONJOUR: from xpra.net.mdns.pybonjour_publisher import BonjourPublishers as MDNSPublishers, get_interface_index elif PREFER_ZEROCONF: from xpra.net.mdns.zeroconf_publisher import ZeroconfPublishers as MDNSPublishers, get_interface_index else: from xpra.net.mdns.avahi_publisher import AvahiPublishers as MDNSPublishers, get_interface_index except ImportError as e: MDNS_WARNING = True from xpra.log import Logger log = Logger("mdns") log("mdns import failure", exc_info=True) log.warn("Warning: failed to load the mdns publisher") try: einfo = str(e) except: einfo = str(type(e)) log.warn(" %s", einfo) log.warn(" either install the 'python-avahi' module") log.warn(" or use the 'mdns=no' option") return d = text_dict.copy() d["mode"] = mode #ensure we don't have duplicate interfaces: f_listen_on = {} for host, port in listen_on: f_listen_on[(get_interface_index(host), port)] = (host, port) try: name = socket.gethostname() except: name = "Xpra" if display_name and not (OSX or WIN32): name += " %s" % display_name if mode not in ("tcp", "rfb"): name += " (%s)" % mode service_type = {"rfb": RFB_MDNS_TYPE}.get(mode, XPRA_MDNS_TYPE) ap = MDNSPublishers(f_listen_on.values(), name, service_type=service_type, text_dict=d) from xpra.scripts.server import add_when_ready, add_cleanup add_when_ready(ap.start) add_cleanup(ap.stop)
def get_icc_info(): from xpra.log import Logger log = Logger("platform") info = {} try: from PIL.ImageCms import get_display_profile, \ getProfileName, getProfileInfo, getProfileCopyright, getProfileManufacturer, getProfileModel, getProfileDescription, getDefaultIntent, \ INTENT_PERCEPTUAL, INTENT_RELATIVE_COLORIMETRIC, INTENT_SATURATION, INTENT_ABSOLUTE_COLORIMETRIC INTENT_STR = { INTENT_PERCEPTUAL: "perceptual", INTENT_RELATIVE_COLORIMETRIC: "relative-colorimetric", INTENT_SATURATION: "saturation", INTENT_ABSOLUTE_COLORIMETRIC: "absolute-colorimetric", } def getDefaultIntentStr(_p): return INTENT_STR.get(getDefaultIntent(_p), "unknown") def getData(_p): return _p.tobytes() p = get_display_profile() if p: for (k, fn) in { "name": getProfileName, "info": getProfileInfo, "copyright": getProfileCopyright, "manufacturer": getProfileManufacturer, "model": getProfileModel, "description": getProfileDescription, "default-intent": getDefaultIntentStr, "data": getData, }.items(): try: v = fn(p) info[k] = v except Exception as e: log("ICC profile error on %s using %s: %s", k, fn, e) except Exception as e: log.warn("Warning: cannot query ICC profiles:") log.warn(" %s", e) return info
def mdns_publish(display_name, mode, listen_on, text_dict={}): try: from xpra.net.avahi_publisher import AvahiPublishers except Exception as e: global MDNS_WARNING if not MDNS_WARNING: MDNS_WARNING = True from xpra.log import Logger log = Logger("mdns") log.warn("Warning: failed to load the mdns avahi publisher: %s", e) log.warn( " either fix your installation or use the 'mdns=no' option") return d = text_dict.copy() d["mode"] = mode ap = AvahiPublishers(listen_on, "Xpra %s %s" % (mode, display_name), text_dict=d) _when_ready.append(ap.start) _cleanups.append(ap.stop)
def main(): from xpra.platform import program_context from xpra.log import enable_color, Logger, enable_debug_for log = Logger("win32") with program_context("LSA-Logon-Test", "LSA Logon Test"): enable_color() for x in ("-v", "--verbose"): if x in list(sys.argv): enable_debug_for("win32") sys.argv.remove(x) if len(sys.argv) != 2: log.warn("invalid number of arguments") log.warn("usage: %s [--verbose] username", sys.argv[0]) return 1 username = sys.argv[1] try: logon_msv1_s4u(username) return 0 except Exception as e: log.error("Logon failed: %s", e) return 1
def get_fcolor(encoding): color_name = os.environ.get("XPRA_BOX_COLOR_%s" % encoding.upper(), DEFAULT_BOX_COLORS.get(encoding)) try: c = color_parse(color_name) except: c = color_parse("black") #try and hope this works: try: return c.red / 65536.0, c.green / 65536.0, c.blue / 65536.0, 0.3 except: pass try: #it seems that in some GDK versions, we get a return value #made of (boolean, GDK.Color), we only want the color.. c = c[1] except: from xpra.log import Logger log = Logger("util") log.warn("failed to parse color %s", color_name) return 0, 0, 0 return c.red / 65536.0, c.green / 65536.0, c.blue / 65536.0, 0.3
def platform_release(release): if sys.platform.startswith("darwin"): SYSTEMVERSION_PLIST = "/System/Library/CoreServices/SystemVersion.plist" try: import plistlib load = getattr(plistlib, "load", None) if load: with open(SYSTEMVERSION_PLIST, "rb") as f: pl = load(f) #@UndefinedVariable else: pl = plistlib.readPlist( '/System/Library/CoreServices/SystemVersion.plist') return pl['ProductUserVisibleVersion'] except Exception as e: from xpra.log import Logger log = Logger("util") log.debug("platform_release(%s)", release, exc_info=True) log.warn("Warning: failed to get release information") log.warn(" from '%s':", SYSTEMVERSION_PLIST) log.warn(" %s", e) return release
def write_runner_shell_scripts(contents, overwrite=True): # This used to be given a display-specific name, but now we give it a # single fixed name and if multiple servers are started then the last one # will clobber the rest. This isn't great, but the tradeoff is that it # makes it possible to use bare 'ssh:hostname' display names and # autodiscover the proper numeric display name when only one xpra server # is running on the remote host. Might need to revisit this later if # people run into problems or autodiscovery turns out to be less useful # than expected. from xpra.log import Logger log = Logger("server") from xpra.platform.paths import get_script_bin_dirs for d in get_script_bin_dirs(): scriptdir = osexpand(d) if not os.path.exists(scriptdir): try: os.mkdir(scriptdir, 0o700) except Exception as e: log.warn("Warning: failed to write script file in '%s':", scriptdir) log.warn(" %s", e) if scriptdir.startswith( "/var/run/user") or scriptdir.startswith("/run/user"): log.warn(" ($XDG_RUNTIME_DIR has not been created?)") continue scriptpath = os.path.join(scriptdir, "run-xpra") if os.path.exists(scriptpath) and not overwrite: continue # Write out a shell-script so that we can start our proxy in a clean # environment: try: with open(scriptpath, "w") as scriptfile: # Unix is a little silly sometimes: umask = os.umask(0) os.umask(umask) os.fchmod(scriptfile.fileno(), 0o700 & ~umask) scriptfile.write(contents) except Exception as e: log.error("Error: failed to write script file '%s':", scriptpath) log.error(" %s\n", e)
def mdns_publish(display_name, mode, listen_on, text_dict={}): global MDNS_WARNING if MDNS_WARNING is True: return PREFER_PYBONJOUR = envbool("XPRA_PREFER_PYBONJOUR", False) or WIN32 or OSX try: from xpra.net import mdns assert mdns if PREFER_PYBONJOUR: from xpra.net.mdns.pybonjour_publisher import BonjourPublishers as MDNSPublishers, get_interface_index else: from xpra.net.mdns.avahi_publisher import AvahiPublishers as MDNSPublishers, get_interface_index except ImportError as e: MDNS_WARNING = True from xpra.log import Logger log = Logger("mdns") log("mdns import failure", exc_info=True) log.warn("Warning: failed to load the mdns %s publisher:", ["avahi", "pybonjour"][PREFER_PYBONJOUR]) log.warn(" %s", e) log.warn(" either fix your installation or use the 'mdns=no' option") return d = text_dict.copy() d["mode"] = mode #ensure we don't have duplicate interfaces: f_listen_on = {} for host, port in listen_on: f_listen_on[get_interface_index(host)] = (host, port) try: name = socket.gethostname() except: name = "Xpra" if display_name and not (OSX or WIN32): name += " %s" % display_name if mode!="tcp": name += " (%s)" % mode ap = MDNSPublishers(f_listen_on.values(), name, text_dict=d) from xpra.scripts.server import add_when_ready, add_cleanup add_when_ready(ap.start) add_cleanup(ap.stop)
if len(data) < width * height * 4: log.warn("Corrupt _NET_WM_ICON") return None except Exception, e: log.warn("Weird corruption in _NET_WM_ICON: %s", e) return None # Cairo wants a native-endian array here, and since the icon is # transmitted as CARDINALs, that's what we get. It might seem more # sensible to use ImageSurface.create_for_data (at least it did to me!) # but then you end up with a surface that refers to the memory you pass in # directly, and also .get_data() doesn't work on it, and it breaks the # test suite and blah. This at least works, as odd as it is: surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) # old versions of cairo do not have this method, just ignore it if not hasattr(surf, "get_data"): log.warn("Your Cairo is too old! Carrying on as best I can, " "but don't expect a miracle") return None surf.get_data()[:] = data # Cairo uses premultiplied alpha. EWMH actually doesn't specify what it # uses, but apparently the de-facto standard is non-premultiplied. (At # least that's what Compiz's sources say.) premultiply_argb_in_place(surf.get_data()) return (width * height, surf) # This returns a cairo ImageSurface which contains the largest icon defined in # a _NET_WM_ICON property. def NetWMIcons(disp, data): icons = [] stream = StringIOClass(data) while True: size_image = _read_image(disp, stream)
import sys from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_NETWORK_DEBUG") has_netifaces = True try: import netifaces # @UnresolvedImport debug("netifaces loaded sucessfully") except Exception, e: has_netifaces = False log.warn("python netifaces package is missing") iface_ipmasks = {} bind_IPs = None def get_interfaces(): if not has_netifaces: return [] return netifaces.interfaces() def get_bind_IPs(): global bind_IPs if not bind_IPs: if has_netifaces: bind_IPs = do_get_bind_IPs()
PIXMAP_RGB_MODES = ["RGB", "RGBX", "RGBA"] INDIRECT_BGR = envbool("XPRA_PIXMAP_INDIRECT_BGR", False) if INDIRECT_BGR: PIXMAP_RGB_MODES += ["BGRX", "BGRA", "BGR"] INTERP_DICT = {"nearest" : gdk.INTERP_NEAREST, "tiles" : gdk.INTERP_TILES, "bilinear" : gdk.INTERP_BILINEAR, "hyper" : gdk.INTERP_HYPER} SCALING_INTERP_STR = os.environ.get("XPRA_SCALING_INTERPOLATION", "HYPER").lower() SCALING_INTERP = INTERP_DICT.get(SCALING_INTERP_STR) if not SCALING_INTERP: log.warn("Warning: invalid interpolation '%s'") log.warn(" supported types: %s", csv(INTERP_DICT.keys())) """ Backing using a gdk.Pixmap """ class PixmapBacking(GTK2WindowBacking): HAS_ALPHA = False RGB_MODES = PIXMAP_RGB_MODES def __repr__(self): return "PixmapBacking(%s)" % self._backing def init(self, ww, wh, bw, bh): #use window size as backing size:
proto.authenticator = self.auth_class(username) except Exception, e: log.warn("error instantiating %s: %s", self.auth_class, e) auth_failed("authentication failed") return False self.digest_modes = c.get("digest", ("hmac", )) #client may have requested encryption: cipher = c.strget("cipher") cipher_iv = c.strget("cipher.iv") key_salt = c.strget("cipher.key_salt") iterations = c.intget("cipher.key_stretch_iterations") auth_caps = {} if cipher and cipher_iv: if cipher not in ENCRYPTION_CIPHERS: log.warn("unsupported cipher: %s", cipher) auth_failed("unsupported cipher") return False encryption_key = self.get_encryption_key(proto.authenticator) if encryption_key is None: auth_failed("encryption key is missing") return False proto.set_cipher_out(cipher, cipher_iv, encryption_key, key_salt, iterations) #use the same cipher as used by the client: auth_caps = new_cipher_caps(proto, cipher, encryption_key) log("server cipher=%s", auth_caps) else: auth_caps = None #verify authentication if required: if proto.authenticator:
# later version. See the file COPYING for details. from cairo import ImageSurface, FORMAT_ARGB32 #pylint: disable=no-name-in-module from gi.repository import GLib #@UnresolvedImport from gi.repository import GdkPixbuf #@UnresolvedImport from xpra.util import envbool from xpra.client.gtk_base.cairo_backing_base import CairoBackingBase, FORMATS from xpra.log import Logger log = Logger("paint", "cairo") try: from xpra.client.gtk3.cairo_workaround import set_image_surface_data, CAIRO_FORMATS #@UnresolvedImport except ImportError as e: log.warn("Warning: failed to load the gtk3 cairo workaround:") log.warn(" %s", e) log.warn(" rendering will be slow!") del e set_image_surface_data = None CAIRO_FORMATS = {} CAIRO_USE_PIXBUF = envbool("XPRA_CAIRO_USE_PIXBUF", False) """ An area we draw onto with cairo This must be used with gtk3 since gtk3 no longer supports gdk pixmaps /RANT: ideally we would want to use pycairo's create_for_data method: #surf = cairo.ImageSurface.create_for_data(data, cairo.FORMAT_RGB24, width, height) but this is disabled in most cases, or does not accept our rowstride, so we cannot use it. Instead we have to use PIL to convert via a PNG or Pixbuf!
return delfile("cannot save fake xinerama settings: incomplete monitor data for monitor: %s" % m) plug_name, x, y, width, height, wmm, hmm = m[:8] data.append("# %s (%smm x %smm)" % (prettify_plug_name(plug_name, "monitor %s" % i), wmm, hmm)) data.append("%s %s %s %s" % (x, y, width, height)) config.append((x, y, width, height)) i += 1 data.append("") contents = "\n".join(data) for filename in xinerama_files: try: f = None try: f = open(filename, 'wb') f.write(contents) except Exception, e: log.warn("error writing fake xinerama file %s: %s", filename, e) pass finally: if f: f.close() log("saved %s monitors to fake xinerama files: %s", len(monitors), xinerama_files) oldconf = self.current_xinerama_config self.current_xinerama_config = config return oldconf!=config def _process_server_settings(self, proto, packet): settings = packet[1] self.update_server_settings(settings) def update_server_settings(self, settings, reset=False):
img = Image.frombuffer("RGB", (w, h), image.get_pixels(), "raw", image.get_pixel_format(), image.get_rowstride()) buf = StringIOClass() img.save(buf, "PNG") data = buf.getvalue() buf.close() return w, h, "png", image.get_rowstride(), data try: import Foundation #@UnresolvedImport import AppKit #@UnresolvedImport import PyObjCTools.AppHelper as AppHelper #@UnresolvedImport NSObject = Foundation.NSObject NSWorkspace = AppKit.NSWorkspace except Exception, e: log.warn("failed to load critical modules for sleep notification support: %s", e) NSObject = object NSWorkspace = None class NotificationHandler(NSObject): """Class that handles the sleep notifications.""" def handleSleepNotification_(self, aNotification): log("handleSleepNotification(%s)", aNotification) if self.sleep_callback: try: self.sleep_callback() except: log.error("Error in sleep callback %s", self.sleep_callback, exc_info=True) def handleWakeNotification_(self, aNotification):
if len(line)==0 or line.startswith("#"): continue debug("line %s: %s", i, line) if line.find("|")<0: #assume old style file with just the password #get all the displays for the current user: sockdir = DotXpra(socket_dir) results = sockdir.sockets() displays = [display for state, display in results if state==DotXpra.LIVE] auth_data[""] = line, os.getuid(), os.getgid(), displays, {}, {} debug("Warning: assuming this is a single password for all users") continue ldata = line.split("|") debug("found %s fields at line %s", len(ldata), i) if len(ldata)<4: log.warn("skipped line %s of %s: not enough fields", i, password_file) continue #parse fields: username = ldata[0] password = ldata[1] def getsysid(s, default_value): if not s: return default_value try: return int(s) except: return default_value uid = getsysid(ldata[2], os.getuid()) gid = getsysid(ldata[3], os.getgid()) displays = ldata[4].split(",") env_options = {}
g.Commit() self.group = g log("dbus service added") except DBusException, e: # use try+except as older versions may not have those modules? message = e.get_dbus_message() dbus_error_name = e.get_dbus_name() if dbus_error_name == "org.freedesktop.Avahi.CollisionError": log.error( "error starting publisher %s: another instance already claims this dbus name: %s, message: %s", self, e, message, ) return log.warn("failed to start %s: %s", self, e) helpmsg() def stop(self): log("%s.stop() group=%s", self, self.group) if self.group: try: self.group.Reset() self.group = None except Exception, e: log.error("error stopping publisher %s: %s", self, e) def main(): import gobject
from xpra.build_info import BUILD_DATE, BUILT_BY, BUILT_ON, BUILD_BIT, BUILD_CPU, \ COMPILER_VERSION, LINKER_VERSION, BUILD_TIME, PYTHON_VERSION, CYTHON_VERSION props.update({ "date" : BUILD_DATE, "time" : BUILD_TIME, "by" : BUILT_BY, "on" : BUILT_ON, "bit" : BUILD_BIT, "cpu" : BUILD_CPU, "compiler" : COMPILER_VERSION, "linker" : LINKER_VERSION, "python" : PYTHON_VERSION, "cython" : CYTHON_VERSION, }) except Exception, e: log.warn("missing some build information: %s", e) return props def do_get_platform_info(): from xpra.os_util import platform_name info = { "" : sys.platform, "name" : platform_name(sys.platform, python_platform.release()), "release" : python_platform.release(), "platform" : python_platform.platform(), "machine" : python_platform.machine(), "processor" : python_platform.processor(), } if sys.platform.startswith("linux") and hasattr(python_platform, "linux_distribution"): info["linux_distribution"] = python_platform.linux_distribution() return info
from xpra.log import Logger log = Logger() from xpra.client.gtk_base.gtk_window_backing_base import GTKWindowBacking from xpra.client.window_backing_base import fire_paint_callbacks from xpra.codecs.loader import has_codec #don't bother trying gtk2 transparency on on MS Windows (not supported): #or on OSX (doesn't work) DEFAULT_HAS_ALPHA = not sys.platform.startswith("win") and not sys.platform.startswith("darwin") HAS_ALPHA = os.environ.get("XPRA_ALPHA", DEFAULT_HAS_ALPHA) in (True, "1") try: #we need argb to un-premultiply alpha: from xpra.codecs.argb.argb import unpremultiply_argb, unpremultiply_argb_in_place, byte_buffer_to_buffer #@UnresolvedImport except: log.warn("argb module is missing, cannot support alpha channels") unpremultiply_argb, unpremultiply_argb_in_place, byte_buffer_to_buffer = None, None, None HAS_ALPHA = False """ This is the gtk2 version. (works much better than gtk3!) Superclass for PixmapBacking and GLBacking """ class GTK2WindowBacking(GTKWindowBacking): def __init__(self, wid, w, h, has_alpha): GTKWindowBacking.__init__(self, wid) self._has_alpha = has_alpha and HAS_ALPHA
PRINTER_ENUM_NAMES[v] = k log("PRINTER_ENUM_VALUES: %s", PRINTER_ENUM_VALUES) PRINTER_LEVEL = int(os.environ.get("XPRA_WIN32_PRINTER_LEVEL", "1")) #DEFAULT_PRINTER_FLAGS = "LOCAL" DEFAULT_PRINTER_FLAGS = "LOCAL,SHARED+NETWORK+CONNECTIONS" PRINTER_FLAGS = [x.strip() for x in os.environ.get("XPRA_WIN32_PRINTER_FLAGS", DEFAULT_PRINTER_FLAGS).split(",")] log("PRINTER_FLAGS=%s", csv(PRINTER_FLAGS)) VALID_PRINTER_FLAGS = ("LOCAL", "SHARED", "CONNECTIONS", "NETWORK", "REMOTE") PRINTER_ENUMS = [] for v in PRINTER_FLAGS: #ie: "SHARED+NETWORK+CONNECTIONS" flags = v.replace('|','+').split("+") #ie: ["SHARED", "NETWORK", "CONNECTIONS"] values = [] for flag in flags: #ie: "SHARED" if flag not in VALID_PRINTER_FLAGS: log.warn("Warning: the following printer flag is invalid and will be ignored: %s", flag) else: values.append(flag) #ie: "SHARED" PRINTER_ENUMS.append(values) log("PRINTER_ENUMS=%s", PRINTER_ENUMS) #emulate pycups job id JOB_ID = 0 PROCESSES = {} GSVIEW_DIR = None GSPRINT_EXE = None GSWIN32C_EXE = None printers_modified_callback = None def init_printing(callback=None):
WHEEL_DELTA = envint("XPRA_WHEEL_DELTA", 120) assert WHEEL_DELTA>0 KNOWN_EVENTS = {} POWER_EVENTS = {} try: for x in dir(win32con): if x.endswith("_EVENT"): v = getattr(win32con, x) KNOWN_EVENTS[v] = x if x.startswith("PBT_"): v = getattr(win32con, x) POWER_EVENTS[v] = x except Exception as e: log.warn("error loading pywin32: %s", e) def do_init(): init_dpi() def init_dpi(): #tell win32 we handle dpi if not DPI_AWARE: screenlog.warn("SetProcessDPIAware not set due to environment override") return try: SetProcessDPIAware = windll.user32.SetProcessDPIAware dpiaware = SetProcessDPIAware() screenlog("SetProcessDPIAware: %s()=%s", SetProcessDPIAware, dpiaware)
def timer_clipboard_check(): global change_count c = change_count change_count = update_change_count() log("timer_clipboard_check() was %s, now %s", c, change_count) if c!=change_count: for x in change_callbacks: try: x() except Exception, e: log("error in change callback %s: %s", x, e) from xpra.platform.ui_thread_watcher import get_UI_watcher w = get_UI_watcher() if w is None: log.warn("no UI watcher available, cannot watch for clipboard events") return False log("UI watcher=%s", w) w.add_alive_callback(timer_clipboard_check) return True class OSXClipboardProtocolHelper(GDKClipboardProtocolHelper): """ Full of OSX quirks! darwin/features.py should be set * CLIPBOARD_GREEDY: request the other end to send tokens for all owner change events * CLIPBOARD_WANT_TARGETS: include targets with the tokens """ def __init__(self, send_packet_cb, progress_cb=None):
(AAC_MPEG4 , "avenc_aac", "mp4mux", "avdec_aac", "qtdemux"), ] MUX_OPTIONS = [ (GDP, "gdppay", "gdpdepay"), (OGG, "oggmux", "oggdemux"), (MKA, "webmmux", "matroskademux"), (MPEG4, "mp4mux", "qtdemux"), ] emux = [x for x in os.environ.get("XPRA_MUXER_OPTIONS", "").split(",") if len(x.strip())>0] if emux: mo = [v for v in MUX_OPTIONS if v[0] in emux] if mo: MUX_OPTIONS = mo else: log.warn("Warning: invalid muxer options %s", emux) del mo del emux #these encoders require an "audioconvert" element: ENCODER_NEEDS_AUDIOCONVERT = ("flacenc", "wavpackenc") #if this is lightweight enough, maybe we should include it unconditionally? SOURCE_NEEDS_AUDIOCONVERT = ("directsoundsrc", "osxaudiosrc", "autoaudiosrc") #options we use to tune for low latency: OGG_DELAY = 20*MS_TO_NS ENCODER_DEFAULT_OPTIONS_COMMON = { "lamemp3enc" : {"encoding-engine-quality": 0}, #"fast" "wavpackenc" : { "mode" : 1, #"fast" (0 aka "very fast" is not supported)
from xpra.x11.bindings.window_bindings import ( constants, #@UnresolvedImport X11WindowBindings, #@UnresolvedImport PropertyError) #@UnresolvedImport X11Window = X11WindowBindings() from xpra.os_util import StringIOClass from xpra.x11.xsettings_prop import set_settings, get_settings from xpra.gtk_common.error import trap, XError from xpra.log import Logger log = Logger("x11", "window") try: from xpra.codecs.argb.argb import premultiply_argb_in_place #@UnresolvedImport except: log.warn("argb module is missing, icon transparency will be incorrect") premultiply_argb_in_place = None import sys if sys.version > '3': long = int #@ReservedAssignment unicode = str #@ReservedAssignment USPosition = constants["USPosition"] PPosition = constants["PPosition"] PMaxSize = constants["PMaxSize"] PMinSize = constants["PMinSize"] PBaseSize = constants["PBaseSize"] PResizeInc = constants["PResizeInc"] PAspect = constants["PAspect"]
if device_type(d)=="GPU": selected_device_cpu_cost = 0 selected_device_gpu_cost = 50 selected_device_setup_cost = 40 else: selected_device_cpu_cost = 100 selected_device_gpu_cost = 0 selected_device_setup_cost = 20 log("device is a %s, using CPU cost=%s, GPU cost=%s", device_type(d), selected_device_cpu_cost, selected_device_gpu_cost) return except Exception, e: log.warn(" failed to use %s", platform_info(p)) log.warn(" with %s device %s", device_type(d), device_info(d)) log.warn(" Error: %s", e) #fallback to pyopencl auto mode: log.warn("OpenCL Error: failed to find a working platform and device combination... trying with pyopencl's 'create_some_context'") context = pyopencl.create_some_context(interactive=False) devices = context.get_info(pyopencl.context_info.DEVICES) log.info("chosen context has %s device(s):", len(devices)) for d in devices: log_device_info(d) assert len(devices)==1, "we only handle a single device at a time, sorry!" selected_device = devices[0] assert context is not None and selected_device is not None #Note: we don't care about alpha! #This tries to map our standard RGB representation #to the channel_order types that OpenCL may support IN_CHANNEL_ORDER = [] #a list of: (string, pyopencl.channel_order)
"OEM_ATTN" : 0xF0, "OEM_FINISH" : 0xF1, "OEM_ENLW" : 0xF4, "OEM_BACKTAB" : 0xF5, "ASCIITILDE" : 65107, #aka 0x00fe53 "DEAD_GRAVE" : 65104, #aka 0x00fe50 } #lookup the constants: KEYCODES = {} for vk, name in VIRTUAL_KEYS.items(): vk_name = "VK_%s" % vk for name, val in DEFS.items(): if hasattr(win32con, vk_name): val = getattr(win32con, vk_name) KEYCODES[name] = val log("KEYCODES[%s]=win32con.%s=%s", name, vk_name, val) elif vk in DEFS: #fallback to our hardcoded definitions: val = DEFS[vk] KEYCODES[name] = val log("KEYCODES[%s]=%s=%s", name, vk, val) else: log.warn("missing key constant: %s", vk_name) for c in "abcdefghijklmnopqrstuvwxyz": KEYCODES[c] = ord(c) KEYCODES[c.upper()] = ord(c.upper()) for c in "0123456789": KEYCODES[c] = ord(c) log("KEYCODES: %s", KEYCODES)
log = Logger("x11", "window") workspacelog = Logger("x11", "window", "workspace") metalog = Logger("x11", "window", "metadata") geomlog = Logger("x11", "window", "geometry") menulog = Logger("x11", "window", "menu") dbus_helper = None MENU_FORWARDING = os.environ.get("XPRA_MENU_FORWARDING", "1")=="1" if MENU_FORWARDING: try: from xpra.dbus.helper import DBusHelper dbus_helper = DBusHelper() from xpra.dbus.gtk_menuactions import query_actions, query_menu, ACTIONS, MENUS except Exception as e: log.warn("Warning: menu forwarding is disabled:") log.warn(" cannot load dbus helper: %s", e) MENU_FORWARDING = False X11Window = X11WindowBindings() #_NET_WM_STATE: _NET_WM_STATE_REMOVE = 0 _NET_WM_STATE_ADD = 1 _NET_WM_STATE_TOGGLE = 2 STATE_STRING = { _NET_WM_STATE_REMOVE : "REMOVE", _NET_WM_STATE_ADD : "ADD", _NET_WM_STATE_TOGGLE : "TOGGLE", }
log("pycups settings: ALLOW=%s", ALLOW) log("pycups settings: FORWARDER_TMPDIR=%s", FORWARDER_TMPDIR) log("pycups settings: SKIPPED_PRINTERS=%s", SKIPPED_PRINTERS) MIMETYPE_TO_PRINTER = {"application/postscript": "Generic PostScript Printer", "application/pdf": "Generic PDF Printer"} MIMETYPE_TO_PPD = {"application/postscript": "CUPS-PDF.ppd", "application/pdf": "Generic-PDF_Printer-PDF.ppd"} DEFAULT_CUPS_OPTIONS = {} dco = os.environ.get("XPRA_DEFAULT_CUPS_OPTIONS", "fit-to-page=True") if dco: for opt in dco.split(","): opt = opt.strip(" ") parts = opt.split("=", 1) if len(parts) != 2: log.warn("Warning: invalid cups option: '%s'", opt) continue # is it a boolean? k, v = parts DEFAULT_CUPS_OPTIONS[k] = v log("DEFAULT_CUPS_OPTIONS=%s", DEFAULT_CUPS_OPTIONS) # allows us to inject the lpadmin and lpinfo commands from the config file def set_lpadmin_command(lpadmin): global LPADMIN LPADMIN = lpadmin def set_lpinfo_command(lpinfo): global LPINFO
except Exception, e: log("lz4 not found: %s", e) LZ4_compress, LZ4_uncompress = None, None has_lz4 = False def lz4_compress(packet, level): raise Exception("lz4 is not supported!") use_lz4 = has_lz4 and os.environ.get("XPRA_USE_LZ4", "1")=="1" rencode_dumps, rencode_loads, rencode_version = None, None, None try: try: from xpra.net.rencode import dumps as rencode_dumps #@UnresolvedImport from xpra.net.rencode import loads as rencode_loads #@UnresolvedImport from xpra.net.rencode import __version__ as rencode_version except ImportError, e: log.warn("rencode import error: %s", e) except Exception, e: log.error("error loading rencode", exc_info=True) has_rencode = rencode_dumps is not None and rencode_loads is not None and rencode_version is not None use_rencode = has_rencode and os.environ.get("XPRA_USE_RENCODER", "1")=="1" log("protocol: has_rencode=%s, use_rencode=%s, version=%s", has_rencode, use_rencode, rencode_version) bencode, bdecode, bencode_version = None, None, None if sys.version_info[0]<3: #bencode needs porting to Python3.. try: try: from xpra.net.bencode import bencode, bdecode, __version__ as bencode_version except ImportError, e: log.warn("bencode import error: %s", e, exc_info=True) except Exception, e:
except Exception, e: log("lz4 not found: %s", e) LZ4_compress, LZ4_uncompress = None, None has_lz4 = False def lz4_compress(packet, level): raise Exception("lz4 is not supported!") use_lz4 = has_lz4 and os.environ.get("XPRA_USE_LZ4", "1")=="1" rencode_dumps, rencode_loads, rencode_version = None, None, None try: try: from xpra.net.rencode import dumps as rencode_dumps #@UnresolvedImport from xpra.net.rencode import loads as rencode_loads #@UnresolvedImport from xpra.net.rencode import __version__ as rencode_version except ImportError, e: log.warn("rencode load error: %s", e) except Exception, e: log.warn("xpra.rencode is missing: %s", e) has_rencode = rencode_dumps is not None and rencode_loads is not None and rencode_version is not None use_rencode = has_rencode and os.environ.get("XPRA_USE_RENCODER", "1")=="1" bencode, bdecode = None, None try: from xpra.net.bencode import bencode, bdecode, __version__ as bencode_version except Exception, e: log.warn("xpra.bencode is missing: %s", e) has_bencode = bencode is not None and bdecode is not None use_bencode = has_bencode and os.environ.get("XPRA_USE_BENCODER", "1")=="1" #stupid python version breakage: