[X2Go-Commits] [x2goclient] 01/94: * re-importing projects
git-admin at x2go.org
git-admin at x2go.org
Fri Dec 15 21:04:29 CET 2023
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to annotated tag 0.1.4.0
in repository x2goclient.
commit 5b39fdfd819a677c3258f900b9bf43714098787a
Author: mike <mike at cdb5e8f1-f799-4276-8919-bce57fd91830>
Date: Sun Oct 24 15:44:51 2010 +0000
* re-importing projects
git-svn-id: https://svn.das-netzwerkteam.de/x2go/pyhoca-cli/trunk@3 cdb5e8f1-f799-4276-8919-bce57fd91830
---
README | 51 +++++
TODO | 25 +++
debian/changelog | 137 +++++++++++++
debian/compat | 1 +
debian/control | 15 ++
debian/copyright | 13 ++
debian/pycompat | 1 +
debian/pyhoca-cli.docs | 2 +
debian/pyhoca-cli.install | 1 +
debian/pyhoca-cli.manpages | 1 +
debian/rules | 24 +++
debian/source/format | 1 +
man/pyhoca-cli.1 | 174 ++++++++++++++++
pyhoca-cli | 502 +++++++++++++++++++++++++++++++++++++++++++++
x2go | 1 +
15 files changed, 949 insertions(+)
diff --git a/README b/README
new file mode 100644
index 00000000..902cce5a
--- /dev/null
+++ b/README
@@ -0,0 +1,51 @@
+pyhoca-cli - Copyright (C) 2010 by Mike Gabriel <m.gabriel at das-netzwerkteam.de>
+
+Contributors:
+ Jörg Sawatzki <joerg.sawatzki at web.de>
+
+Published under the terms of the GNU General Public License.
+See http://www.gnu.org/licenses/gpl.html for a recent copy.
+
+
+=== What is pyhoca-cli? ===
+
+=== Requirements ===
+
+* the python-x2go module needs to be installed (of course)
+* the python-argparse module needs to be available
+* a working version of nxproxy/nxproxy.exe somewhere on your system (if you have
+ installed x2goclient, everything should be fine)
+
+
+=== Current features ===
+
+* start a new session on an X2go server
+* resume a suspended session on an X2go server
+* suspend a running session (hit Ctrl+C)
+* terminate a running session
+* retrieve a list of running sessions
+* sound support available
+* local folder sharing
+
+=== How to use it ===
+
+Please refer to the man page:
+
+ man pyhoca-cli
+
+=== Known issues ===
+Please refer to the TODO file that has been shipped with pyhoca-cli.
+
+
+Thanks in advance for your feedback and contributions,
+
+Kiel (Germany), 20101013,
+
+ Mike Gabriel <m.gabriel at das-netzwerkteam.de>
+
+
+
+
+
+
+
diff --git a/TODO b/TODO
new file mode 100644
index 00000000..0be537da
--- /dev/null
+++ b/TODO
@@ -0,0 +1,25 @@
+pyhoca-cli - Copyright (C) 2010 by Mike Gabriel <m.gabriel at das-netzwerkteam.de>
+
+Contributors:
+ Jörg Sawatzki <joerg.sawatzki at web.de>
+
+Published under the terms of the GNU General Public License.
+See http://www.gnu.org/licenses/gpl.html for a recent copy.
+
+
+=== pyhoca-cli TODOs ===
+
+* enable printing support
+* enable shadow session support
+
+
+=== pyhoca-cli Wishlist ===
+
+* SOCKS client support
+
+
+If you find any issues with this programme please let me know.
+
+Kiel (Germany), 20101013,
+
+ Mike Gabriel <m.gabriel at das-netzwerkteam.de>
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 00000000..cadeb438
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,137 @@
+pyhoca-cli (0.0.15-0~nwt1) lucid maverick testing unstable; urgency=low
+
+ * updated man page
+ * support for --libdebug-sftpxfer option
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Wed, 13 Oct 2010 23:30:00 +0200
+
+pyhoca-cli (0.0.14-0~nwt2) lucid maverick testing unstable; urgency=low
+
+ * depending on bugfix Python X2go version 0.0.12 (or higher)
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Wed, 13 Oct 2010 14:12:00 +0200
+
+pyhoca-cli (0.0.14-0~nwt1) lucid maverick testing unstable; urgency=low
+
+ * added local folder sharing support
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Wed, 13 Oct 2010 14:00:00 +0200
+
+pyhoca-cli (0.0.13-0~nwt1) lucid maverick testing unstable; urgency=low
+
+ * adding cleanup functionality of remaining X2goSession (sub)threads
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Thu, 07 Oct 2010 01:22:00 +0200
+
+pyhoca-cli (0.0.12-0~nwt1) lucid maverick testing unstable; urgency=low
+
+ * if no SSH private key file is specified (default) pyhoca looks
+ for standard private key files and if present tries to use them
+ (imitates behaviour of openssh-client). If you do not want to use
+ SSH pub/priv key authentication, remove your priv key files from the
+ .ssh folder.
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Wed, 06 Oct 2010 18:36:00 +0200
+
+pyhoca-cli (0.0.11-0~nwt1) lucid maverick testing unstable; urgency=low
+
+ * more bugfixing for not-existent SSH private key file
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Wed, 06 Oct 2010 16:42:00 +0200
+
+pyhoca-cli (0.0.10-0~nwt1) lucid maverick testing unstable; urgency=low
+
+ * bugfix for the last bugfix
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Wed, 06 Oct 2010 16:32:00 +0200
+
+pyhoca-cli (0.0.9-0~nwt1) lucid maverick testing unstable; urgency=low
+
+ * bugfix release for case where there is not id_rsa file in the SSH home dir
+ of a user
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Wed, 06 Oct 2010 16:30:00 +0200
+
+pyhoca-cli (0.0.8-0~nwt1) lucid maverick testing unstable; urgency=low
+
+ * moved the _touch_file function further up
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Wed, 06 Oct 2010 16:25:00 +0200
+
+pyhoca-cli (0.0.7-0~nwt4) lucid maverick testing unstable; urgency=low
+
+ * added build destination Ubuntu lucid/maverick, Debian squeeze/sid
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Wed, 06 Oct 2010 16:08:00 +0200
+
+pyhoca-cli (0.0.7-0~nwt3) unstable; urgency=low
+
+ * bugfix (typo) for pyhoca-cli version string
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Wed, 06 Oct 2010 13:30:00 +0200
+
+pyhoca-cli (0.0.7-0~nwt2) unstable; urgency=low
+
+ * version was derived from python-x2go, now pyhoca-cli displays
+ its own version number
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Wed, 06 Oct 2010 10:00:00 +0200
+
+pyhoca-cli (0.0.7-0~nwt1) unstable; urgency=low
+
+ * added an internal session duration counter
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Tue, 05 Oct 2010 18:50:00 +0200
+
+pyhoca-cli (0.0.6-0~nwt1) unstable; urgency=low
+
+ * activated sound support option
+ * activated local ssh port option
+ * distro codename lucid -> unstable (to be more general)
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Tue, 05 Oct 2010 13:30:00 +0200
+
+pyhoca-cli (0.0.5-0~nwt1) lucid; urgency=low
+
+ * updated man page
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Fri, 01 Oct 2010 22:41:00 +0200
+
+pyhoca-cli (0.0.4-0~nwt1) lucid; urgency=low
+
+ * renamed --timeout option to --time-to-wait, because it is more descriptive for
+ what it does
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Fri, 01 Oct 2010 21:22:00 +0200
+
+pyhoca-cli (0.0.3-0~nwt1) lucid; urgency=low
+
+ * at end of session: added a small pause before telling the user what
+ happened to the running session
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Fri, 01 Oct 2010 20:58:00 +0200
+
+pyhoca-cli (0.0.2-0~nwt3) lucid; urgency=low
+
+ * updated python-x2go dependency in control file
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Fri, 01 Oct 2010 20:51:00 +0200
+
+pyhoca-cli (0.0.2-0~nwt2) lucid; urgency=low
+
+ * fixed control file
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Fri, 01 Oct 2010 01:32:00 +0200
+
+pyhoca-cli (0.0.2-0~nwt1) lucid; urgency=low
+
+ * first test release
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Fri, 01 Oct 2010 01:30:00 +0200
+
+pyhoca-cli (0.0.1-0~nwt1) lucid; urgency=low
+
+ * resetting changelog after rewrite of python-x2go
+
+ -- Mike Gabriel <m.gabriel at das-netzwerkteam.de> Sat, 25 Sep 2010 16:00:00 +0200
+
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 00000000..7f8f011e
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+7
diff --git a/debian/control b/debian/control
new file mode 100644
index 00000000..79179389
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,15 @@
+Source: pyhoca-cli
+Section: python
+Priority: optional
+Maintainer: Mike Gabriel <m.gabriel at das-netzwerkteam.de>
+Build-Depends: debhelper (>= 7), python, python-setuptools, python-support
+Standards-Version: 3.9.0
+Homepage: http://das-netzwerkteam.de/site/?q=node/71
+XS-Python-Version: all
+
+Package: pyhoca-cli
+Architecture: all
+Depends: ${misc:Depends}, python, python-x2go (>=0.0.14-0~nwt1), python-argparse
+Description: X2go client written in Python
+ A fully functional X2go client implementation written
+ in Python.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 00000000..fc67feca
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,13 @@
+pyhoca-cli - Copyright (C) 2010 by Mike Gabriel <m.gabriel at das-netzwerkteam.de>
+
+Published under the terms of the GNU General Public License.
+See http://www.gnu.org/licenses/gpl.html for a recent copy.
+
+On Debian/Ubuntu systems a local copy of the GPL license can also be
+found in /usr/share/common-licenses.
+
+The code has been packaged for Debian/Ubuntu by Mike Gabriel
+<m.gabriel at das-netzwerkteam.de>
+
+light+love,
+Mike Gabriel
diff --git a/debian/pycompat b/debian/pycompat
new file mode 100644
index 00000000..0cfbf088
--- /dev/null
+++ b/debian/pycompat
@@ -0,0 +1 @@
+2
diff --git a/debian/pyhoca-cli.docs b/debian/pyhoca-cli.docs
new file mode 100644
index 00000000..1d23e9b9
--- /dev/null
+++ b/debian/pyhoca-cli.docs
@@ -0,0 +1,2 @@
+README
+TODO
\ No newline at end of file
diff --git a/debian/pyhoca-cli.install b/debian/pyhoca-cli.install
new file mode 100644
index 00000000..b6c7254f
--- /dev/null
+++ b/debian/pyhoca-cli.install
@@ -0,0 +1 @@
+pyhoca-cli /usr/bin/
\ No newline at end of file
diff --git a/debian/pyhoca-cli.manpages b/debian/pyhoca-cli.manpages
new file mode 100644
index 00000000..6a255bff
--- /dev/null
+++ b/debian/pyhoca-cli.manpages
@@ -0,0 +1 @@
+man/pyhoca-cli.1
\ No newline at end of file
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 00000000..ecc98712
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,24 @@
+#!/usr/bin/make -f
+# debian/rules file - for pyhoca-cli
+# Based on sample debian/rules file - for GNU Hello (1.3).
+# Copyright 2010 by Mike Gabriel
+
+#PYVERS=$(shell pyversions -vr)
+
+%:
+ dh ${@}
+
+build:
+ dh ${@}
+
+install:
+ dh ${@}
+
+
+binary-indep:
+ dh ${@}
+
+clean:
+ rm -Rfv debian/pyhoca-cli debian/pyhoca-cli.*.debhelper debian/pyhoca-cli.substvars
+ rm -Rfv debian/tmp debian/patches
+ dh ${@}
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 00000000..163aaf8d
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/man/pyhoca-cli.1 b/man/pyhoca-cli.1
new file mode 100644
index 00000000..79fae870
--- /dev/null
+++ b/man/pyhoca-cli.1
@@ -0,0 +1,174 @@
+'\" -*- coding: utf-8 -*-
+.if \n(.g .ds T< \\FC
+.if \n(.g .ds T> \\F[\n[.fam]]
+.de URL
+\\$2 \(la\\$1\(ra\\$3
+..
+.if \n(.g .mso www.tmac
+.TH pyhoca-cli 1 "21 Sep 2010" "Version 0.0.6" "X2go Application"
+.SH NAME
+pyhoca-cli \- X2go command line client written in Python
+.SH SYNOPSIS
+'nh
+.fi
+.ad l
+\fBpyhoca-cli\fR \kx
+.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
+'in \n(.iu+\nxu
+[
+\fIoptions\fR
+]
+'in \n(.iu-\nxu
+.ad b
+'hy
+.SH DESCRIPTION
+\fBpyhoca-cli\fR is an X2go command line client written in Python.
+.PP
+You can use it
+for scripting remote X2go sessions or simply starting, resuming or shadowing X2go sessions from
+the command line in a terminal.
+.PP
+It supports versatile
+command line options as well as parsing \fBx2goclient\fR configuration
+files.
+.PP
+See the included README and TODO for further information on \fBpyhoca-cli\fR.
+.SH COMMON OPTIONS
+\fBpyhoca-cli\fR accepts the following common options:
+.TP
+\*(T<\fB\-h, \-\-help\fR\*(T>
+Display a help with all available command line options and exit.
+.TP
+\*(T<\fB\-V, \-\-version\fR\*(T>
+Output version information and exit.
+.TP
+\*(T<\fB\-d, \-\-debug\fR\*(T>
+Enable debugging output.
+.TP
+\*(T<\fB\-\-libdebug\fR\*(T>
+Enable debugging code of the unterlying Python X2go module.
+.TP
+\*(T<\fB\-\-libdebug-sftpxfer\fR\*(T>
+Enable debugging code of Python X2go\'s sFTP server code (very verbose, and it may even reveal promiscuous data).
+.SH SERVER
+.TP
+\*(T<\fB\-\-server\fR \fI<HOSTNAME_or_IP>\fR\*(T>
+If not in LDAP mode you always have to name the remote X2go server's hostname or IP address.
+.SH ACTIONS
+\fBpyhoca-cli\fR accepts exclusively one of the listed actions:
+.TP
+\*(T<\fB\-N, \-\-new\fR\*(T>
+Start a new X2go session on server (default mode if no mode is explicitly specified).
+.TP
+\*(T<\fB\-R, \-\-resume\fR \fI<SESSION_NAME>\fR\*(T>
+Resume existing X2go session <SESSION_NAME> on server.
+.TP
+\*(T<\fB\-S, \-\-suspend\fR \fI<SESSION_NAME>\fR\*(T>
+Suspend running X2go session <SESSION_NAME>.
+.TP
+\*(T<\fB\-T, \-\-terminate\fR \fI<SESSION_NAME>\fR\*(T>
+Terminate running X2go session <SESSION_NAME> .
+.TP
+\*(T<\fB\-L, \-\-list-sessions\fR\*(T>
+List user's X2go sessions on server.
+.TP
+\*(T<\fB\-I, \-\-import-session\fR\*(T>
+NOT IMPLEMENTED YET: Import a session from an x2goclient config file and run it (requires \fB\-\-config\fR option).
+.SH X2GO OPTIONS
+.TP
+\*(T<\fB\-\-config\fR \fI<CONFIG_FILENAME>\fR\*(T>
+NOT IMPLEMENTED YET: X2goclient config file containing x2go client session settings (default: ~/.x2goclient/sessions).
+.TP
+\*(T<\fB\-c, \-\-command\fR \fI<CMD>\fR\*(T>
+Command to run with \fB\-\-new\fR mode on server (default: xterm).
+.TP
+\*(T<\fB\-u, \-\-username\fR \fI<USERNAME>\fR\*(T>
+Username for the session (default: currently logged in user).
+.TP
+\*(T<\fB\-p, \-\-password\fR \fI<secret>\fR\*(T>
+User password, usage not recommended directly from the command line, useful for scripting, though (default: not set).
+.TP
+\*(T<\fB\-r, \-\-remote-ssh-port\fR \fI<R_PORT>\fR\*(T>
+Remote X2go server's SSH port (default: 22).
+.TP
+\*(T<\fB\-k, \-\-ssh-privkey\fR \fI<SSH_PRIVKEY>\fR\*(T>
+Use file <SSH_PRIVKEY> as private key for SSH connections (default: ~/.ssh/id_rsa).
+.TP
+\*(T<\fB\-\-add\-to\-known\-hosts\fR\*(T>
+Add RSA/DSA host key to ~/.ssh/known_hosts if authenticity of server can't be established (default: not set).
+.TP
+\*(T<\fB\-\-sound\fR \fI{pulse|esd|none}\fR\*(T>
+X2go server's sound system (default: 'pulse').
+.TP
+\*(T<\fB\-F, \-\-share-local-folders\fR \fI<folder1>[,<folder2>[,...]]\fR\*(T>
+A comma separated list of local folders that shall be made available in the remote X2go session.
+.TP
+\*(T<\fB\-\-printing\fR\*(T>
+Use X2go printing (default: disabled).
+.TP
+\*(T<\fB\-\-clean-sessions\fR\*(T>
+Clean all of the user's suspended sessions before starting a new one on the named X2go server.
+.TP
+\*(T<\fB\-\-time-to-wait\fR\*(T>
+Time to wait for session startup/resume (default: 8s). There should be no need to touch this, unless on very slow network connections.
+.SH LDAP OPTIONS
+LDAP support is planned to be added into \fBpyhoca-cli\fR in the near future. So stay tuned...
+.PP
+.SH NX OPTIONS (Version 3)
+.TP
+\*(T<\fB\-g, \-\-geometry\fR \fI{<WIDTH>x<HEIGHT>|fullscreen}\fR\*(T>
+Screen geometry (default: '800x600').
+.TP
+\*(T<\fB\-q, \-\-link\fR \fI{modem|isdn|adsl|wan|lan}\fR\*(T>
+link quality (default: 'adsl')
+.TP
+\*(T<\fB\-t, \-\-session\-type\fR \fI{desktop|application}\fR\*(T>
+Session type (default: 'application'). Note: there are also some auto-detection
+feature for the session type built into the code.
+It might not always happen what you expect from setting this option.
+.TP
+\*(T<\fB\-p, \-\-pack\-type\fR \fI<PACK_METHOD>\fR\*(T>
+Compression methods (see below for possible values).
+.TP
+\*(T<\fB\-\-kbd\-layout\fR \fI{us|de|fr|...}\fR\*(T>
+Use keyboard layout (default: 'us').
+.TP
+\*(T<\fB\-\-kbd\-type\fR \fI{pc105/us|pc105/de|...}\fR\*(T>
+Set Keyboard type (default 'pc105/us').
+.SH COMPATIBILITY OPTIONS
+\fBpyhoca-cli\fR aims at being fully compatible with all command line options and session config files of the X2go project's X2go command
+line client \fBx2goclient-cli\fR as well as the \fBx2goclient\fR GUI.
+To achieve this, some compatibility options have
+been added (\fBx2goclient-cli\fR compatibility only, for now):
+.TP
+\*(T<\fB\-\-port\fR \fI<R_PORT>\fR\*(T>
+Compatibility option, synonymous to \fB\-\-remote\-ssh\-port\fR \fI<R_PORT>\fR.
+.TP
+\*(T<\fB\-\-ssh\-key\fR \fI<SSH_PRIVKEY>\fR\*(T>
+Compatibility option, synonymous to \fB\-\-ssh-privkey\fR \fISSH_KEY\fR.
+.TP
+\*(T<\fB\-\-use\-sound\fR \fI{yes|no}\fR\*(T>
+Compatibility option, synonymous to \fB\-\-sound\fR \fI{pulse|none}\fR.
+.TP
+\*(T<\fB\-\-client-ssh-port\fR \fI<PORT>\fR\*(T>
+Compatibility option for the x2goclient GUI. PyHoca-Cli (resp. Python X2go) brings its own internal sFTP server. Thus, this option will be ignored.
+.SH NX COMPRESSION METHODS
+As NX compression methods (\fB--pack\fR options) the following values are possible. The % character must be replaced by a digit 0-9.
+.PP
+nopack, 8, 64, 256, 512, 4k, 32k, 64k, 256k, 2m, 16m
+256-rdp, 256-rdp-compressed, 32k-rdp, 32k-rdp-compressed, 64k-rdp
+64k-rdp-compressed, 16m-rdp, 16m-rdp-compressed
+rfb-hextile, rfb-tight, rfb-tight-compressed
+8-tight, 64-tight, 256-tight, 512-tight, 4k-tight, 32k-tight
+64k-tight, 256k-tight, 2m-tight, 16m-tight
+8-jpeg-%, 64-jpeg, 256-jpeg, 512-jpeg, 4k-jpeg, 32k-jpeg
+64k-jpeg, 256k-jpeg, 2m-jpeg, 16m-jpeg-%
+8-png-jpeg-%, 64-png-jpeg, 256-png-jpeg, 512-png-jpeg, 4k-png-jpeg
+32k-png-jpeg, 64k-png-jpeg, 256k-png-jpeg, 2m-png-jpeg, 16m-png-jpeg-%
+8-png-%, 64-png, 256-png, 512-png, 4k-png
+32k-png, 64k-png, 256k-png, 2m-png, 16m-png-%
+16m-rgb-%, 16m-rle-%
+.SH "SEE ALSO"
+\fB/usr/share/doc/python-x2go\fR
+.SH AUTHOR
+This manual has been written by Mike Gabriel <m.gabriel at das-netzwerkteam.de>
diff --git a/pyhoca-cli b/pyhoca-cli
new file mode 100755
index 00000000..12da2004
--- /dev/null
+++ b/pyhoca-cli
@@ -0,0 +1,502 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+"""
+ Copyright (C) 2010 by Mike Gabriel <m.gabriel at das-netzwerkteam.de>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the
+ Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Contributors to the code of this programme:
+ Jörg Sawatzki <joerg.sawatzki at web.de>
+"""
+
+
+###
+### module section
+###
+
+import sys, os
+import time
+import argparse
+import getpass
+import x2go
+import paramiko
+from types import *
+
+# for debugging
+import pprint
+
+# Python X2go provides the current local username (OS independent)
+from x2go.defaults import CURRENT_LOCAL_USER as current_user
+from x2go.defaults import X2GO_PRINT_ACTIONS
+from x2go.defaults import DEFAULT_PDFVIEW_CMD
+from x2go.defaults import DEFAULT_PDFSAVE_LOCATION
+from x2go.defaults import DEFAULT_PRINTCMD_CMD
+
+# version information
+PROG_NAME = os.path.basename(sys.argv[0])
+PROG_PID = os.getpid()
+VERSION="0.0.14"
+VERSION_TEXT="""
+%s[%s] - an X2go command line client written in Python
+----------------------------------------------------------------------
+developed by Mike Gabriel <m.gabriel at das-netzwerkteam.de>
+
+VERSION: %s
+
+""" % (PROG_NAME, PROG_PID, VERSION)
+
+
+def _touch_file(filename):
+
+ if not os.path.isfile(filename):
+ f = open(filename, 'w')
+ f.close()
+
+# ,,constants'' needed for debugging
+logger = x2go.X2goLogger(tag='MAIN')
+liblogger = x2go.X2goLogger()
+x2go_session_hash = ''
+
+# use current_home as user home dir
+current_home = os.path.expanduser("~")
+
+# define and create known_hosts file (if not there)
+ssh_known_hosts_filename = os.path.join(current_home, '.ssh', 'known_hosts')
+if not os.path.isfile(ssh_known_hosts_filename):
+ _touch_file(ssh_known_hosts_filename)
+# define and create ssh_config file (if not there)
+ssh_config_filename = os.path.join(current_home, '.ssh', 'config')
+if not os.path.isfile(ssh_config_filename):
+ _touch_file(ssh_config_filename)
+
+PRINT_ACTIONS = X2GO_PRINT_ACTIONS.keys()
+print_action_args = {}
+
+###
+### command line arguments
+###
+
+# exclusive client control options
+action_options = [
+ {'args':['-N','--new'], 'default': False, 'action': 'store_true', 'help': 'start a new X2go session on server (default)', },
+ {'args':['-R','--resume'], 'default': None, 'metavar': 'SESSION_NAME', 'help': 'resume a suspended X2go session with name SESSION_NAME', },
+ {'args':['-S','--suspend'], 'default': None, 'metavar': 'SESSION_NAME', 'help': 'suspend running X2go session SESSION_NAME', },
+ {'args':['-T','--terminate'], 'default': None, 'metavar': 'SESSION_NAME', 'help': 'terminate running X2go session SESSION_NAME', },
+ {'args':['-L','--list-sessions'], 'default': False, 'action': 'store_true', 'help': 'list user\'s X2go sessions on server', },
+ # NOT IMPLEMENTED {'args':['-I','--import-session'], 'default': False, 'action': 'store_true', 'help': 'import a session from an x2goclient config file and run it', },
+ ]
+# debug options...
+debug_options = [
+ {'args':['-d','--debug'], 'default': False, 'action': 'store_true', 'help': 'enable application debugging code', },
+ {'args':['--libdebug'], 'default': False, 'action': 'store_true', 'help': 'enable debugging code of the underlying Python X2go module', },
+ {'args':['--libdebug-sftpxfer'], 'default': False, 'action': 'store_true', 'help': 'enable debugging code of Python X2go\'s sFTP server code (very verbose, and even promiscuous)', },
+ {'args':['-V', '--version'], 'default': False, 'action': 'store_true', 'help': 'print version number and exit', },
+ ]
+# possible programme options are
+x2go_options = [
+ # NOT IMPLEMENTED {'args':['--config'], 'default': '~/.x2goclient/sessions', 'help': 'x2goclient config file containing x2go session settings (default: ~/.x2goclient/sessions)', },
+ {'args':['-c','--command'], 'default': 'TERMINAL', 'help': 'command to run with -R mode on server (default: xterm)', },
+ {'args':['-u','--username'], 'default': None, 'help': 'username for the session (default: current user)', },
+ {'args':['-p','--password'], 'default': None, 'help': 'user password (not recommended from the command line, default: not set)', },
+ {'args':['-r','--remote-ssh-port'], 'default': '22', 'help': 'remote SSH port (default: 22)', },
+ {'args':['-k','--ssh-privkey'], 'default': None, 'help': 'use file \'SSH_PRIVKEY\' as private key for the SSH connection (e.g. ~/.ssh/id_rsa)', },
+ {'args':['--add-to-known-hosts'], 'default': False, 'action': 'store_true', 'help': 'add RSA host key fingerprint to ~/.ssh/known_hosts if authenticity of server can\'t be established (default: not set)', },
+ {'args':['--sound'], 'default': 'pulse', 'choices': ('pulse', 'esd', 'none'), 'help': 'X2go server sound system (default: \'pulse\')', },
+ {'args':['--printing'], 'default': False, 'action': 'store_true', 'help': 'use X2go printing (default: disabled)', },
+ {'args':['-F', '--share-local-folders'], 'metavar': '<folder1>[,<folder2[,...]]', 'default': None, 'help': 'a comma separated list of local folder names to mount in the X2go session', },
+ {'args':['--clean-sessions'], 'default': False, 'action': 'store_true', 'help': 'clean all suspended sessions before starting a new one', },
+ {'args':['--time-to-wait'], 'default': '8', 'help': 'time to wait for session startup/resume (default: 8s)', },
+ ]
+print_options = [
+ {'args':['--print-action'], 'default': 'PDFVIEW', 'choices': PRINT_ACTIONS, 'help': 'action to be performed for incoming X2go print jobs (default: \'PDFVIEW\')', },
+ {'args':['--pdfview-cmd'], 'default': None, 'help': 'PDF viewer command for displaying incoming X2go print jobs (default: \'%s\'); this option selects \'--print-action PDFVIEW\'' % DEFAULT_PDFVIEW_CMD,},
+ {'args':['--save-to-folder'], 'default': None, 'metavar': 'PRINT_DEST', 'help': 'save print jobs as PDF files to folder PRINT_DEST (default: \'%s\'); this option selects \'--print-action PDFSAVE\'' % DEFAULT_PDFSAVE_LOCATION,},
+ {'args':['--printer'], 'default': None, 'help': 'target CUPS print queue for incoming X2go print jobs (default: CUPS default printer); this option selects \'--print-action CUPS\'',},
+ {'args':['--print-cmd'], 'default': None, 'help': 'print command including cmd line arguments (default: \'%s\'); this option selects \'--print-action PRINTCMD\'' % DEFAULT_PRINTCMD_CMD,},
+ ]
+nx_options = [
+ {'args':['-g','--geometry'], 'default': '800x600','help': 'screen geometry: \'<width>x<height>\' or \'fullscreen\' (default: \'800x600\')',},
+ {'args':['-q','--link'], 'default': 'adsl', 'choices': ('modem','isdn','adsl','wan','lan'), 'help': 'link quality (default: \'adsl\')',},
+ {'args':['-t','--session-type'], 'default': 'application', 'choices': ('desktop', 'application'), 'help': 'session type (default: \'application\')', },
+ {'args':['--pack'], 'default': '16m-jpeg-9', 'help': 'compression methods (see below for possible values)', },
+ {'args':['--kbd-layout'], 'default': 'us', 'help': 'use keyboard layout (default: \'us\')',},
+ {'args':['--kbd-type'], 'default': 'pc105/us', 'help': 'set Keyboard type (default: \'pc105/us\')',},
+ ]
+compat_options = [
+ {'args':['--port'], 'default': None, 'help': 'compatibility option, synonymous to --remote-ssh-port PORT', },
+ {'args':['--ssh-key'], 'default': None, 'help': 'compatibility option, synonymous to --ssh-privkey SSH_KEY', },
+ {'args':['--use-sound'], 'default': None, 'choices': ('yes', 'no'), 'help': 'compatibility option, synonymous to --sound {pulse|none}', },
+ {'args':['--client-ssh-port'], 'default': None, 'help': 'compatibility option for the x2goclient GUI; as Python X2go brings its own internal SFTP server, this option will be ignored', },
+ ]
+
+
+###
+### beginning of code
+###
+
+# print version text and exit
+def version():
+
+ sys.stderr.write ("%s\n" % VERSION_TEXT)
+ sys.exit(0)
+
+
+# sometimes we have to fail...
+def runtime_error(m, parser=None, exitcode=-1):
+ if parser is not None:
+ parser.print_usage()
+ sys.stderr.write ("%s: error: %s\n" % (PROG_NAME, m))
+ sys.exit(exitcode)
+
+
+def parseargs():
+
+ global DEBUG
+ global print_action_args
+
+ p = argparse.ArgumentParser(description='X2go command line client implemented in Python.',\
+ epilog="""
+Possible values for the --pack NX option are:
+ %s
+""" % x2go.defaults.pack_methods_nx3_formatted, \
+ formatter_class=argparse.RawDescriptionHelpFormatter, \
+ add_help=True, argument_default=None)
+ p_reqargs = p.add_argument_group('X2go server name is always required')
+ p_reqargs.add_argument('--server', help='server hostname or IP address')
+ p_actionopts = p.add_argument_group('client actions')
+ p_debugopts = p.add_argument_group('debug options')
+ p_x2goopts = p.add_argument_group('X2go options')
+ p_printopts = p.add_argument_group('X2go print options')
+ p_nxopts = p.add_argument_group('NX options')
+ p_compatopts = p.add_argument_group('compatibility options')
+
+ for (p_group, opts) in ((p_x2goopts, x2go_options), (p_printopts, print_options), (p_actionopts, action_options), (p_debugopts, debug_options), (p_nxopts, nx_options), (p_compatopts, compat_options)):
+ required = False
+ for opt in opts:
+
+ args = opt['args']
+ del opt['args']
+ p_group.add_argument(*args, **opt)
+
+ a = p.parse_args()
+
+ if a.debug:
+ logger.set_loglevel_debug()
+
+ if a.libdebug:
+ liblogger.set_loglevel_debug()
+
+ if a.libdebug_sftpxfer:
+ liblogger.enable_debug_sftpxfer()
+
+ if a.version:
+ version()
+
+ # the --server options is required for most operations
+ if not a.server:
+ runtime_error ("argument --server is required", parser=p, exitcode=1)
+
+ # check for mutual exclusiveness of -N, -R, -S, -T and -L, -N is default if none of them is set
+ if bool(a.new) + bool(a.resume) + bool(a.suspend) + bool(a.terminate) + bool(a.list_sessions) > 1:
+ runtime_error ("modes --new, --resume, --suspend, --terminate and --list-sessions are mutually exclusive", parser=p, exitcode=2)
+ if bool(a.new) + bool(a.resume) + bool(a.suspend) + bool(a.terminate) + bool(a.list_sessions) == 0:
+ a.new = True
+
+ # check if pack method is available
+ if not x2go.utils.is_in_nx3packmethods(a.pack):
+ runtime_error("unknown pack method '%s'" % args.pack, parser=p, exitcode=10)
+
+ # if no username is given we use the uid under which this programme is run
+ if a.username is None:
+ a.username = current_user
+
+ # time-to-wait needs to be an integer
+ try:
+ a.time_to_wait = int(a.time_to_wait)
+ except ValueError:
+ runtime_error("--time_to_wait value needs to be an integer value", parser=p, exitcode=80)
+
+ # X2go printing
+ if ((a.pdfview_cmd and a.printer) or
+ (a.pdfview_cmd and a.save_to_folder) or
+ (a.pdfview_cmd and a.print_cmd) or
+ (a.printer and a.save_to_folder) or
+ (a.printer and a.print_cmd) or
+ (a.print_cmd and a.save_to_folder)):
+ runtime_error("--pdfviewer, --save-to-folder, --printer and --print-cmd options are mutually exclusive", parser=p, exitcode=81)
+
+ if a.pdfview_cmd:
+ a.print_action = 'PDFVIEW'
+ elif a.save_to_folder:
+ a.print_action = 'PDFSAVE'
+ elif a.printer:
+ a.print_action = 'PRINT'
+ elif a.print_cmd:
+ a.print_action = 'PRINTCMD'
+
+ if a.pdfview_cmd is None and a.print_action == 'PDFVIEW':
+ a.pdfview_cmd = DEFAULT_PDFVIEW_CMD
+
+ if a.save_to_folder is None and a.print_action == 'PDFSAVE':
+ a.save_to_folder = DEFAULT_PDFSAVE_LOCATION
+
+ if a.printer is None and a.print_action == 'PRINT':
+ # None means CUPS default printer...
+ a.printer = None
+
+ if a.print_cmd is None and a.print_action == 'PRINTCMD':
+ a.print_cmd = DEFAULT_PRINTCMD_CMD
+
+ if a.pdfview_cmd:
+ print_action_args={'pdfview_cmd': a.pdfview_cmd, }
+ elif a.save_to_folder:
+ print_action_args={'save_to_folder': a.save_to_folder, }
+ elif a.printer:
+ print_action_args={'printer': a.printer, }
+ elif a.print_cmd:
+ print_action_args={'print_cmd': a.print_cmd, }
+
+ ### take care of compatibility options
+ # option --use-sound yes as synonomyn for --sound
+ if a.use_sound is not None:
+ if a.use_sound == 'yes': a.sound = 'pulse'
+ if a.use_sound == 'no': a.sound = 'none'
+
+ if a.ssh_key is not None:
+ a.ssh_privkey = a.ssh_key
+
+ if a.port is not None:
+ a.remote_ssh_port = a.port
+
+ if a.share_local_folders is not None:
+ a.share_local_folders = a.share_local_folders.split(',')
+
+ ###
+ ### initialize SSH context
+ ###
+ # check if SERVER is in .ssh/config file, extract information from there...
+ ssh_config = paramiko.SSHConfig()
+ ssh_config_fileobj = open(ssh_config_filename)
+ ssh_config.parse(ssh_config_fileobj)
+ ssh_host = ssh_config.lookup(a.server)
+ if ssh_host:
+ if 'hostname' in ssh_host.keys():
+ a.server = ssh_host['hostname']
+ if 'port' in ssh_host.keys():
+ a.remote_ssh_port = ssh_host['port']
+ ssh_config_fileobj.close()
+ # check if ssh priv key exists
+ if a.ssh_privkey and not os.path.isfile(a.ssh_privkey):
+ runtime_error("SSH private key %s file does not exist." % a.ssh_privkey, parser=p, exitcode=30)
+ if not a.ssh_privkey and os.path.isfile('%s/.ssh/id_rsa' % current_home):
+ a.ssh_privkey = '%s/.ssh/id_rsa' % current_home
+ if not a.ssh_privkey and os.path.isfile('%s/.ssh/id_dsa' % current_home):
+ a.ssh_privkey = '%s/.ssh/id_dsa' % current_home
+
+ return p, a
+
+
+def list_sessions(cli, s_hash):
+ # retrieve a session list
+ print
+ print "Available runing/suspended X2go sessions"
+ print "========================================"
+ print "Hostname: [%s]:%s" % cli.get_server(s_hash)
+ print "Username: %s" % cli.get_username(s_hash)
+ print
+ session_infos = cli.list_sessions(s_hash)
+ for session_info in session_infos.values():
+ print "Session Name: %s" % session_info
+ print "-------------"
+ print "cookie: %s" % session_info.cookie
+ print "agent PID: %s" % session_info.agent_pid
+ print "display: %s" % session_info.display
+ print "status: %s" % session_info.status
+ print "graphic port: %s" % session_info.graphics_port
+ print "snd port: %s" % session_info.snd_port
+ print "sshfs port: %s" % session_info.sshfs_port
+ print "username: %s" % session_info.username
+ print "hostname: %s" % session_info.hostname
+ # TODO: turn into datetime object
+ print "create date: %s" % session_info.date_created
+ # TODO: turn into datetime object
+ print "suspended since: %s" % session_info.date_suspended
+ print
+
+
+def clean_sessions(cli, s_hash):
+ # clean all sessions from X2go server
+ logger('cleaning up all running sessions from X2go server: %s' % args.server, x2go.loglevel_NOTICE, )
+ cli.clean_sessions(s_hash)
+
+
+def new_session(cli, s_hash):
+ # start a new session and run a command
+ logger('starting a new X2go session', x2go.loglevel_INFO, )
+ logger('Command for new session is: %s' % args.command, x2go.loglevel_DEBUG, )
+ cli.start_session(s_hash)
+
+
+def resume_session(cli, s_hash):
+ # resume a running session
+ logger('resuming X2go session: %s' % args.resume, x2go.loglevel_INFO, )
+ available_sessions = cli.list_sessions(s_hash)
+ if args.resume in available_sessions.keys():
+ cli.resume_session(s_hash, args.resume)
+ else:
+ runtime_error('requested session not available on X2go server [%s]:%s.' % (args.server, args.remote_ssh_port), exitcode=20)
+
+
+def suspend_session(cli, s_hash):
+ # send a suspend request to a session
+ logger('requesting X2go session suspend of session: %s' % args.suspend, x2go.loglevel_INFO, )
+ available_sessions = cli.list_sessions(s_hash)
+ if args.suspend in available_sessions.keys():
+ cli.suspend_session(s_hash, args.suspend)
+ else:
+ runtime_error('requested session not available on X2go server [%s]:%s.' % (args.server, args.remote_ssh_port), exitcode=21)
+
+def terminate_session(cli, s_hash):
+ # send a terminate request to a session
+ logger('requesting X2go session terminate of session: %s' % args.terminate, x2go.loglevel_INFO, )
+ available_sessions = cli.list_sessions(s_hash)
+ if args.terminate in available_sessions.keys():
+ cli.terminate_session(s_hash, args.terminate)
+ else:
+ runtime_error('requested session not available on X2go server [%s]:%s.' % (args.server, args.remote_ssh_port), exitcode=22)
+
+
+if __name__ == '__main__':
+
+
+ # parse command line
+ parser, args = parseargs()
+
+ # initialize the X2GoClient context and start the connection to the X2go server
+ logger('preparing requested X2go session', x2go.loglevel_NOTICE, )
+
+ try:
+ x2goclient = x2go.X2goClient(logger=liblogger)
+ x2go_session_hash = x2goclient.register_session(args.server, port=int(args.remote_ssh_port),
+ username=args.username,
+ password=args.password,
+ key_filename=args.ssh_privkey,
+ add_to_known_hosts=args.add_to_known_hosts,
+ profile_name = 'Pyhoca-Client_Session',
+ session_type=args.session_type,
+ link=args.link,
+ geometry=args.geometry,
+ pack=args.pack,
+ cache_type='unix-kde',
+ kblayout=args.kbd_layout,
+ kbtype=args.kbd_type,
+ snd_system=args.sound,
+ printing=args.printing,
+ print_action=args.print_action,
+ print_action_args=print_action_args,
+ cmd=args.command)
+ x2goclient.with_session(x2go_session_hash).load_host_keys(ssh_known_hosts_filename)
+ connected = False
+ force_password_auth = False
+ while not connected:
+ try:
+ x2goclient.connect_session(x2go_session_hash, password=args.password, force_password_auth=force_password_auth)
+ connected = True
+ except x2go.AuthenticationException:
+ force_password_auth = True
+ args.password = getpass.getpass()
+ except x2go.PasswordRequiredException:
+ args.password = getpass.getpass()
+ except x2go.BadHostKeyException:
+ runtime_error('SSH host key verification for remote host [%s]:%s failed' % (args.server, args.remote_ssh_port), exitcode=-254)
+ except x2go.SSHException, e:
+ runtime_error(str(e), exitcode=253)
+
+ if args.clean_sessions:
+ clean_sessions(x2goclient, x2go_session_hash)
+
+ # go through the possible X2go client modes
+ if args.list_sessions:
+ # print a beautified session list for the user
+ list_sessions(x2goclient, x2go_session_hash)
+ sys.exit(0)
+
+ if args.resume:
+ resume_session(x2goclient, x2go_session_hash)
+
+ elif args.suspend:
+ suspend_session(x2goclient, x2go_session_hash)
+
+ elif args.terminate:
+ terminate_session(x2goclient, x2go_session_hash)
+
+ elif args.new:
+ new_session(x2goclient, x2go_session_hash)
+
+
+ if args.new or args.resume:
+ # give the session some time to come up...
+ # no CTRL-C is allowed during this phase...
+ i=0
+ logger("give the X2go session some time to come up...", x2go.loglevel_NOTICE, )
+ while i < args.time_to_wait:
+ time.sleep(1)
+ i+=1
+
+ if x2goclient.session_ok(x2go_session_hash):
+
+ profile_name = x2goclient.get_profile_name(x2go_session_hash)
+ session_name = x2goclient.get_session_name(x2go_session_hash)
+ logger("X2go session is now running, the X2go client's profile name is: %s." % profile_name, x2go.loglevel_INFO, )
+ logger("X2go session name is: %s." % session_name, x2go.loglevel_INFO, )
+ logger("Press CTRL+C to suspend the running session.", x2go.loglevel_NOTICE, )
+ try:
+
+ session_duration = 0
+ mounted = False
+ while x2goclient.session_ok(x2go_session_hash):
+ time.sleep(2)
+ session_duration +=2
+
+ if session_duration > 2 and not mounted and args.share_local_folders is not None:
+ if x2goclient.with_session(x2go_session_hash).get_transport().reverse_tunnels['sshfs'][1] is not None:
+ for _folder in args.share_local_folders:
+ x2goclient.share_local_folder(x2go_session_hash, _folder)
+ mounted = True
+
+ # wait a little longer before telling the user what had happened
+ time.sleep(2)
+
+ if x2goclient.has_terminated(x2go_session_hash):
+ logger("X2go session %s has terminated." % session_name, x2go.loglevel_NOTICE, )
+ elif x2goclient.is_suspended(x2go_session_hash):
+ logger("X2go session %s has been suspended." % session_name, x2go.loglevel_NOTICE, )
+ elif x2goclient.is_running(x2go_session_hash):
+ logger("X2go session %s has been moved to a different screen." % session_name, x2go.loglevel_NOTICE, )
+
+ except KeyboardInterrupt:
+ logger("Suspending X2go session %s." % session_name, x2go.loglevel_INFO, )
+ x2goclient.suspend_session(x2go_session_hash)
+ # giving nxproxy's SSH tunnel some time to settle
+ time.sleep(2)
+ logger("X2go session %s has been suspended." % session_name, x2go.loglevel_NOTICE, )
+
+ sys.exit(0)
+
+ except (KeyboardInterrupt, SystemExit), e:
+ x2go.x2go_cleanup(e)
+
diff --git a/x2go b/x2go
new file mode 120000
index 00000000..64abb4d8
--- /dev/null
+++ b/x2go
@@ -0,0 +1 @@
+../../../python/python-x2go/trunk/x2go
\ No newline at end of file
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
More information about the x2go-commits
mailing list