示例#1
0
 def test_distribution_variant(self):
     is_Ubuntu()
     is_Debian()
     is_Raspbian()
     is_Fedora()
     is_Arch()
     is_CentOS()
     is_RedHat()
     is_WSL()
示例#2
0
# later version. See the file COPYING for details.
#pylint: disable-msg=E1101

import os

from xpra.util import engs, envbool
from xpra.os_util import is_Ubuntu, is_Debian
from xpra.log import Logger

log = Logger("webcam")

#on Debian and Ubuntu, the v4l2loopback device is created with exclusive_caps=1,
#so we cannot check the devices caps for the "VIDEO_CAPTURE" flag.
#see https://xpra.org/trac/ticket/1596
CHECK_VIRTUAL_CAPTURE = envbool("XPRA_CHECK_VIRTUAL_CAPTURE",
                                not (is_Ubuntu() or is_Debian()))


def _can_capture_video(dev_file, dev_info):
    if not dev_info:
        return False
    caps = dev_info.get("capabilities", [])
    if "DEVICE_CAPS" in caps:
        caps = dev_info.get("device_caps", [])
    if not "VIDEO_CAPTURE" in caps:
        log("device %s does not support video capture, capabilities=%s",
            dev_file, caps)
        return False
    return True

示例#3
0
# This file is part of Xpra.
# Copyright (C) 2016 Antoine Martin <*****@*****.**>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

import os

from xpra.log import Logger
log = Logger("webcam")
from xpra.util import engs, envbool
from xpra.os_util import is_Ubuntu, is_Debian

#on Debian and Ubuntu, the v4l2loopback device is created with exclusive_caps=1,
#so we cannot check the devices caps for the "VIDEO_CAPTURE" flag.
#see http://xpra.org/trac/ticket/1596
CHECK_VIRTUAL_CAPTURE = envbool("XPRA_CHECK_VIRTUAL_CAPTURE", not (is_Ubuntu() or is_Debian()))


def _can_capture_video(dev_file, dev_info):
    if not dev_info:
        return False
    caps = dev_info.get("capabilities", [])
    if "DEVICE_CAPS" in caps:
        caps = dev_info.get("device_caps", [])
    if not "VIDEO_CAPTURE" in caps:
        log("device %s does not support video capture, capabilities=%s", dev_file, caps)
        return False
    return True

v4l2_virtual_dir = "/sys/devices/virtual/video4linux"
def check_virtual_dir(warn=True):
示例#4
0
def get_defaults():
    global GLOBAL_DEFAULTS
    if GLOBAL_DEFAULTS is not None:
        return GLOBAL_DEFAULTS
    from xpra.platform.features import DEFAULT_SSH_COMMAND, OPEN_COMMAND, DEFAULT_PULSEAUDIO_CONFIGURE_COMMANDS, DEFAULT_PULSEAUDIO_COMMAND, \
                                        DEFAULT_ENV, CAN_DAEMONIZE
    from xpra.platform.paths import get_download_dir, get_remote_run_xpra_scripts
    try:
        from xpra.platform.info import get_username
        username = get_username()
    except:
        username = ""
    conf_dirs = [os.environ.get("XPRA_CONF_DIR")]
    build_root = os.environ.get("RPM_BUILD_ROOT")
    if build_root:
        conf_dirs.append(os.path.join(build_root, "etc", "xpra"))
    xpra_cmd = sys.argv[0]
    bin_dir = None
    if len(sys.argv) > 0:
        for strip in ("/usr/bin", "/bin"):
            pos = xpra_cmd.find(strip)
            if pos >= 0:
                bin_dir = xpra_cmd[:pos + len(strip)]
                root = xpra_cmd[:pos] or "/"
                conf_dirs.append(os.path.join(root, "etc", "xpra"))
                break
    if sys.prefix == "/usr":
        conf_dirs.append("/etc/xpra")
    else:
        conf_dirs.append(os.path.join(sys.prefix, "etc", "xpra"))
    for conf_dir in [x for x in conf_dirs if x]:
        if os.path.exists(conf_dir):
            break
    xvfb = detect_xvfb_command(conf_dir, bin_dir)

    def addtrailingslash(v):
        if v.endswith("/"):
            return v
        return v + "/"

    if WIN32:
        bind_dirs = ["Main"]
    else:
        bind_dirs = ["auto"]

    ssl_protocol = "TLSv1_2"
    if sys.version_info < (2, 7, 9):
        ssl_protocol = "SSLv23"
    from xpra.os_util import is_Debian, is_Ubuntu

    GLOBAL_DEFAULTS = {
        "encoding":
        "",
        "title":
        "@title@ on @client-machine@",
        "username":
        username,
        "password":
        "",
        "auth":
        "",
        "vsock-auth":
        "",
        "tcp-auth":
        "",
        "ssl-auth":
        "",
        "wm-name":
        DEFAULT_NET_WM_NAME,
        "session-name":
        "",
        "dock-icon":
        "",
        "tray-icon":
        "",
        "window-icon":
        "",
        "password-file":
        "",
        "keyboard-raw":
        False,
        "keyboard-layout":
        "",
        "keyboard-layouts": [],
        "keyboard-variant":
        "",
        "keyboard-variants": [],
        "keyboard-options":
        "",
        "clipboard":
        "yes",
        "clipboard-direction":
        "both",
        "clipboard-filter-file":
        "",
        "remote-clipboard":
        "CLIPBOARD",
        "local-clipboard":
        "CLIPBOARD",
        "pulseaudio-command":
        " ".join(DEFAULT_PULSEAUDIO_COMMAND),
        "encryption":
        "",
        "tcp-encryption":
        "",
        "encryption-keyfile":
        "",
        "tcp-encryption-keyfile":
        "",
        "pidfile":
        "",
        "ssh":
        DEFAULT_SSH_COMMAND,
        "systemd-run":
        get_default_systemd_run(),
        "systemd-run-args":
        "",
        "xvfb":
        " ".join(xvfb),
        "socket-dir":
        "",
        "log-dir":
        "auto",
        "log-file":
        "$DISPLAY.log",
        "border":
        "auto,5:off",
        "window-close":
        "auto",
        "max-size":
        "",
        "desktop-scaling":
        "auto",
        "display":
        "",
        "tcp-proxy":
        "",
        "download-path":
        get_download_dir(),
        "open-command":
        OPEN_COMMAND,
        "remote-logging":
        "both",
        "lpadmin":
        "/usr/sbin/lpadmin",
        "lpinfo":
        "/usr/sbin/lpinfo",
        "add-printer-options":
        ["-E", "-o printer-is-shared=false", "-u allow:$USER"],
        "pdf-printer":
        "",
        "postscript-printer":
        DEFAULT_POSTSCRIPT_PRINTER,
        "debug":
        "",
        "input-method":
        "none",
        "sound-source":
        "",
        "html":
        "auto",
        "socket-permissions":
        "600",
        "exec-wrapper":
        "",
        "dbus-launch":
        "dbus-launch --close-stderr",
        "webcam": ["auto", "no"][OSX],
        #ssl options:
        "ssl":
        "auto",
        "ssl-key":
        "",
        "ssl-cert":
        "",
        "ssl-protocol":
        ssl_protocol,
        "ssl-ca-certs":
        "default",
        "ssl-ca-data":
        "",
        "ssl-ciphers":
        "DEFAULT",
        "ssl-client-verify-mode":
        "optional",
        "ssl-server-verify-mode":
        "required",
        "ssl-verify-flags":
        "X509_STRICT",
        "ssl-check-hostname":
        False,
        "ssl-server-hostname":
        "localhost",
        "ssl-options":
        "ALL,NO_COMPRESSION",
        "quality":
        0,
        "min-quality":
        30,
        "speed":
        0,
        "min-speed":
        30,
        "compression_level":
        1,
        "dpi":
        0,
        "video-scaling":
        1,
        "file-size-limit":
        100,
        "idle-timeout":
        0,
        "server-idle-timeout":
        0,
        "sync-xvfb":
        0,
        "auto-refresh-delay":
        0.15,
        "daemon":
        CAN_DAEMONIZE,
        "use-display":
        False,
        "fake-xinerama":
        not OSX and not WIN32 and not is_Debian() and not is_Ubuntu(),
        "resize-display":
        not OSX and not WIN32,
        "tray":
        True,
        "pulseaudio":
        not OSX and not WIN32,
        "dbus-proxy":
        not OSX and not WIN32,
        "mmap": ["no", "yes"][not OSX and not WIN32],
        "mmap-group":
        False,
        "speaker": ["disabled", "on"][has_sound_support()],
        "microphone": ["disabled", "off"][has_sound_support()],
        "readonly":
        False,
        "keyboard-sync":
        True,
        "pings":
        False,
        "cursors":
        True,
        "bell":
        True,
        "notifications":
        True,
        "xsettings":
        not OSX and not WIN32,
        "system-tray":
        True,
        "sharing":
        False,
        "delay-tray":
        False,
        "windows":
        True,
        "exit-with-children":
        False,
        "exit-with-client":
        False,
        "start-after-connect":
        False,
        "start-new-commands":
        False,
        "proxy-start-sessions":
        True,
        "av-sync":
        True,
        "exit-ssh":
        True,
        "dbus-control":
        not WIN32 and not OSX,
        "opengl":
        get_opengl_default(),
        "mdns":
        not WIN32,
        "file-transfer":
        True,
        "printing":
        True,
        "open-files":
        False,
        "swap-keys":
        OSX,  #only used on osx
        "desktop-fullscreen":
        False,
        "global-menus":
        True,
        "pulseaudio-configure-commands":
        [" ".join(x) for x in DEFAULT_PULSEAUDIO_CONFIGURE_COMMANDS],
        "socket-dirs": [],
        "remote-xpra":
        get_remote_run_xpra_scripts(),
        "encodings": ["all"],
        "proxy-video-encoders": [],
        "video-encoders": ["all"],
        "csc-modules": ["all"],
        "video-decoders": ["all"],
        "speaker-codec": [],
        "microphone-codec": [],
        "compressors": ["all"],
        "packet-encoders": ["all"],
        "key-shortcut":
        get_default_key_shortcuts(),
        "bind":
        bind_dirs,
        "bind-vsock": [],
        "bind-tcp": [],
        "bind-ssl": [],
        "start": [],
        "start-child": [],
        "start-after-connect": [],
        "start-child-after-connect": [],
        "start-on-connect": [],
        "start-child-on-connect": [],
        "start-env":
        DEFAULT_ENV,
        "env": [],
    }
    return GLOBAL_DEFAULTS