[X2Go-Commits] python-x2go.git - twofactorauth (branch) updated: 0.2.0.1-6-g699da4c

X2Go dev team git-admin at x2go.org
Sat Sep 14 15:57:35 CEST 2013


The branch, twofactorauth has been updated
       via  699da4c0fe1a13fc8e0a4988360b4101348cce77 (commit)
      from  6184896fab1e7e2551f561e854db30e07d4ec032 (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 -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 debian/changelog |    2 ++
 x2go/session.py  |   60 +++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 55 insertions(+), 7 deletions(-)

The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index b100123..e736b5b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ python-x2go (0.2.0.2-0~x2go1) UNRELEASED; urgency=low
       forwarding tunnel.
     - Improve session management, handle exceptions more gracefully.
     - Ignoring timeouts for x2golistmounts and x2golistdesktops.
+    - Add support to X2goSession class to launch sessions for the Python
+      command line in five steps.
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Wed, 30 May 2012 00:27:03 +0200
 
diff --git a/x2go/session.py b/x2go/session.py
index 6350d0c..8fe7b98 100644
--- a/x2go/session.py
+++ b/x2go/session.py
@@ -25,7 +25,30 @@ This class is normally embedded into the context of an L{X2goClient}
 instance, but it is also possible to address L{X2goSession}s directly via this
 class.
 
+To launch a session manually from the Python interactive shell, perform these
+simple steps::
+
+  $ python
+  Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) 
+  [GCC 4.4.5] on linux2
+  Type "help", "copyright", "credits" or "license" for more information.
+  >>> import x2go
+  >>> import gevent
+  Xlib.protocol.request.QueryExtension
+  >>> s = x2go.session.X2goSession()
+  >>> s.set_server('<my.x2go.server>')
+  >>> s.set_port(<ssh-port>)
+  >>> s.connect('<my-login>', '<my-password>')
+  [<pidno>] (x2gocontrolsession-pylib) NOTICE: connecting to [<my.x2go.server>]:<ssh-port>
+  [<pidno>] (x2gosession-pylib) NOTICE: SSH host key verification for host [<my.x2go.server>]:<ssh-port> with SSH-RSA fingerprint ,,<ssh-fingerprint>'' initiated. We are seeing this X2Go server for the first time.
+  [<pidno>] (x2gosession-pylib) WARN: HOOK_check_host_dialog: host check requested for [<my.x2go.server>]:<ssh-port> with SSH-RSA fingerprint: ,,<ssh-fingerprint>''. Automatically adding host as known host.
+  True
+  >>> s.start(cmd="LXDE")
+  True
+  >>> while True: gevent.sleep(1)
+
 """
+
 __NAME__ = 'x2gosession-pylib'
 
 import os
@@ -105,7 +128,7 @@ class X2goSession(object):
     sessions etc.).
 
     """
-    def __init__(self, server=None, control_session=None,
+    def __init__(self, server=None, port=22, control_session=None,
                  use_sshproxy=False,
                  profile_id=None, profile_name='UNKNOWN',
                  session_name=None,
@@ -232,6 +255,7 @@ class X2goSession(object):
         self.profile_name = profile_name
         self.session_name = session_name
         self.server = server
+        self.port = port
 
         self._last_status = None
 
@@ -342,7 +366,7 @@ class X2goSession(object):
         if self.client_instance:
             self.client_instance.HOOK_profile_auto_connect(profile_name=self.profile_name)
         else:
-            self.logger('HOOK_auto_connect: profile ,,%s'' wants to auto-connect to the X2Go server.' % self.profile_name, loglevel=log.loglevel_WARN)
+            self.logger('HOOK_auto_connect: profile ,,%s\'\' wants to auto-connect to the X2Go server.' % self.profile_name, loglevel=log.loglevel_WARN)
 
     def HOOK_session_startup_failed(self):
         """\
@@ -352,7 +376,7 @@ class X2goSession(object):
         if self.client_instance:
             self.client_instance.HOOK_session_startup_failed(profile_name=self.profile_name)
         else:
-            self.logger('HOOK_session_startup_failed: session startup for session profile ,,%s'' failed.' % self.profile_name, loglevel=log.loglevel_WARN)
+            self.logger('HOOK_session_startup_failed: session startup for session profile ,,%s\'\' failed.' % self.profile_name, loglevel=log.loglevel_WARN)
 
     def HOOK_rforward_request_denied(self, server_port=0):
         """\
@@ -450,7 +474,7 @@ class X2goSession(object):
         if self.client_instance:
             return self.client_instance.HOOK_check_host_dialog(profile_name=self.profile_name, host=host, port=port, fingerprint=fingerprint, fingerprint_type=fingerprint_type)
         else:
-            self.logger('HOOK_check_host_dialog: host check requested for [%s]:%s with %s fingerprint: ,,%s.\'\'. Automatically adding host as known host.' % (host, port, fingerprint_type, fingerprint), loglevel=log.loglevel_WARN)
+            self.logger('HOOK_check_host_dialog: host check requested for [%s]:%s with %s fingerprint: ,,%s\'\'. Automatically adding host as known host.' % (host, port, fingerprint_type, fingerprint), loglevel=log.loglevel_WARN)
             return True
 
     def init_control_session(self):
@@ -539,6 +563,16 @@ class X2goSession(object):
         """
         self.server = server
 
+    def set_port(self, port):
+        """\
+        Modify server port after L{X2goSession} has already been initialized.
+
+        @param port: socket port of server to connect to
+        @type port: C{int}
+
+        """
+        self.port = port
+
     def set_profile_name(self, profile_name):
         """\
         Modify session profile name after L{X2goSession} has already been initialized.
@@ -1064,6 +1098,9 @@ class X2goSession(object):
             _params.update(self.control_params)
             _params.update(self.sshproxy_params)
 
+            if 'port' not in _params:
+                _params['port'] = self.port
+
             try:
                 self.connected = self.control_session.connect(self.server,
                                                               use_sshproxy=self.use_sshproxy, 
@@ -1477,7 +1514,7 @@ class X2goSession(object):
                     if not self.published_applications:
                         return self.start()
 
-    def resume(self, session_name=None, session_list=None):
+    def resume(self, session_name=None, session_list=None, cmd=None):
         """\
         Resume or continue a suspended / running X2Go session on the
         remote X2Go server.
@@ -1486,6 +1523,9 @@ class X2goSession(object):
         @type session_name: C{str}
         @param session_list: a session list to avoid a server-side session list query
         @type session_list: C{dict}
+        @param cmd: if starting a new session, manually hand over the command to be launched in
+            the new session
+        @type cmd: C{str}
 
         @return: returns C{True} if resuming the session has been successful, C{False} otherwise
         @rtype: C{bool}
@@ -1520,6 +1560,9 @@ class X2goSession(object):
                 # FIXME: test the code to see what exceptions may occur here...
                 raise
 
+            if cmd is not None:
+                self.terminal_params['cmd'] = cmd
+
             self.terminal_session = _control.resume(session_name=self.session_name,
                                                     session_instance=self,
                                                     session_list=session_list,
@@ -1606,16 +1649,19 @@ class X2goSession(object):
 
     __resume = resume
 
-    def start(self):
+    def start(self, cmd=None):
         """\
         Start a new X2Go session on the remote X2Go server.
 
+        @param cmd: manually hand over the command that is to be launched in the new session
+        @type cmd: C{str}
+
         @return: returns C{True} if starting the session has been successful, C{False} otherwise
         @rtype: C{bool}
 
         """
         self.session_name = None
-        return self.resume()
+        return self.resume(cmd=cmd)
     __start = start
 
     def share_desktop(self, desktop=None, user=None, display=None, share_mode=0, check_desktop_list=True):


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