Ejemplo n.º 1
0
def get_info():
    info = {}
    from xpra.util import updict
    updict(info, "pulseaudio", {
            "wrapper": "palib",
            "id"     : get_pulse_id(),
            "server" : get_pulse_server(),
           })
    try:
        c = PALibContext()
        with c:
            l = c.context.pulse_server_info()
            for v in l:
                updict(info, "pulseaudio", v)
    except Exception as e:
        log.error("error accessing pulse server: %s", e)
    i = 0
    for monitors in (True, False):
        for io in (True, False):
            devices = get_pa_device_options(monitors, io, log_errors=False)
            for d,name in devices.items():
                info["device.%s" % d] = name
            i += 1
    info["devices"] = i
    return info
Ejemplo n.º 2
0
def get_host_info():
    #this function is for non UI thread info
    info = {}
    try:
        import socket
        info.update({
            "pid": os.getpid(),
            "byteorder": sys.byteorder,
            "hostname": socket.gethostname()
        })
        import struct
        bits = struct.calcsize("P") * 8
        updict(
            info, "python", {
                "bits": bits,
                "full_version": sys.version,
                "version": ".".join(str(x) for x in sys.version_info[:3]),
            })
    except:
        pass
    for x in ("uid", "gid"):
        if hasattr(os, "get%s" % x):
            try:
                info[x] = getattr(os, "get%s" % x)()
            except:
                pass
    return info
Ejemplo n.º 3
0
def get_version_info_full():
    props = get_version_info()
    try:
        from xpra import build_info
        #rename these build info properties:
        for k,bk in {
                    "date"                 : "BUILD_DATE",
                    "time"                 : "BUILD_TIME",
                    "by"                   : "BUILT_ON",
                    "bit"                  : "BUILD_BIT",
                    "cpu"                  : "BUILD_CPU",
                    "compiler"             : "COMPILER_VERSION",
                    "nvcc"                 : "NVCC_VERSION",
                    "linker"               : "LINKER_VERSION",
                    "python"               : "PYTHON_VERSION",
                    "cython"               : "CYTHON_VERSION",
                  }.items():
            v = getattr(build_info, bk, None)
            if v:
                props[k] = v
        #record library versions:
        d = dict((k.lstrip("lib_"), getattr(build_info, k)) for k in dir(build_info) if k.startswith("lib_"))
        updict(props, "lib", d)
    except Exception as e:
        log.warn("missing some build information: %s", e)
    log("get_version_info_full()=%s", props)
    return props
Ejemplo n.º 4
0
 def do_get_info(self, proto, *args):
     info = ServerBase.do_get_info(self, proto, *args)
     updict(info, "server", get_gtk_version_info())
     info.update({
                  "server.type"      : "Python/gtk-x11",
                  "features.randr"   : self.randr})
     return info
Ejemplo n.º 5
0
 def send_hello(self, server_source, root_w, root_h, key_repeat, server_cipher):
     capabilities = self.make_hello(server_source)
     if server_source.wants_encodings:
         updict(capabilities, "encoding", codec_versions, "version")
         for k,v in self.get_encoding_info().items():
             if k=="":
                 k = "encodings"
             else:
                 k = "encodings.%s" % k
             capabilities[k] = v
     if server_source.wants_display:
         capabilities.update({
                      "actual_desktop_size"  : (root_w, root_h),
                      "root_window_size"     : (root_w, root_h),
                      "desktop_size"         : self._get_desktop_size_capability(server_source, root_w, root_h),
                      })
     if key_repeat:
         capabilities.update({
                  "key_repeat"           : key_repeat,
                  "key_repeat_modifiers" : True})
     if self._reverse_aliases and server_source.wants_aliases:
         capabilities["aliases"] = self._reverse_aliases
     if server_cipher:
         capabilities.update(server_cipher)
     server_source.send_hello(capabilities)
Ejemplo n.º 6
0
def get_info():
    info = {}
    from xpra.util import updict
    updict(info, "pulseaudio", {
        "wrapper": "palib",
        "id": get_pulse_id(),
        "server": get_pulse_server(),
    })
    try:
        c = PALibContext()
        with c:
            l = c.context.pulse_server_info()
            for v in l:
                updict(info, "pulseaudio", v)
    except Exception as e:
        log.error("error accessing pulse server: %s", e)
    i = 0
    for monitors in (True, False):
        for io in (True, False):
            devices = get_pa_device_options(monitors, io, log_errors=False)
            for d, name in devices.items():
                info["device.%s" % d] = name
            i += 1
    info["devices"] = i
    return info
Ejemplo n.º 7
0
 def send_hello(self, server_source, root_w, root_h, server_cipher):
     capabilities = self.make_hello(server_source)
     if server_source.wants_encodings:
         try:
             from xpra.codecs.loader import codec_versions
         except ImportError:
             log("no codecs", exc_info=True)
         else:
             updict(capabilities, "encoding", codec_versions, "version")
             for k, v in self.get_encoding_info().items():
                 if k == "":
                     k = "encodings"
                 else:
                     k = "encodings.%s" % k
                 capabilities[k] = v
     if server_source.wants_display:
         capabilities.update({
             "actual_desktop_size": (root_w, root_h),
             "root_window_size": (root_w, root_h),
         })
     if self._reverse_aliases and server_source.wants_aliases:
         capabilities["aliases"] = self._reverse_aliases
     if server_cipher:
         capabilities.update(server_cipher)
     server_source.send_hello(capabilities)
Ejemplo n.º 8
0
def get_info_base():
    def fname(v):
        try:
            return v.__name__
        except:
            return str(v)

    def fnames(l):
        return [fname(x) for x in l]

    info = {
        "native_tray_menu_helpers":
        fnames(get_native_tray_menu_helper_classes()),
        "native_trays": fnames(get_native_tray_classes()),
        "native_system_trays": fnames(get_native_system_tray_classes()),
        "system_bell": fname(system_bell),
        "native_notifiers": fnames(get_native_notifier_classes()),
        "workarea": get_workarea() or "",
        "workareas": get_workareas(),
        "desktops": get_number_of_desktops(),
        "desktop_names": get_desktop_names(),
        "vertical-refresh": get_vrefresh(),
        "double_click.time": get_double_click_time(),
        "double_click.distance": get_double_click_distance(),
        "fixed_cursor_size": get_fixed_cursor_size(),
        "dpi": get_dpi(),
        "dpi.x": get_xdpi(),
        "dpi.y": get_ydpi(),
        "icon_size": get_icon_size(),
    }
    from xpra.util import updict
    updict(info, "antialias", get_antialias_info())
    updict(info, "window_frame", get_window_frame_sizes())
    return info
Ejemplo n.º 9
0
def get_info_base():
    def fname(v):
        try:
            return v.__name__
        except:
            return str(v)

    def fnames(l):
        return [fname(x) for x in l]

    info = {
        "native_tray_menu_helpers": fnames(get_native_tray_menu_helper_classes()),
        "native_trays": fnames(get_native_tray_classes()),
        "native_system_trays": fnames(get_native_system_tray_classes()),
        "system_bell": fname(system_bell),
        "native_notifiers": fnames(get_native_notifier_classes()),
        "workarea": get_workarea() or "",
        "workareas": get_workareas(),
        "desktops": get_number_of_desktops(),
        "desktop_names": get_desktop_names(),
        "vertical-refresh": get_vrefresh(),
        "double_click.time": get_double_click_time(),
        "double_click.distance": get_double_click_distance(),
        "fixed_cursor_size": get_fixed_cursor_size(),
        "cursor_size": get_cursor_size(),
        "dpi.x": get_xdpi(),
        "dpi.y": get_ydpi(),
        "icon_size": get_icon_size(),
    }
    from xpra.util import updict

    updict(info, "antialias", get_antialias_info())
    updict(info, "window_frame", get_window_frame_sizes())
    return info
Ejemplo n.º 10
0
def get_version_info_full():
    props = get_version_info()
    try:
        from xpra import build_info
        #rename these build info properties:
        for k, bk in {
                "date": "BUILD_DATE",
                "time": "BUILD_TIME",
                "by": "BUILT_ON",
                "bit": "BUILD_BIT",
                "cpu": "BUILD_CPU",
                "compiler": "COMPILER_VERSION",
                "nvcc": "NVCC_VERSION",
                "linker": "LINKER_VERSION",
                "python": "PYTHON_VERSION",
                "cython": "CYTHON_VERSION",
        }.items():
            v = getattr(build_info, bk, None)
            if v:
                props[k] = v
        #record library versions:
        d = dict((k.lstrip("lib_"), getattr(build_info, k))
                 for k in dir(build_info) if k.startswith("lib_"))
        updict(props, "lib", d)
    except Exception as e:
        log.warn("missing some build information: %s", e)
    log("get_version_info_full()=%s", props)
    return props
Ejemplo n.º 11
0
 def add_encoding_caps(d):
     updict(d, "encoding", codec_versions, "version")
     for k, v in self.get_encoding_info().items():
         if k == "":
             k = "encodings"
         else:
             k = "encodings.%s" % k
         d[k] = v
Ejemplo n.º 12
0
 def test_updict(self):
     d1 = {"foo": "bar"}
     d2 = {"hello": "world", 1: 2}
     d = {}
     updict(d, "d1", d1)
     self.assertEqual(d.get("d1.foo"), "bar")
     self.assertIsNone(d.get("d2"))
     updict(d, "d2", d2)
     self.assertEqual(d.get("d2.1"), 2)
Ejemplo n.º 13
0
 def get_info(self):
     iv = list(self._proc_info)
     info = {"children"          : len(iv),
             "children.dead"     : len([x for x in iv if x.dead]),
             "children.ignored"  : len([x for x in iv if x.ignore])}
     pi = sorted(self._proc_info, key=lambda x: x.pid, reverse=True)
     for i, procinfo in enumerate(pi):
         d = dict((k,getattr(procinfo,k)) for k in ("name", "command", "ignore", "forget", "returncode", "dead", "pid"))
         updict(info, "child[%i]" % i, d)
     return info
Ejemplo n.º 14
0
 def get_info(self):
     iv = list(self._proc_info)
     info = {"children"          : len(iv),
             "children.dead"     : len([x for x in iv if x.dead]),
             "children.ignored"  : len([x for x in iv if x.ignore])}
     pi = sorted(self._proc_info, key=lambda x: x.pid, reverse=True)
     for i, procinfo in enumerate(pi):
         d = dict((k,getattr(procinfo,k)) for k in ("name", "command", "ignore", "forget", "returncode", "dead", "pid"))
         updict(info, "child[%i]" % i, d)
     return info
Ejemplo n.º 15
0
 def get_caps(self) -> dict:
     caps = {
         "encodings"                 : self.get_encodings(),
         "encodings.core"            : self.get_core_encodings(),
         "encodings.window-icon"     : self.get_window_icon_encodings(),
         "encodings.cursor"          : self.get_cursor_encodings(),
         "encodings.packet"          : True,
         }
     updict(caps, "batch",           self.get_batch_caps())
     updict(caps, "encoding",        self.get_encodings_caps())
     return caps
Ejemplo n.º 16
0
 def get_caps(self):
     caps = {
         #legacy (not needed in 1.0 - can be dropped soon):
         "generic-rgb-encodings": True,
         "encodings": self.get_encodings(),
         "encodings.core": self.get_core_encodings(),
         "encodings.window-icon": self.get_window_icon_encodings(),
         "encodings.cursor": self.get_cursor_encodings(),
     }
     updict(caps, "batch", self.get_batch_caps())
     updict(caps, "encoding", self.get_encodings_caps())
     return caps
Ejemplo n.º 17
0
 def get_info(self):
     info = SoundPipeline.get_info(self)
     if QUEUE_TIME>0:
         clt = self.queue.get_property("current-level-time")
         updict(info, "queue", {
             "time"          : int(QUEUE_TIME/MS_TO_NS),
             "min_time"      : int(QUEUE_MIN_TIME/MS_TO_NS),
             "used_pct"      : int(min(QUEUE_TIME, clt)*100.0/QUEUE_TIME),
             "used"          : int(clt/MS_TO_NS),
             "overruns"      : self.overruns,
             "state"         : self.queue_state})
     return info
Ejemplo n.º 18
0
 def do_get_info(self, proto, *args):
     info = ServerBase.do_get_info(self, proto, *args)
     ss = self._server_sources.get(proto)
     updict(
         info, "server",
         get_gtk_version_info(
             new_namespace=(ss is not None) and ss.namespace))
     info.update({
         "server.type": "Python/gtk-x11",
         "features.randr": self.randr
     })
     return info
Ejemplo n.º 19
0
 def make_hello(self, source):
     capabilities = super().make_hello(source)
     if source.wants_features:
         capabilities.update({
                              "pointer.grabs"    : True,
                              "desktop"          : True,
                              })
         updict(capabilities, "window", {
             "decorations"            : True,
             "states"                 : ["iconified", "focused"],
             })
         capabilities["screen_sizes"] = get_screen_sizes()
     return capabilities
Ejemplo n.º 20
0
 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
Ejemplo n.º 21
0
 def make_hello(self, source):
     capabilities = X11ServerBase.make_hello(self, source)
     if source.wants_features:
         capabilities.update({
                              "pointer.grabs"    : True,
                              "desktop"          : True,
                              })
         updict(capabilities, "window", {
             "decorations"            : True,
             "resize-counter"         : True,
             "configure.skip-geometry": True,
             "configure.pointer"      : True,
             })
     return capabilities
Ejemplo n.º 22
0
 def make_hello(self, source):
     capabilities = X11ServerBase.make_hello(self, source)
     if source.wants_features:
         capabilities.update({
                              "pointer.grabs"    : True,
                              "desktop"          : True,
                              })
         updict(capabilities, "window", {
             "decorations"            : True,
             "resize-counter"         : True,
             "configure.skip-geometry": True,
             "configure.pointer"      : True,
             })
     return capabilities
Ejemplo n.º 23
0
 def get_info(self):
     info = SoundPipeline.get_info(self)
     if QUEUE_TIME>0:
         clt = self.queue.get_property("current-level-time")
         qmax = self.queue.get_property("max-size-time")
         qmin = self.queue.get_property("min-threshold-time")
         updict(info, "queue", {
             "min"           : qmin//MS_TO_NS,
             "max"           : qmax//MS_TO_NS,
             "cur"           : clt//MS_TO_NS,
             "pct"           : min(QUEUE_TIME, clt)*100//qmax,
             "overruns"      : self.overruns,
             "underruns"     : self.underruns,
             "state"         : self.queue_state})
     return info
Ejemplo n.º 24
0
 def get_info(self, alias_info=True):
     info = {
         "input.packetcount": self.input_packetcount,
         "input.raw_packetcount": self.input_raw_packetcount,
         "input.cipher": self.cipher_in_name or "",
         "input.cipher.padding": self.cipher_in_padding,
         "output.packetcount": self.output_packetcount,
         "output.raw_packetcount": self.output_raw_packetcount,
         "output.cipher": self.cipher_out_name or "",
         "output.cipher.padding": self.cipher_out_padding,
         "large_packets": self.large_packets,
         "compression_level": self.compression_level,
         "max_packet_size": self.max_packet_size
     }
     updict(info, "input.count", self.input_stats)
     updict(info, "output.count", self.output_stats)
     c = self._compress
     if c:
         info["compressor"] = compression.get_compressor_name(
             self._compress)
     e = self._encoder
     if e:
         if self._encoder == self.noencode:
             info["encoder"] = "noencode"
         else:
             info["encoder"] = packet_encoding.get_encoder_name(
                 self._encoder)
     if alias_info:
         for k, v in self.send_aliases.items():
             info["send_alias." + str(k)] = v
             info["send_alias." + str(v)] = k
         for k, v in self.receive_aliases.items():
             info["receive_alias." + str(k)] = v
             info["receive_alias." + str(v)] = k
     c = self._conn
     if c:
         try:
             info.update(self._conn.get_info())
         except:
             log.error("error collecting connection information on %s",
                       self._conn,
                       exc_info=True)
     info["has_more"] = self._source_has_more.is_set()
     for t in (self._write_thread, self._read_thread,
               self._read_parser_thread, self._write_format_thread):
         if t:
             info["thread.%s" % t.name] = t.is_alive()
     return info
Ejemplo n.º 25
0
 def get_info(self):
     d = Connection.get_info(self)
     try:
         d["type"] = "socket"
         s = self._socket
         if s:
             from xpra.util import updict
             updict(d, "socket", {
                     "fileno"        : s.fileno(),
                     "timeout"       : int(1000*(s.gettimeout() or 0)),
                     "family"        : s.family,
                     "proto"         : s.proto,
                     "type"          : s.type})
     except:
         log.warn("failed to get socket information", exc_info=True)
     return d
Ejemplo n.º 26
0
 def make_hello(self, source):
     capabilities = X11ServerBase.make_hello(self, source)
     if source.wants_features:
         capabilities.update({
             "pointer.grabs": True,
             "desktop": True,
         })
         updict(
             capabilities, "window", {
                 "decorations": True,
                 "resize-counter": True,
                 "configure.skip-geometry": True,
                 "configure.pointer": True,
                 "states": ["iconified", "focused"],
             })
         capabilities["screen_sizes"] = get_screen_sizes()
     return capabilities
Ejemplo n.º 27
0
 def get_info(self):
     info = SoundPipeline.get_info(self)
     if QUEUE_TIME > 0:
         clt = self.queue.get_property("current-level-time")
         updict(
             info,
             "queue",
             {
                 "time": int(QUEUE_TIME / MS_TO_NS),
                 "min_time": int(QUEUE_MIN_TIME / MS_TO_NS),
                 "used_pct": int(min(QUEUE_TIME, clt) * 100.0 / QUEUE_TIME),
                 "used": int(clt / MS_TO_NS),
                 "overruns": self.overruns,
                 "state": self.queue_state,
             },
         )
     return info
Ejemplo n.º 28
0
 def filter_caps(self, caps, prefixes):
     #removes caps that the proxy overrides / does not use:
     pcaps = {}
     removed = []
     for k in caps.keys():
         if any(e for e in prefixes if bytestostr(k).startswith(e)):
             removed.append(k)
         else:
             pcaps[k] = caps[k]
     log("filtered out %s matching %s", removed, prefixes)
     #replace the network caps with the proxy's own:
     pcaps.update(flatten_dict(get_network_caps()))
     #then add the proxy info:
     updict(pcaps, "proxy", get_server_info(), flatten_dicts=True)
     pcaps["proxy"] = True
     pcaps["proxy.hostname"] = socket.gethostname()
     return pcaps
Ejemplo n.º 29
0
 def get_caps(self):
     return updict({}, "notifications", {
         "":
         self.client_supports_notifications,
         "close":
         self.client_supports_notifications,
         "actions":
         self.client_supports_notifications and self.notifier
         and self.notifier.handles_actions,
     })
Ejemplo n.º 30
0
 def filter_caps(self, caps, prefixes):
     #removes caps that the proxy overrides / does not use:
     #(not very pythonic!)
     pcaps = {}
     removed = []
     for k in caps.keys():
         skip = len([e for e in prefixes if k.startswith(e)])
         if skip == 0:
             pcaps[k] = caps[k]
         else:
             removed.append(k)
     log("filtered out %s matching %s", removed, prefixes)
     #replace the network caps with the proxy's own:
     pcaps.update(get_network_caps())
     #then add the proxy info:
     updict(pcaps, "proxy", get_server_info())
     pcaps["proxy"] = True
     pcaps["proxy.hostname"] = socket.gethostname()
     return pcaps
Ejemplo n.º 31
0
 def filter_caps(self, caps, prefixes):
     #removes caps that the proxy overrides / does not use:
     #(not very pythonic!)
     pcaps = {}
     removed = []
     for k in caps.keys():
         skip = len([e for e in prefixes if k.startswith(e)])
         if skip==0:
             pcaps[k] = caps[k]
         else:
             removed.append(k)
     log("filtered out %s matching %s", removed, prefixes)
     #replace the network caps with the proxy's own:
     pcaps.update(get_network_caps())
     #then add the proxy info:
     updict(pcaps, "proxy", get_server_info())
     pcaps["proxy"] = True
     pcaps["proxy.hostname"] = socket.gethostname()
     return pcaps
Ejemplo n.º 32
0
 def get_info(self, alias_info=True):
     info = {
         "input.packetcount"     : self.input_packetcount,
         "input.raw_packetcount" : self.input_raw_packetcount,
         "input.cipher"          : self.cipher_in_name or "",
         "input.cipher.padding"  : self.cipher_in_padding,
         "output.packetcount"    : self.output_packetcount,
         "output.raw_packetcount": self.output_raw_packetcount,
         "output.cipher"         : self.cipher_out_name or "",
         "output.cipher.padding" : self.cipher_out_padding,
         "large_packets"         : self.large_packets,
         "compression_level"     : self.compression_level,
         "max_packet_size"       : self.max_packet_size}
     updict(info, "input.count", self.input_stats)
     updict(info, "output.count", self.output_stats)
     c = self._compress
     if c:
         info["compressor"] = compression.get_compressor_name(self._compress)
     e = self._encoder
     if e:
         if self._encoder==self.noencode:
             info["encoder"] = "noencode"
         else:
             info["encoder"] = packet_encoding.get_encoder_name(self._encoder)
     if alias_info:
         for k,v in self.send_aliases.items():
             info["send_alias." + str(k)] = v
             info["send_alias." + str(v)] = k
         for k,v in self.receive_aliases.items():
             info["receive_alias." + str(k)] = v
             info["receive_alias." + str(v)] = k
     c = self._conn
     if c:
         try:
             info.update(self._conn.get_info())
         except:
             log.error("error collecting connection information on %s", self._conn, exc_info=True)
     info["has_more"] = self._source_has_more.is_set()
     for t in (self._write_thread, self._read_thread, self._read_parser_thread, self._write_format_thread):
         if t:
             info["thread.%s" % t.name] = t.is_alive()
     return info
Ejemplo n.º 33
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
Ejemplo n.º 34
0
def get_info():
    global selected_device, selected_platform, context, KERNELS_DEFS
    info = {
            "version.cl_header"     : pyopencl.get_cl_header_version(),
            "opengl"                : pyopencl.have_gl(),
            #"kernels"               : KERNELS_DEFS.keys()
            }
    updict(info, "pyopencl", get_pyopencl_info())
    if selected_platform:
        updict(info, "platform", {
            "name"          : selected_platform.name,
            "vendor"        : selected_platform.vendor,
            "devices"       : len(selected_platform.get_devices()),
            })
    if selected_device:
        if hasattr(selected_device, "opencl_c_version"):
            info["device.opencl_c_version"] = getattr(selected_device, "opencl_c_version")
        updict(info, "device", {
            "type"                      : device_type(selected_device),
            "name"                      : selected_device.name.strip(),
            "version"                   : selected_device.version,
            "max_work_group_size"       : selected_device.max_work_group_size,
            "max_work_item_dimensions"  : selected_device.max_work_item_dimensions,
            "max_work_item_sizes"       : selected_device.max_work_item_sizes,
            "max-size"                  : selected_device_max_size})
    return info
Ejemplo n.º 35
0
 def get_sys_info():
     from xpra.platform.info import get_user_info
     from xpra.scripts.config import read_xpra_defaults
     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
Ejemplo n.º 36
0
def get_host_info():
    # this function is for non UI thread info
    info = {}
    try:
        import socket

        info.update({"pid": os.getpid(), "byteorder": sys.byteorder, "hostname": socket.gethostname()})
        import struct

        bits = struct.calcsize("P") * 8
        updict(
            info,
            "python",
            {"bits": bits, "full_version": sys.version, "version": ".".join(str(x) for x in sys.version_info[:3])},
        )
    except:
        pass
    for x in ("uid", "gid"):
        if hasattr(os, "get%s" % x):
            try:
                info[x] = getattr(os, "get%s" % x)()
            except:
                pass
    return info
Ejemplo n.º 37
0
 def test_updict(self):
     d1 = {"foo": "bar"}
     d2 = {"hello": "world", 1: 2}
     d = {}
     updict(d, "d1", d1)
     self.assertEqual(d.get("d1.foo"), "bar")
     self.assertIsNone(d.get("d2"))
     updict(d, "d2", d2)
     self.assertEqual(d.get("d2.1"), 2)
     d3 = {
         "moo": "cow",
     }
     updict(d, "d3", d3, "hat")
     self.assertEqual(d.get("d3.moo.hat"), "cow")
Ejemplo n.º 38
0
 def make_hello(self):
     capabilities = UIXpraClient.make_hello(self)
     capabilities["named_cursors"] = len(cursor_types) > 0
     capabilities.update(flatten_dict(get_gtk_version_info()))
     #tell the server which icons GTK can use
     #so it knows when it should supply one as fallback
     it = icon_theme_get_default()
     #this would add our bundled icon directory
     #to the search path, but I don't think we have
     #any extra icons that matter in there:
     #from xpra.platform.paths import get_icon_dir
     #d = get_icon_dir()
     #if d not in it.get_search_path():
     #    it.append_search_path(d)
     #    it.rescan_if_needed()
     log("default icon theme: %s", it)
     log("icon search path: %s", it.get_search_path())
     log("contexts: %s", it.list_contexts())
     icons = []
     for context in it.list_contexts():
         icons += it.list_icons(context)
     log("icons: %s", icons)
     capabilities["theme.default.icons"] = list(set(icons))
     if METADATA_SUPPORTED:
         ms = [x.strip() for x in METADATA_SUPPORTED.split(",")]
     else:
         #this is currently unused, and slightly redundant because of metadata.supported below:
         capabilities["window.states"] = [
             "fullscreen", "maximized", "sticky", "above", "below",
             "shaded", "iconified", "skip-taskbar", "skip-pager"
         ]
         ms = list(DEFAULT_METADATA_SUPPORTED)
         #added in 0.15:
         ms += [
             "command", "workspace", "above", "below", "sticky",
             "set-initial-position"
         ]  #0.17
     if os.name == "posix":
         #this is only really supported on X11, but posix is easier to check for..
         #"strut" and maybe even "fullscreen-monitors" could also be supported on other platforms I guess
         ms += [
             "shaded", "bypass-compositor", "strut", "fullscreen-monitors"
         ]
     if HAS_X11_BINDINGS:
         ms += ["shape"]
     if self._set_window_menu:
         ms += ["menu"]
     #figure out if we can handle the "global menu" stuff:
     if os.name == "posix" and not sys.platform.startswith("darwin"):
         try:
             from xpra.dbus.helper import DBusHelper
             assert DBusHelper
         except:
             pass
     log("metadata.supported: %s", ms)
     capabilities["metadata.supported"] = ms
     #we need the bindings to support initiate-moveresize (posix only for now):
     updict(
         capabilities, "window", {
             "initiate-moveresize": HAS_X11_BINDINGS,
             "configure.pointer": True,
             "frame_sizes": self.get_window_frame_sizes()
         })
     from xpra.client.window_backing_base import DELTA_BUCKETS
     updict(
         capabilities,
         "encoding",
         {
             "icons.greedy":
             True,  #we don't set a default window icon any more
             "icons.size": (64, 64),  #size we want
             "icons.max_size": (128, 128),  #limit
             "delta_buckets": DELTA_BUCKETS,
         })
     return capabilities
Ejemplo n.º 39
0
 def get_caps(self) -> dict:
     d = {}
     updict(d, "av-sync", self.get_avsync_capabilities())
     updict(d, "sound", self.get_audio_capabilities())
     return d
Ejemplo n.º 40
0
 def up(prefix, d):
     updict(capabilities, prefix, d)
Ejemplo n.º 41
0
 def up(prefix, d):
     updict(capabilities, prefix, d)
Ejemplo n.º 42
0
 def up(prefix, d):
     updict(info, prefix, d)
Ejemplo n.º 43
0
 def upp(d):
     updict(info, "proxy", d)
Ejemplo n.º 44
0
 def make_hello(self):
     capabilities = UIXpraClient.make_hello(self)
     capabilities["named_cursors"] = len(cursor_types)>0
     capabilities.update(get_gtk_version_info())
     #tell the server which icons GTK can use
     #so it knows when it should supply one as fallback
     it = icon_theme_get_default()
     #this would add our bundled icon directory
     #to the search path, but I don't think we have
     #any extra icons that matter in there:
     #from xpra.platform.paths import get_icon_dir
     #d = get_icon_dir()
     #if d not in it.get_search_path():
     #    it.append_search_path(d)
     #    it.rescan_if_needed()
     log("default icon theme: %s", it)
     log("icon search path: %s", it.get_search_path())
     log("contexts: %s", it.list_contexts())
     icons = []
     for context in it.list_contexts():
         icons += it.list_icons(context)
     log("icons: %s", icons)
     capabilities["theme.default.icons"] = list(set(icons))
     if METADATA_SUPPORTED:
         ms = [x.strip() for x in METADATA_SUPPORTED.split(",")]
     else:
         #this is currently unused, and slightly redundant because of metadata.supported below:
         capabilities["window.states"] = ["fullscreen", "maximized", "sticky", "above", "below", "shaded", "iconified", "skip-taskbar", "skip-pager"]
         ms = list(DEFAULT_METADATA_SUPPORTED)
         #added in 0.15:
         ms += ["command", "workspace", "above", "below", "sticky"]
     if os.name=="posix":
         #this is only really supported on X11, but posix is easier to check for..
         #"strut" and maybe even "fullscreen-monitors" could also be supported on other platforms I guess
         ms += ["shaded", "bypass-compositor", "strut", "fullscreen-monitors"]
     if HAS_X11_BINDINGS:
         ms += ["shape"]
     if self._set_window_menu:
         ms += ["menu"]
     #figure out if we can handle the "global menu" stuff:
     if os.name=="posix" and not sys.platform.startswith("darwin"):
         try:
             from xpra.dbus.helper import DBusHelper
             assert DBusHelper
         except:
             pass
     log("metadata.supported: %s", ms)
     capabilities["metadata.supported"] = ms
     #we need the bindings to support initiate-moveresize (posix only for now):
     updict(capabilities, "window", {
            "initiate-moveresize"    : HAS_X11_BINDINGS,
            "configure.pointer"      : True,
            "frame_sizes"            : self.get_window_frame_sizes()
            })
     from xpra.client.window_backing_base import DELTA_BUCKETS
     updict(capabilities, "encoding", {
                 "icons.greedy"      : True,         #we don't set a default window icon any more
                 "icons.size"        : (64, 64),     #size we want
                 "icons.max_size"    : (128, 128),   #limit
                 "delta_buckets"     : DELTA_BUCKETS,
                 })
     return capabilities