Skip to content

Commit

Permalink
#1838: make the actual python modules optional, warn if they're missi…
Browse files Browse the repository at this point in the history
…ng and we try to use features that require them

git-svn-id: https://xpra.org/svn/Xpra/trunk@19723 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 26, 2018
1 parent ac724db commit e74cfec
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
19 changes: 14 additions & 5 deletions src/xpra/scripts/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,16 +913,25 @@ def b(v):
return str(v).lower() not in FALSE_OPTIONS
#turn off some server mixins:
from xpra.server import server_features
server_features.notifications = opts.notifications
def impcheck(*modules):
for mod in modules:
try:
__import__("xpra.%s" % mod, {}, {}, [])
except ImportError as e:
log = get_util_logger()
log.warn("Warning: missing %s module", mod)
return False
return True
server_features.notifications = opts.notifications and impcheck("notifications")
server_features.webcam = b(opts.webcam)
server_features.clipboard = b(opts.clipboard)
server_features.audio = b(opts.speaker) or b(opts.microphone)
server_features.clipboard = b(opts.clipboard) and impcheck("clipboard")
server_features.audio = (b(opts.speaker) or b(opts.microphone)) and impcheck("sound")
server_features.av_sync = server_features.audio and b(opts.av_sync)
server_features.fileprint = b(opts.printing) or b(opts.file_transfer)
server_features.mmap = b(opts.mmap)
server_features.input_devices = not opts.readonly
server_features.input_devices = not opts.readonly and impcheck("keyboard")
#server_features.commands = ??
server_features.dbus = opts.dbus_proxy
server_features.dbus = opts.dbus_proxy and impcheck("dbus")
#server_features.encoding = ??
server_features.logging = b(opts.remote_logging)
#server_features.network_state = ??
Expand Down
6 changes: 4 additions & 2 deletions src/xpra/x11/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,10 @@ def reset_focus():
window.raise_window()
window.give_client_focus()
if server_source and modifiers is not None:
focuslog("focus: will set modified mask to %s", modifiers)
server_source.make_keymask_match(modifiers)
make_keymask_match = getattr(server_source, "make_keymask_match", None)
if make_keymask_match:
focuslog("focus: will set modified mask to %s using %s", modifiers, make_keymask_match)
make_keymask_match(modifiers)
self._has_focus = wid

def get_focus(self):
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/x11/x11_server_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
from xpra.os_util import bytestostr
from xpra.server.gtk_server_base import GTKServerBase
from xpra.x11.xkbhelper import clean_keyboard_state
from xpra.x11.server_keyboard_config import KeyboardConfig

ALWAYS_NOTIFY_MOTION = envbool("XPRA_ALWAYS_NOTIFY_MOTION", False)

Expand Down Expand Up @@ -415,6 +414,7 @@ def get_window_info(self, window):


def get_keyboard_config(self, props):
from xpra.x11.server_keyboard_config import KeyboardConfig
keyboard_config = KeyboardConfig()
keyboard_config.enabled = props.boolget("keyboard", True)
keyboard_config.parse_options(props)
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/x11/xkbhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
init_display_source()

from xpra.util import std, csv
from xpra.keyboard.layouts import parse_xkbmap_query
from xpra.gtk_common.error import xsync
from xpra.x11.bindings.keyboard_bindings import X11KeyboardBindings #@UnresolvedImport
X11Keyboard = X11KeyboardBindings()
Expand Down Expand Up @@ -63,6 +62,7 @@ def do_set_keymap(xkbmap_layout, xkbmap_variant, xkbmap_options,
#First we try to use data from setxkbmap -query,
#preferably as structured data:
if xkbmap_query and not xkbmap_query_struct:
from xpra.keyboard.layouts import parse_xkbmap_query
xkbmap_query_struct = parse_xkbmap_query(xkbmap_query)
if xkbmap_query_struct:
log("do_set_keymap using xkbmap_query struct=%s", xkbmap_query_struct)
Expand Down

0 comments on commit e74cfec

Please sign in to comment.