1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 """\
21 Python X2Go is a python module that implements X2Go client support for
22 the free X2Go server project (U{http://wiki.x2go.org}) in Python.
23
24 Introduction
25 ============
26 With Python X2Go you can write your own X2Go clients or embed X2Go client
27 features into already existing application environments.
28
29 API Concept
30 ===========
31
32 Python X2Go consists of quite a few classes. Furthermore,
33 Python X2Go is quite heavily taking advantage of Python\'s
34 threading features. When providing a library like Python
35 X2Go, it is always quite a task to keep the library code
36 compatible with former versions of the same library. This is
37 intended for Python X2Go, but with some restraints.
38
39 Python X2Go only offers five public API classes. With the release of
40 version 0.1.0.0, we will try to keep these five public API classes
41 of future releases as compatible as possible with versions of Python X2go
42 greater/equal than v0.1.0.0.
43
44 The five public API classes are:
45
46 - L{X2goClient} --- a whole X2Go client API
47 - L{X2goSession} --- management of an individual X2Go
48 session--either started standalone or from within an L{X2goClient} instance
49 - L{X2goClientSettings} --- provide access to X2Go (global and
50 user) configuration node »settings«
51 - L{X2goClientPrinting} --- provide access to X2Go (global and
52 user) configuration node »printing«
53 - L{X2goSessionProfiles} --- provide access to X2Go (global and
54 user) configuration node »sessions«
55
56 Plus two extra classes on MS Windows platforms:
57
58 - L{X2goClientXConfig} and L{X2goXServer} --- these classes will be initialized
59 during L{X2goClient} instantiation on MS Windows platforms and start an installed XServer
60
61 Any other of the Python X2Go classes may be subject to internal changes
62 and the way of addressing these classes in code may vary between different
63 versions of Python X2Go. If you directly use other than the five public API
64 classes in your own applications, so please be warned.
65
66
67 API Structure
68 =============
69
70 When using Python X2Go in your applications, the basic idea is that you
71 create your own class and inherit the X2goClient class in that::
72
73 import x2go
74 class MyX2goClient(x2go.X2goClient):
75
76 ...
77
78 Python X2Go is capable of handling multiple running/suspended sessions within the
79 same client instance, so for your application, there should not be any need of
80 instantiating more than one L{X2goClient} object in parallel.
81
82 NOTE: Doing so is--herewith--fully disrecommended.
83
84 The L{X2goClient} class flattens the complex structure of Python X2Go into
85 many L{X2goClient} methods that you can use in your own C{MyX2goClient} instance.
86
87 However, it might be handy to retrieve a whole X2Go session instance
88 from the L{X2goClient} instance. This can be achieved by the
89 L{X2goClient.register_session()} method::
90
91 import x2go
92 my_x2gocli = MyX2goClient()
93 reg_session_instance = my_x2gocli.register_session(<options>, return_object=True)
94
95 Whereas <options> can be as simple as::
96
97 »profile_name=<PROFILE_NAME_IN_SESSIONS_FILE>«
98
99 or contain a whole set of L{X2goSession} parameters that can be used to start a
100 session manually (i.e. a session that is based on a pre-configured session profile
101 in either of the »sessions« config files).
102
103 The L{X2goClient.register_session()} method---in object-retrieval-mode---returns
104 an L{X2goSession} instance. With this instance you can then manage
105 your X2Go session::
106
107 import gevent, getpass
108 pw=getpass.getpass()
109 # authenticate
110 reg_session_instance.connect(password=pw, <further_options>)
111 # then launch the session window with either a new session
112 if start:
113 reg_session_instance.start()
114 # or resume a session
115 if resume:
116 reg_session_instance.resume(session_name=<X2Go-session-name>)
117 # leave it runnint for 60 seconds
118 gevent.sleep(60)
119 # and then suspend
120 if suspend:
121 reg_session_instance.suspend()
122 # or alternatively terminate it
123 elif terminate:
124 reg_session_instance.terminate()
125
126 How to access---especially how to modify---the X2Go client configuration
127 files »settings«, »printing«, »sessions« and »xconfig« (Windows only)
128 is explained in detail with each class declaration in this API documentation.
129 Please refer to the class docs of L{X2goClientSettings}, L{X2goClientPrinting},
130 L{X2goSessionProfiles} and L{X2goXServer}.
131
132
133 Configuration and Session Management
134 ====================================
135
136 Python X2Go strictly separates configuration management from
137 session management. The classes needed for session management
138 / administration are supposed to only gain »read access« to the
139 classes handling the X2Go client configuration nodes.
140
141 A configuration node in Python X2Go can be a file, a gconf database
142 section, a section in the Windows registry, etc.
143
144 NOTE: Each configuration node will be re-read whenever it is needed
145 by an X2Go sesion or the X2goClient class itself.
146
147 Conclusively, any change to either of the configuration nodes
148 will be reflected as a change in your X2Go client behaviour:
149
150 - L{X2goSessionProfiles}: changes to a session profile in
151 the »sessions« node will be available for the next registered
152 L{X2goSession} instance
153 - L{X2goClientPrinting}: on each incoming X2Go print job the
154 »printing« configuration node will be re-read, thus you can
155 change your X2Go client's print setup during a running session
156 - L{X2goClientSettings}: also the configuration node »settings«
157 is re-read whenever needed in the course of X2Go session management
158 - L{X2goClientXConfig} and L{X2goXServer} (Windows only): these classes will only be initialized
159 once (starting the XServer on Windows platforms) on construction
160 of an L{X2goClient} instance
161
162 Dependencies
163 ============
164 Python X2Go takes advantage of the libevent/greenlet implementation
165 gevent (http://www.gevent.org). The least needed version of Python gevent
166 is 0.13.0. On MS Windows Python gevent 1.0 is highly recommended.
167
168 Python X2Go (because of gevent) requires at least Python 2.6. Further recent
169 information on Python X2Go is available at:
170 U{http://wiki.x2go.org/python-x2go}
171
172 Contact
173 =======
174 If you have any questions concerning Python X2Go, please sign up for the
175 x2go-dev list (https://lists.berlios.de/mailman/listinfo/x2go-dev) and post
176 your questions, requests and feedbacks there.
177
178 """
179
180 __NAME__ = 'python-x2go'
181 __VERSION__ = '0.2.1.0'
182
183 from gevent import monkey
184 monkey.patch_all()
185
186 import utils
187
188 from client import X2goClient
189 from backends.profiles import X2goSessionProfiles
190 from backends.printing import X2goClientPrinting
191 from backends.settings import X2goClientSettings
192 from session import X2goSession
193 from sshproxy import X2goSSHProxy
194 from x2go_exceptions import *
195 from log import *
196
197 from cleanup import x2go_cleanup
198
199 from defaults import X2GOCLIENT_OS
200 from defaults import CURRENT_LOCAL_USER
201 from defaults import LOCAL_HOME
202 from defaults import X2GO_CLIENT_ROOTDIR
203 from defaults import X2GO_SESSIONS_ROOTDIR
204 from defaults import X2GO_SSH_ROOTDIR
205
206 if X2GOCLIENT_OS == 'Windows':
207 from xserver import X2goClientXConfig, X2goXServer
208