[X2go-Commits] python-x2go.git - master (branch) updated: 0.1.1.4-250-g0294d5b

X2Go dev team git-admin at x2go.org
Mon May 28 16:08:32 CEST 2012


The branch, master has been updated
       via  0294d5b5fdd1174f63271dab28f7149df8d8c891 (commit)
       via  b4a9e5f4921f5713fb71acf692f1ae73ec843666 (commit)
       via  86aa11e89f7d667813ddadd61209466c57b843d7 (commit)
      from  476c6f3d70767ca3d4fe3fe98064427d47e46d92 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0294d5b5fdd1174f63271dab28f7149df8d8c891
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Mon May 28 16:08:27 2012 +0200

    Add new session profile parameter: ,,variant''. Add support to set the keyboard layout _and_ the keyboard variant from the client-side.

commit b4a9e5f4921f5713fb71acf692f1ae73ec843666
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Mon May 28 16:06:23 2012 +0200

    drop experimental keyboard setting code

commit 86aa11e89f7d667813ddadd61209466c57b843d7
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Mon May 28 16:05:04 2012 +0200

    Add support for re-registering sessions after session profile changes.

-----------------------------------------------------------------------

Summary of changes:
 debian/changelog                  |    3 ++
 x2go/backends/proxy/_nx3.py       |   40 ------------------------
 x2go/backends/terminal/_stdout.py |   60 ++++++++++++++++++++++++++++++-------
 x2go/client.py                    |    8 ++++-
 x2go/defaults.py                  |    2 +-
 x2go/registry.py                  |   12 +++++--
 x2go/session.py                   |    2 +-
 x2go/utils.py                     |    6 ++++
 8 files changed, 74 insertions(+), 59 deletions(-)

The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index 3e16857..fc3d676 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -135,6 +135,9 @@ python-x2go (0.1.2.0-0~x2go1) UNRELEASED; urgency=low
       and make the notifiable via hooks.
     - Properly set setkbd value for x2gostartagent and x2goresume-session.
     - Fix local folder sharing when the master session changes during runtime.
+    - Add support for re-registering sessions after session profile changes.
+    - Add new session profile parameter: ,,variant''. Add support to set the
+      keyboard layout _and_ the keyboard variant from the client-side.
   * Depend on python-xlib.
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Sat, 28 Sep 2012 01:44:21 +0100
diff --git a/x2go/backends/proxy/_nx3.py b/x2go/backends/proxy/_nx3.py
index 7005178..271f318 100644
--- a/x2go/backends/proxy/_nx3.py
+++ b/x2go/backends/proxy/_nx3.py
@@ -116,46 +116,6 @@ class X2goProxyNX3(base.X2goProxyBASE):
 
     def process_proxy_options(self):
 
-        if self.proxy_options.has_key('defkeymap') and self.proxy_options['defkeymap']:
-
-            # first: draw in xkb_rules_names from xprop output
-            xkb_rules_names = utils.xkb_rules_names()
-            _proxy_options = {
-                'xkbrules': xkb_rules_names['rules'],
-                'xkbmodel': xkb_rules_names['model'],
-                'xkblayout': xkb_rules_names['layout'],
-                'xkbvariant': xkb_rules_names['variant'],
-                'xkboptions': xkb_rules_names['options'],
-            }
-
-            # merge self.proxy_options into the proxy_options we obtained from xprop
-            _proxy_options.update(self.proxy_options)
-            self.proxy_options = _proxy_options
-
-            del self.proxy_options['defkeymap']
-
-            # create keyboard file
-            _keyboard = """\
-rules=%s
-model=%s
-layout=%s
-variant=%s
-options=%s""" % ( self.proxy_options['xkbrules'],
-                  self.proxy_options['xkbmodel'],
-                  self.proxy_options['xkblayout'],
-                  self.proxy_options['xkbvariant'],
-                  self.proxy_options['xkboptions'], )
-
-            # remove processed options from self.process_options
-            del self.proxy_options['xkbrules']
-            del self.proxy_options['xkbmodel']
-            del self.proxy_options['xkblayout']
-            del self.proxy_options['xkbvariant']
-            del self.proxy_options['xkboptions']
-
-            # write the keyboard file into the remote session directory
-            self.session_instance.control_session._x2go_sftp_write('%s/keyboard' % self.session_info.remote_container, _keyboard)
-
         # run the base variant of this method (basically for logging of ignored process_options)
         base.X2goProxyBASE.process_proxy_options(self)
 
diff --git a/x2go/backends/terminal/_stdout.py b/x2go/backends/terminal/_stdout.py
index 1f256a7..91a7c8c 100644
--- a/x2go/backends/terminal/_stdout.py
+++ b/x2go/backends/terminal/_stdout.py
@@ -183,7 +183,7 @@ class X2goTerminalSessionSTDOUT(object):
     def __init__(self, control_session, session_info=None,
                  geometry="800x600", depth=_local_color_depth, link="adsl", pack="16m-jpeg-9", 
                  cache_type="unix-kde", 
-                 keyboard='', kblayout='null', kbtype='null/null',
+                 kbtype='null/null', kblayout='null', kbvariant='null',
                  session_type="application", snd_system='pulse', snd_port=4713, cmd=None,
                  published_applications=False,
                  set_session_title=False, session_title="", applications=[],
@@ -219,10 +219,12 @@ class X2goTerminalSessionSTDOUT(object):
             (class C{X2goProxyNX3}) this originally is the session name. With X2Go it 
             defines the name of the NX cache directory. Best is to leave it untouched.
         @type cache_type: str
-        @param kblayout: keyboard layout, e.g. C{us} (default), C{de}, C{fr}, ...
-        @type kblayout: str
         @param kbtype: keyboard type, e.g. C{pc105/us} (default), C{pc105/de}, ...
         @type kbtype: str
+        @param kblayout: keyboard layout, e.g. C{us} (default), C{de}, C{fr}, ...
+        @type kblayout: str
+        @param kbvariant: keyboard variant, e.g. C{nodeadkeys} (for C{de} layout), C{intl} (for C{us} layout), etc.
+        @type kbvariant: str
         @param session_type: either C{desktop}, C{application} (rootless session) or C{shared}
         @type session_type: str
         @param snd_system: sound system to be used on server (C{none}, C{pulse} (default), 
@@ -285,9 +287,9 @@ class X2goTerminalSessionSTDOUT(object):
         self.params.pack = str(pack)
         self.params.cache_type = str(cache_type)
         self.params.session_type = str(session_type)
-        self.params.keyboard = str(keyboard)
-        self.params.kblayout = str(kblayout)
         self.params.kbtype = str(kbtype)
+        self.params.kblayout = str(kblayout)
+        self.params.kbvariant = str(kbvariant)
         self.params.snd_system = str(snd_system)
         self.params.cmd = str(cmd)
         self.params.depth = str(depth)
@@ -1025,6 +1027,9 @@ class X2goTerminalSessionSTDOUT(object):
 
         (stdin, stdout, stderr) = self.control_session._x2go_exec_command(cmd_line)
 
+        if self.params.kbtype not in ('null/null', 'auto') and (self.params.kblayout not in ('null', '') or self.params.kbvariant not in ('null', '')):
+            self.set_keyboard(layout=self.params.kblayout, variant=self.params.kbvariant)
+
         return stdout.read(), stderr.read()
 
     def is_desktop_session(self):
@@ -1051,6 +1056,39 @@ class X2goTerminalSessionSTDOUT(object):
             return self.session_info.is_published_applications_provider()
         return False
 
+    def set_keyboard(self, layout='null', variant='null'):
+        """\
+        Set the keyboard layout and variant for this (running) session.
+
+        @param layout: keyboard layout to be set
+        @type layout: C{str}
+        @param variant: keyboard variant to be set
+        @type variant: C{str}
+
+        @return: returns C{True} if the {setxkbmap} command could be executed successfully.
+        @rtype: C{bool}
+
+        """
+        cmd_line = [ 'export DISPLAY=:%s && ' % str(self.session_info.display),
+                     'setxkbmap '
+                   ]
+
+        if layout != 'null':
+            self.logger('setting keyboad layout ,,%s\'\' for session %s' % (layout, self.session_info), log.loglevel_INFO)
+            cmd_line.append('-layout %s' % layout)
+        if variant != 'null':
+            self.logger('setting keyboad variant ,,%s\'\' for session %s' % (variant, self.session_info), log.loglevel_INFO)
+            cmd_line.append('-variant %s' % variant)
+
+        (stdin, stdout, stderr) = self.control_session._x2go_exec_command(cmd_line)
+        _stderr = stderr.read()
+        if not _stderr:
+            self.logger('setting keyboard layout ,,%s\'\' and variant ,,%s\'\' for session %s has been successful' % (layout, variant, self.session_info), log.loglevel_NOTICE)
+            return True
+        else:
+            self.logger('setting keyboard layout ,,%s\'\' and variant ,,%s\'\' for session %s failed: %s' % (layout, variant, self.session_info, _stderr.replace('\n', ' ')), log.loglevel_ERROR)
+            return False
+
     def exec_published_application(self, exec_name, timeout=20, env={}):
         """\
         Executed a published application.
@@ -1146,7 +1184,7 @@ class X2goTerminalSessionSTDOUT(object):
             return False
 
         setkbd = "0"
-        if (self.params.kblayout != "null") or (self.params.kbtype != "null/null"):
+        if self.params.kbtype != "null/null":
             setkbd = "1"
 
         if '/' in self.params.cmd:
@@ -1196,10 +1234,6 @@ class X2goTerminalSessionSTDOUT(object):
                                                                 self.session_info.name,
                                                                )
 
-        # let the proxy backend know that we want to define a very special keymap
-        if (self.params.kbtype.endswith('defkeymap') and self.params.kblayout == 'defkeymap'):
-            self.proxy_options.update({'defkeymap': True, })
-
         # set up SSH tunnel for X11 graphical elements
         self.proxy = self.proxy_backend(session_info=self.session_info, 
                                         ssh_transport=self.control_session.get_transport(),
@@ -1234,7 +1268,7 @@ class X2goTerminalSessionSTDOUT(object):
 
         """
         setkbd = "0"
-        if (self.params.kblayout != "null") or (self.params.kbtype != "null/null"):
+        if self.params.kbtype != "null/null":
             setkbd = "1"
 
         cmd_line = [ "x2goresume-session", self.session_info.name,
@@ -1290,9 +1324,13 @@ class X2goTerminalSessionSTDOUT(object):
                                                                     self.session_info.name,
                                                                    )
             self.params.depth = self.session_info.name.split('_')[2][2:]
+
             # on a session resume the user name comes in as a user ID. We have to translate this...
             self.session_info.username = self.control_session.remote_username()
 
+            if self.params.kbtype not in ('null/null', 'auto') and (self.params.kblayout not in ('null', '') or self.params.kbvariant not in ('null', '')):
+                self.set_keyboard(layout=self.params.kblayout, variant=self.params.kbvariant)
+
             if self.params.session_type in ('D', 'S'):
                 self.find_session_window()
                 self.auto_session_window_title()
diff --git a/x2go/client.py b/x2go/client.py
index 5bbdb17..2f50823 100644
--- a/x2go/client.py
+++ b/x2go/client.py
@@ -2861,21 +2861,25 @@ class X2goClient(object):
 
     __update_cache_all_profiles = update_cache_all_profiles
 
-    def register_available_server_sessions_by_profile_name(self, profile_name):
+    def register_available_server_sessions_by_profile_name(self, profile_name, re_register=False):
         """\
         Register available sessions that are found on the X2Go server the profile
         of name C{profile_name} is connected to.
 
         @param profile_name: the X2Go session profile name
         @type profile_name: C{str}
+        @param re_register: re-register available sessions, needs to be done after session profile changes
+        @type re_register: C{bool}
 
         """
+        if profile_name not in self.client_connected_profiles(return_profile_names=True):
+            return
         session_list = self.list_sessions(profile_name=profile_name, 
                                           update_sessionregistry=False,
                                           register_sessions=False,
                                          )
         try:
-            self.session_registry.register_available_server_sessions(profile_name, session_list=session_list)
+            self.session_registry.register_available_server_sessions(profile_name, session_list=session_list, re_register=re_register)
         except x2go_exceptions.X2goControlSessionException:
             self.HOOK_on_control_session_death(profile_name)
             self.disconnect_profile(profile_name)
diff --git a/x2go/defaults.py b/x2go/defaults.py
index 8a12e23..a1da523 100644
--- a/x2go/defaults.py
+++ b/x2go/defaults.py
@@ -298,7 +298,7 @@ X2GO_SESSIONPROFILE_DEFAULTS = {
     'usemimebox': False, 'mimeboxextensions': '', 'mimeboxaction': 'OPEN',
     'fullscreen': False,
     'width': 800,'height': 600,'dpi': 96,'setdpi': False, 'xinerama': False, 'multidisp': False,
-    'usekbd': True, 'layout': 'us', 'type': 'pc105/us',
+    'usekbd': True, 'layout': 'us', 'type': 'pc105/us', 'variant': '',
     'sound': False, 'soundsystem': 'pulse', 'startsoundsystem': False, 'soundtunnel':True, 'defsndport':True, 'sndport':4713,
     'name': 'NEW_PROFILE', 'icon': ':icons/128x128/x2gosession.png',
     'host': '', 'user': CURRENT_LOCAL_USER, 'key': '', 'sshport': 22, 'krblogin': False,
diff --git a/x2go/registry.py b/x2go/registry.py
index 87026a4..324e2c4 100644
--- a/x2go/registry.py
+++ b/x2go/registry.py
@@ -357,7 +357,7 @@ class X2goSessionRegistry(object):
 
         return True
 
-    def register_available_server_sessions(self, profile_name, session_list=None, newly_connected=False):
+    def register_available_server_sessions(self, profile_name, session_list=None, newly_connected=False, re_register=False):
         """\
         Register server-side available X2Go sessions with this L{X2goSessionRegistry} instance for a given profile name.
 
@@ -366,12 +366,16 @@ class X2goSessionRegistry(object):
         @param session_list: an optional C{X2goServerSessionList*} instance (as returned by the L{X2goClient.list_sessions()} command can
             be passed to this method.
         @type session_list: C{X2goServerSessionList*} instance
+        @param newly_connected: give a hint that the session profile got newly connected
+        @type newly_connected: C{bool}
+        @param re_register: re-register available sessions, needs to be done after changes to the session profile
+        @type re_register: C{bool}
 
         """
         if self._last_available_session_registration is not None:
             _now = time.time()
             _time_delta = _now - self._last_available_session_registration
-            if _time_delta < 2:
+            if _time_delta < 2 and not re_register:
                 self.logger('registration interval too short (%s), skipping automatic session registration...' % _time_delta, loglevel=log.loglevel_DEBUG)
                 return
             self._last_available_session_registration = _now
@@ -392,7 +396,7 @@ class X2goSessionRegistry(object):
             # (if the server name has changed, this will kick out obsolete X2goSessions)
             self.update_status(profile_name=profile_name, session_list=session_list, force_update=True)
             for session_name in session_list.keys():
-                if session_name not in _session_names and not self._skip_auto_registration:
+                if (session_name not in _session_names and not self._skip_auto_registration) or re_register:
                     server = _ctrl_session.get_server_hostname()
                     profile_id = _ctrl_session.get_profile_id()
 
@@ -421,7 +425,7 @@ class X2goSessionRegistry(object):
                     except: pass
 
                     # this if clause catches problems when x2golistsessions commands give weird results
-                    if not self.has_session_of_session_name(session_name):
+                    if not self.has_session_of_session_name(session_name) or re_register:
                         session_uuid = self.register(server, profile_id, profile_name,
                                                      session_name=session_name, virgin=False,
                                                      **kwargs
diff --git a/x2go/session.py b/x2go/session.py
index 96c057f..26baeda 100644
--- a/x2go/session.py
+++ b/x2go/session.py
@@ -74,7 +74,7 @@ _X2GO_SESSION_PARAMS = ('use_sshproxy', 'profile_id', 'session_name',
 """A list of allowed X2Go pure session parameters (i.e. parameters that are passed on neither to an X2goControlSession, X2goSSHProxy nor an X2goControlSession object."""
 # options of the paramiko.SSHClient().connect() method, any option that is allowed for a terminal session instance
 _X2GO_TERMINAL_PARAMS = ('geometry', 'depth', 'link', 'pack',
-                        'cache_type', 'kblayout', 'kbtype',
+                        'cache_type', 'kbtype', 'kblayout', 'kbvariant',
                         'session_type', 'snd_system', 'snd_port',
                         'cmd', 'set_session_title', 'session_title',
                         'rdp_server', 'rdp_options', 'applications',
diff --git a/x2go/utils.py b/x2go/utils.py
index 0333afe..99b4c13 100644
--- a/x2go/utils.py
+++ b/x2go/utils.py
@@ -144,6 +144,7 @@ def _convert_SessionProfileOptions_2_SessionParams(_options):
             'sndport': 'snd_port',
             'type': 'kbtype',
             'layout': 'kblayout',
+            'variant': 'kbvariant',
             'speed': 'link',
             'sshport': 'port',
             'useexports': 'allow_share_local_folders',
@@ -257,8 +258,13 @@ def _convert_SessionProfileOptions_2_SessionParams(_options):
     if not _options['usekbd']:
         _params['kbtype'] = 'null/null'
         _params['kblayout'] = 'null'
+        _params['kbvariant'] = 'null'
     del _params['usekbd']
 
+    if not _params['kbtype'].strip(): _params['kbtype'] = 'null/null'
+    if not _params['kblayout'].strip(): _params['kblayout'] = 'null'
+    if not _params['kbvariant'].strip(): _params['kbvariant'] = 'null'
+
     # currently known but ignored in Python X2go
     _ignored_options = [
             'dpi',


hooks/post-receive
-- 
python-x2go.git (Python X2Go Client API)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-x2go.git" (Python X2Go Client API).




More information about the x2go-commits mailing list