Package x2go

[frames] | no frames]

# Package x2go

source code

Python X2Go is a python module that implements X2Go client support for the free X2Go server project (http://wiki.x2go.org) in Python.

# Introduction

With Python X2Go you can write your own X2Go clients or embed X2Go client features into already existing application environments.

NOTE: Beginning with v0.4.0.0 of Python X2Go all class names start with X2Go***. Earlier versions used X2go***. As X2Go is the official name of the project (i.e. with a capital X and a capital G) we have adapted the class names to this circumstance.

# API Concept

Python X2Go consists of quite a few classes. Furthermore, Python X2Go is quite heavily taking advantage of Python's threading features. When providing a library like Python X2Go, it is always quite a task to keep the library code compatible with former versions of the same library. This is intended for Python X2Go, but with some restraints.

Python X2Go only offers five public API classes. With the release of version 0.1.0.0, we will try to keep these five public API classes of future releases as compatible as possible with versions of Python X2Go greater/equal than v0.1.0.0.

The five public API classes are:

- X2GoClient --- a whole X2Go client API
- X2GoSession --- management of an individual X2Go session--either started standalone or from within an X2GoClient instance
- X2GoClientSettings --- provide access to X2Go (global and user) configuration node »settings«
- X2GoClientPrinting --- provide access to X2Go (global and user) configuration node »printing«
- X2GoSessionProfiles --- provide access to X2Go (global and user) configuration node »sessions«

Plus two extra classes on MS Windows platforms:

- X2GoClientXConfig and X2GoXServer --- these classes will be initialized during X2GoClient instantiation on MS Windows platforms and start an installed XServer

Any other of the Python X2Go classes may be subject to internal changes and the way of addressing these classes in code may vary between different versions of Python X2Go. If you directly use other than the five public API classes in your own applications, so please be warned.

# API Structure

When using Python X2Go in your applications, the basic idea is that you create your own class and inherit the X2GoClient class in that:

       import x2go
       class MyX2GoClient(x2go.X2GoClient):

           ...

Python X2Go is capable of handling multiple running/suspended sessions within the same client instance, so for your application, there should not be any need of instantiating more than one X2GoClient object in parallel.

NOTE: Doing so is--herewith--fully disrecommended.

The X2GoClient class flattens the complex structure of Python X2Go into many X2GoClient methods that you can use in your own `MyX2GoClient` instance.

However, it might be handy to retrieve a whole X2Go session instance from the X2GoClient instance. This can be achieved by the X2GoClient.register_session() method:

       import x2go
       my_x2gocli = MyX2GoClient()
       reg_session_instance = my_x2gocli.register_session(<options>, return_object=True)

Whereas <options> can be as simple as:

        »profile_name=<PROFILE_NAME_IN_SESSIONS_FILE>«

or contain a whole set of X2GoSession parameters that can be used to start a session manually (i.e. a session that is based on a pre-configured session profile in either of the »sessions« config files).

The X2GoClient.register_session() method---in object-retrieval-mode---returns an X2GoSession instance. With this instance you can then manage your X2Go session:

       import gevent, getpass
       pw=getpass.getpass()
       # authenticate
       reg_session_instance.connect(password=pw, <further_options>)
       # then launch the session window with either a new session
       if start:
           reg_session_instance.start()
       # or resume a session
       if resume:
           reg_session_instance.resume(session_name=<X2Go-session-name>)
       # leave it runnint for 60 seconds
       gevent.sleep(60)
       # and then suspend
       if suspend:
           reg_session_instance.suspend()
       # or alternatively terminate it
       elif terminate:
           reg_session_instance.terminate()

How to access---especially how to modify---the X2Go client configuration files »settings«, »printing«, »sessions« and »xconfig« (Windows only) is explained in detail with each class declaration in this API documentation. Please refer to the class docs of X2GoClientSettings, X2GoClientPrinting, X2GoSessionProfiles and X2GoXServer.

# Configuration and Session Management

Python X2Go strictly separates configuration management from session management. The classes needed for session management / administration are supposed to only gain »read access« to the classes handling the X2Go client configuration nodes.

A configuration node in Python X2Go can be a file, a gconf database section, a section in the Windows registry, etc.

NOTE: Each configuration node will be re-read whenever it is needed by an X2Go sesion or the X2GoClient class itself.

Conclusively, any change to either of the configuration nodes will be reflected as a change in your X2Go client behaviour:

- X2GoSessionProfiles: changes to a session profile in the »sessions« node will be available for the next registered X2GoSession instance
- X2GoClientPrinting: on each incoming X2Go print job the »printing« configuration node will be re-read, thus you can change your X2Go client's print setup during a running session
- X2GoClientSettings: also the configuration node »settings« is re-read whenever needed in the course of X2Go session management
- X2GoClientXConfig and X2GoXServer (Windows only): these classes will only be initialized once (starting the XServer on Windows platforms) on construction of an X2GoClient instance

# Dependencies

Python X2Go takes advantage of the libevent/greenlet implementation gevent (http://www.gevent.org). The least needed version of Python gevent is 0.13.0. On MS Windows Python gevent 1.0 is highly recommended.

Python X2Go (because of gevent) requires at least Python 2.6. Further recent information on Python X2Go is available at: http://wiki.x2go.org/python-x2go

# Contact

If you have any questions concerning Python X2Go, please sign up for the x2go-dev list (https://lists.berlios.de/mailman/listinfo/x2go-dev) and post your questions, requests and feedbacks there.

Submodules

- x2go._paramiko: Monkey Patch and feature map for Python Paramiko
- x2go.backends
  - x2go.backends.control
    - x2go.backends.control.plain: X2GoControlSession class - core functions for handling your individual X2Go sessions.
  - x2go.backends.info
    - x2go.backends.info.plain: X2GoServerSessionList and X2GoServerSessionInfo classes - data handling for X2Go server sessions.
  - x2go.backends.printing
    - x2go.backends.printing.file: X2GoClientPrinting class is one of Python X2Go's public API classes.
    - x2go.backends.printing.gconf: X2GoClientPrinting class is one of Python X2Go's public API classes.
    - x2go.backends.printing.winreg: X2GoClientPrinting class is one of Python X2Go's public API classes.
  - x2go.backends.profiles
    - x2go.backends.profiles.base: X2GoSessionProfiles class - managing x2goclient session profiles.
    - x2go.backends.profiles.file: X2GoSessionProfiles class - managing x2goclient session profiles.
    - x2go.backends.profiles.gconf: X2GoSessionProfiles class - managing x2goclient session profiles.
    - x2go.backends.profiles.httpbroker: X2GoSessionProfiles class - managing x2goclient session profiles.
    - x2go.backends.profiles.sshbroker: X2GoSessionProfiles class - managing x2goclient session profiles.
    - x2go.backends.profiles.winreg: X2GoSessionProfiles class - managing x2goclient session profiles.
  - x2go.backends.proxy
    - x2go.backends.proxy.base: X2GoProxy class - proxying your connection through NX3 and others.
    - x2go.backends.proxy.nx3: X2GoProxy classes - proxying your connection through NX3 and others.
  - x2go.backends.settings
    - x2go.backends.settings.file: X2GoClientSettings class - managing x2goclient settings file.
    - x2go.backends.settings.gconf: X2GoClientSettings class - managing x2goclient settings file.
    - x2go.backends.settings.winreg: X2GoClientSettings class - managing x2goclient settings file (incl.
  - x2go.backends.terminal
    - x2go.backends.terminal.plain: X2GoTerminalSession class - core functions for handling your individual X2Go sessions.
- x2go.cache: X2GoListSessionCache class - caching X2Go session information.
- x2go.checkhosts: Providing mechanisms to `X2GoControlSession*` backends for checking host validity.
- x2go.cleanup: A recommended X2Go session clean up helper function.
- x2go.client: X2GoClient is a public API class.
- x2go.defaults: Default variables and values for Python X2Go.
- x2go.forward: Python Gevent based port forwarding server (openssh -L option) for the proxying of graphical X2Go elements.
- x2go.gevent_subprocess: Implementation of the standard :mod:`subprocess` module that spawns greenlets
- x2go.guardian: X2GoSessionGuardian class - a guardian thread that controls X2Go session threads and their sub-threads (like reverse forwarding tunnels, Paramiko transport threads, etc.).
- x2go.inifiles: X2GoProcessIniFile - helper class for parsing .ini files
- x2go.log: X2GoLogger class - flexible handling of log and debug output.
- x2go.mimebox: X2GoMIMEboxQueue sets up a thread that listens for incoming files that shall be opened locally on the client.
- x2go.mimeboxactions: For MIME box jobs there are currently three handling actions available: X2GoMIMEboxActionOPEN, X2GoMIMEboxActionOPENWITH and X2GoMIMEboxActionSAVEAS.
- x2go.printactions: Print jobs can either be sent to any of the local print queues (CUPS, Win32API), be opened in an external PDF viewer, be saved to a local folder or be handed over to a custom (print) command.
- x2go.printqueue: X2GoPrintQueue sets up a thread that listens for incoming print jobs.
- x2go.pulseaudio: X2GoPulseAudio class - a Pulseaudio daemon guardian thread.
- x2go.registry: X2GoSessionRegistry class - the X2GoClient's session registry backend
- x2go.rforward: X2Go reverse SSH/Paramiko tunneling provides X2Go sound, X2Go printing and X2Go sshfs for folder sharing and mounting remote devices in X2Go terminal server sessions.
- x2go.session: X2GoSession class - a public API of Python X2Go, handling standalone X2Go sessions.
- x2go.sftpserver: For sharing local folders via sFTP/sshfs Python X2Go implements its own sFTP server (as end point of reverse forwarding tunnel requests).
- x2go.sshproxy: X2GoSSHProxy class - providing a forwarding tunnel for connecting to servers behind firewalls.
- x2go.telekinesis: X2GoTelekinesisClient class - Connect to Telekinesis Server on X2Go Server.
- x2go.tests
  - x2go.tests.runalltests: This file is a default test runner as found in ZOPE/Plone products.
  - x2go.tests.test_printing
- x2go.utils: Python X2Go helper functions, constants etc.
- x2go.x2go_exceptions: Python X2Go exceptions.
- x2go.xserver

Variables
| X2goClientXConfig = `X2GoClientXConfig`
| X2goXServer = `X2GoXServer`
| __NAME__ = ``'``python-x2go``'``
| __VERSION__ = ``'``0.5.0.4``'``
| __package__ = ``'``x2go``'``
| loglevel_DEBUG = `128`
| loglevel_DEBUG_SFTPXFER = `1024`
| loglevel_DEFAULT = `56`
| loglevel_ERROR = `8`
| loglevel_INFO = `64`
| loglevel_NONE = `0`
| loglevel_NOTICE = `32`
| loglevel_WARN = `16`