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 a077a980c6b5e7e2bd4b09c62c4c29fe590a9b1b
Author: mike <mike@cdb5e8f1-f799-4276-8919-bce57fd91830>
Date: Sun Nov 7 00:34:00 2010 +0000
* added --session-profile option (run a session profile as configured in ~/.x2goclient/sessions)
git-svn-id: https://svn.das-netzwerkteam.de/x2go/pyhoca-cli/trunk@31 cdb5e8f1-f799-4276-8919-bce57fd91830
---
pyhoca-cli | 4 ++++
pyhoca/cli/frontend.py | 20 ++++++++++----------
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/pyhoca-cli b/pyhoca-cli
index 974f7856..aedcdaa4 100755
--- a/pyhoca-cli
+++ b/pyhoca-cli
@@ -203,6 +203,10 @@ Possible values for the --pack NX option are:
if not x2go.utils.is_in_nx3packmethods(a.pack):
runtime_error("unknown pack method '%s'" % args.pack, parser=p, exitcode=10)
+ else:
+ if not (a.resume or a.suspend or a.terminate or a.list_sessions):
+ a.new = True
+
# X2go printing
if ((a.pdfview_cmd and a.printer) or
(a.pdfview_cmd and a.save_to_folder) or
diff --git a/pyhoca/cli/frontend.py b/pyhoca/cli/frontend.py
index 11ff709a..5546e41a 100644
--- a/pyhoca/cli/frontend.py
+++ b/pyhoca/cli/frontend.py
@@ -118,7 +118,10 @@ class PyHocaCLI(x2go.X2goClient):
"""
# start a new session and run a command
self.logger('starting a new X2go session', x2go.loglevel_INFO, )
- self.logger('Command for new session is: %s' % self.args.command, x2go.loglevel_DEBUG, )
+ if self.args.session_profile is None:
+ self.logger('command for new session is: %s' % self.args.command, loglevel=x2go.loglevel_DEBUG, )
+ else:
+ self.logger('command from session profile to run is: %s' % self.session_registry(self.x2go_session_hash).session_params['cmd'], loglevel=x2go.loglevel_DEBUG, )
self._X2goClient__start_session(s_hash)
@@ -176,12 +179,12 @@ class PyHocaCLI(x2go.X2goClient):
self.logger('preparing requested X2go session', x2go.loglevel_NOTICE, )
x2go.X2goClient.__init__(self, logger=liblogger)
- _profile_id = None
- if self.args.session_profile:
- self.load_session_profiles()
- _profile_id = self.get_profile_id(self.args.session_profile)
- if not _profile_id:
+ if self.args.session_profile and self.has_session_profile(self.args.session_profile):
+
+ self.x2go_session_hash = self.register_session(profile_name=self.args.session_profile)
+
+ else:
self.x2go_session_hash = self.register_session(args.server, port=int(self.args.remote_ssh_port),
username=self.args.username,
@@ -202,9 +205,6 @@ class PyHocaCLI(x2go.X2goClient):
print_action_args=self.args.print_action_args,
share_local_folders=self.args.share_local_folders,
cmd=self.args.command)
- else:
-
- self.x2go_session_hash = self.register_session(profile_id = _profile_id)
self.with_session(self.x2go_session_hash).load_host_keys(ssh_known_hosts_filename)
@@ -256,7 +256,7 @@ class PyHocaCLI(x2go.X2goClient):
self.new_session(self.x2go_session_hash)
# finally call the MainLoop of PyHocaCLI
- if not (self.args.new or self.args.resume):
+ if not (self.args.new or self.args.resume or self.args.session_profile):
sys.exit(0)
# give the session some time to come up...
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
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 5cf374abea625fe956a7db380b3e1f7a00f6b4e5
Author: mike <mike@cdb5e8f1-f799-4276-8919-bce57fd91830>
Date: Mon Nov 1 09:50:29 2010 +0000
* fixed pyhoca-cli
git-svn-id: https://svn.das-netzwerkteam.de/x2go/pyhoca-cli/trunk@20 cdb5e8f1-f799-4276-8919-bce57fd91830
---
pyhoca-cli | 5 ++--
pyhoca/cli/frontend.py | 62 ++++++++++++++++++++++++++++++++++++++------------
2 files changed, 50 insertions(+), 17 deletions(-)
diff --git a/pyhoca-cli b/pyhoca-cli
index 632c0fa9..97bb404e 100755
--- a/pyhoca-cli
+++ b/pyhoca-cli
@@ -45,7 +45,7 @@ from x2go.defaults import DEFAULT_PDFVIEW_CMD
from x2go.defaults import DEFAULT_PDFSAVE_LOCATION
from x2go.defaults import DEFAULT_PRINTCMD_CMD
-from pyhoca.cli import current_home, PyHocaCLI
+from pyhoca.cli import current_home, PyHocaCLI, runtime_error
# version information
PROG_NAME = os.path.basename(sys.argv[0])
@@ -136,8 +136,8 @@ def version():
def parseargs():
- global DEBUG
global logger
+ global liblogger
p = argparse.ArgumentParser(description='X2go command line client implemented in Python.',\
epilog="""
@@ -296,6 +296,7 @@ if __name__ == '__main__':
thisPyHocaCLI = PyHocaCLI(args, logger=logger, liblogger=liblogger)
thisPyHocaCLI.authenticate()
thisPyHocaCLI.MainLoop()
+
sys.exit(0)
except (KeyboardInterrupt, SystemExit), e:
diff --git a/pyhoca/cli/frontend.py b/pyhoca/cli/frontend.py
index 15a85d74..6706c32e 100644
--- a/pyhoca/cli/frontend.py
+++ b/pyhoca/cli/frontend.py
@@ -44,12 +44,22 @@ ssh_config_filename = os.path.join(current_home, '.ssh', 'config')
if not os.path.isfile(ssh_config_filename):
self._touch_file(ssh_config_filename)
-def _touch_file(self, filename):
+def _touch_file(filename):
if not os.path.isfile(filename):
f = open(filename, 'w')
f.close()
+# sometimes we have to fail...
+def runtime_error(m, parser=None, exitcode=-1):
+ """\
+ STILL UNDOCUMENTED
+ """
+ if parser is not None:
+ parser.print_usage()
+ sys.stderr.write ("%s: error: %s\n" % (os.path.basename(sys.argv[0]), m))
+ sys.exit(exitcode)
+
class PyHocaCLI(x2go.X2goClient):
"""\
@@ -57,13 +67,9 @@ class PyHocaCLI(x2go.X2goClient):
"""
x2go_session_hash = None
- # sometimes we have to fail...
- def runtime_error(self, m, exitcode=-1):
- """\
- STILL UNDOCUMENTED
- """
- sys.stderr.write ("%s: error: %s\n" % (sys.argv[0], m))
- sys.exit(exitcode)
+
+ def _runtime_error(self, m, exitcode=-1):
+ runtime_error(m, exitcode=exitcode)
def list_sessions(self, s_hash):
@@ -103,7 +109,7 @@ class PyHocaCLI(x2go.X2goClient):
"""
# clean all sessions from X2go server
self.logger('cleaning up all running sessions from X2go server: %s' % self.args.server, x2go.loglevel_NOTICE, )
- X2goClient.clean_sessions(self, s_hash)
+ x2go.X2goClient.clean_sessions(self, s_hash)
def new_session(self, s_hash):
@@ -113,7 +119,7 @@ class PyHocaCLI(x2go.X2goClient):
# start a new session and run a command
self.logger('starting a new X2go session', x2go.loglevel_INFO, )
self.logger('Command for new session is: %s' % self.args.command, x2go.loglevel_DEBUG, )
- self.start_session(s_hash)
+ x2go.X2goClient.start_session(self, s_hash)
def resume_session(self, s_hash):
@@ -126,7 +132,7 @@ class PyHocaCLI(x2go.X2goClient):
if self.args.resume in available_sessions.keys():
x2go.X2goClient.resume_session(self, s_hash, self.args.resume)
else:
- self.runtime_error('requested session not available on X2go server [%s]:%s.' % (self.args.server, self.args.remote_ssh_port), exitcode=20)
+ self._runtime_error('requested session not available on X2go server [%s]:%s.' % (self.args.server, self.args.remote_ssh_port), exitcode=20)
def suspend_session(self, s_hash):
@@ -139,7 +145,7 @@ class PyHocaCLI(x2go.X2goClient):
if self.args.suspend in available_sessions.keys():
x2go.X2goClient.suspend_session(self, s_hash, self.args.suspend)
else:
- self.runtime_error('requested session not available on X2go server [%s]:%s.' % (self.args.server, self.args.remote_ssh_port), exitcode=21)
+ self._runtime_error('requested session not available on X2go server [%s]:%s.' % (self.args.server, self.args.remote_ssh_port), exitcode=21)
def terminate_session(self, s_hash):
@@ -152,7 +158,7 @@ class PyHocaCLI(x2go.X2goClient):
if self.args.terminate in available_sessions.keys():
x2go.X2goClient.terminate_session(self, s_hash, self.args.terminate)
else:
- self.runtime_error('requested session not available on X2go server [%s]:%s.' % (self.args.server, self.args.remote_ssh_port), exitcode=22)
+ self._runtime_error('requested session not available on X2go server [%s]:%s.' % (self.args.server, self.args.remote_ssh_port), exitcode=22)
def __init__(self, args, logger=None, liblogger=None):
@@ -164,6 +170,7 @@ class PyHocaCLI(x2go.X2goClient):
logger = x2go.X2goLogger(tag='PyHocaCLI')
else:
self.logger = logger
+ self.logger.tag = 'PyHocaCLI'
# initialize the X2goClient context and start the connection to the X2go server
self.logger('preparing requested X2go session', x2go.loglevel_NOTICE, )
@@ -206,15 +213,40 @@ class PyHocaCLI(x2go.X2goClient):
except x2go.PasswordRequiredException:
self.args.password = getpass.getpass()
except x2go.BadHostKeyException:
- self.runtime_error('SSH host key verification for remote host [%s]:%s failed' % (self.args.server, self.args.remote_ssh_port), exitcode=-254)
+ self._runtime_error('SSH host key verification for remote host [%s]:%s failed' % (self.args.server, self.args.remote_ssh_port), exitcode=-254)
except x2go.SSHException, e:
- self.runtime_error(str(e), exitcode=253)
+ self._runtime_error(str(e), exitcode=253)
def MainLoop(self):
"""\
STILL UNDOCUMENTED
"""
+ if self.args.clean_sessions:
+ self.clean_sessions(self.x2go_session_hash)
+
+ # go through the possible X2go client modes
+ if self.args.list_sessions:
+ # print a beautified session list for the user
+ self.list_sessions(self.x2go_session_hash)
+ sys.exit(0)
+
+ if self.args.resume:
+ self.resume_session(self.x2go_session_hash)
+
+ elif self.args.suspend:
+ self.suspend_session(self.x2go_session_hash)
+
+ elif self.args.terminate:
+ self.terminate_session(self.x2go_session_hash)
+
+ elif self.args.new:
+ self.new_session(self.x2go_session_hash)
+
+ # finally call the MainLoop of PyHocaCLI
+ if not (self.args.new or self.args.resume):
+ sys.exit(0)
+
# give the session some time to come up...
# no CTRL-C is allowed during this phase...
i=0
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
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 4e17df006c8eb36d7247ad56abcfc60dda233501
Author: mike <mike@cdb5e8f1-f799-4276-8919-bce57fd91830>
Date: Fri Nov 5 23:50:49 2010 +0000
* intermediate check-in on the way of proper session profile handling
git-svn-id: https://svn.das-netzwerkteam.de/x2go/pyhoca-cli/trunk@28 cdb5e8f1-f799-4276-8919-bce57fd91830
---
pyhoca-cli | 67 ++++++++++++++++++++++++++++----------------------
pyhoca/cli/frontend.py | 55 ++++++++++++++++++++++-------------------
2 files changed, 67 insertions(+), 55 deletions(-)
diff --git a/pyhoca-cli b/pyhoca-cli
index 97bb404e..974f7856 100755
--- a/pyhoca-cli
+++ b/pyhoca-cli
@@ -76,7 +76,7 @@ action_options = [
{'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', },
+ {'args':['-P','--session-profile'], 'default': None, 'help': 'load x2goclient session profiles and use the session profile SESSION_PROFILE', },
]
# debug options...
debug_options = [
@@ -177,20 +177,6 @@ Possible values for the --pack NX option are:
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
@@ -201,6 +187,22 @@ Possible values for the --pack NX option are:
except ValueError:
runtime_error("--time_to_wait value needs to be an integer value", parser=p, exitcode=80)
+ if not a.session_profile:
+
+ # 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)
+
# X2go printing
if ((a.pdfview_cmd and a.printer) or
(a.pdfview_cmd and a.save_to_folder) or
@@ -257,21 +259,26 @@ Possible values for the --pack NX option are:
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()
- from pyhoca.cli import ssh_config_filename
- 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()
+
+ if a.server:
+
+ ##### TODO: ssh_config to be moved into Python X2go!!!!
+ ###
+ ### initialize SSH context
+ ###
+ # check if SERVER is in .ssh/config file, extract information from there...
+ ssh_config = paramiko.SSHConfig()
+ from pyhoca.cli import ssh_config_filename
+ 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)
diff --git a/pyhoca/cli/frontend.py b/pyhoca/cli/frontend.py
index 6df99468..11ff709a 100644
--- a/pyhoca/cli/frontend.py
+++ b/pyhoca/cli/frontend.py
@@ -176,24 +176,36 @@ class PyHocaCLI(x2go.X2goClient):
self.logger('preparing requested X2go session', x2go.loglevel_NOTICE, )
x2go.X2goClient.__init__(self, logger=liblogger)
- self.x2go_session_hash = self.register_session(args.server, port=int(self.args.remote_ssh_port),
- username=self.args.username,
- password=self.args.password,
- key_filename=self.args.ssh_privkey,
- add_to_known_hosts=self.args.add_to_known_hosts,
- profile_name = 'Pyhoca-Client_Session',
- session_type=self.args.session_type,
- link=self.args.link,
- geometry=self.args.geometry,
- pack=self.args.pack,
- cache_type='unix-kde',
- kblayout=self.args.kbd_layout,
- kbtype=self.args.kbd_type,
- snd_system=self.args.sound,
- printing=self.args.printing,
- print_action=self.args.print_action,
- print_action_args=self.args.print_action_args,
- cmd=self.args.command)
+ _profile_id = None
+ if self.args.session_profile:
+ self.load_session_profiles()
+ _profile_id = self.get_profile_id(self.args.session_profile)
+
+ if not _profile_id:
+
+ self.x2go_session_hash = self.register_session(args.server, port=int(self.args.remote_ssh_port),
+ username=self.args.username,
+ password=self.args.password,
+ key_filename=self.args.ssh_privkey,
+ add_to_known_hosts=self.args.add_to_known_hosts,
+ custom_profile_name = 'Pyhoca-Client_Session',
+ session_type=self.args.session_type,
+ link=self.args.link,
+ geometry=self.args.geometry,
+ pack=self.args.pack,
+ cache_type='unix-kde',
+ kblayout=self.args.kbd_layout,
+ kbtype=self.args.kbd_type,
+ snd_system=self.args.sound,
+ printing=self.args.printing,
+ print_action=self.args.print_action,
+ print_action_args=self.args.print_action_args,
+ share_local_folders=self.args.share_local_folders,
+ cmd=self.args.command)
+ else:
+
+ self.x2go_session_hash = self.register_session(profile_id = _profile_id)
+
self.with_session(self.x2go_session_hash).load_host_keys(ssh_known_hosts_filename)
@@ -245,7 +257,6 @@ class PyHocaCLI(x2go.X2goClient):
# finally call the MainLoop of PyHocaCLI
if not (self.args.new or self.args.resume):
- print 'exiting'
sys.exit(0)
# give the session some time to come up...
@@ -271,12 +282,6 @@ class PyHocaCLI(x2go.X2goClient):
time.sleep(2)
session_duration +=2
- if session_duration > 2 and not mounted and self.args.share_local_folders is not None:
- if self.with_session(self.x2go_session_hash).get_transport().reverse_tunnels['sshfs'][1] is not None:
- for _folder in self.args.share_local_folders:
- self.share_local_folder(self.x2go_session_hash, _folder)
- mounted = True
-
# wait a little longer before telling the user what had happened
time.sleep(2)
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
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 64696c5d103939e4ca68537f322da1aa171d07c3
Author: mike <mike@cdb5e8f1-f799-4276-8919-bce57fd91830>
Date: Mon Nov 1 09:51:07 2010 +0000
* re-added pyhoca-cli symlinks to Python X2go working copy
git-svn-id: https://svn.das-netzwerkteam.de/x2go/pyhoca-cli/trunk@21 cdb5e8f1-f799-4276-8919-bce57fd91830
---
pyhoca/cli/x2go | 1 +
x2go | 1 +
2 files changed, 2 insertions(+)
diff --git a/pyhoca/cli/x2go b/pyhoca/cli/x2go
new file mode 120000
index 00000000..b7003701
--- /dev/null
+++ b/pyhoca/cli/x2go
@@ -0,0 +1 @@
+../../../../python/python-x2go/trunk/x2go
\ No newline at end of file
diff --git a/x2go b/x2go
new file mode 120000
index 00000000..3e762901
--- /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
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@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(a)das-netzwerkteam.de>
+
+Contributors:
+ Jörg Sawatzki <joerg.sawatzki(a)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(a)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(a)das-netzwerkteam.de>
+
+Contributors:
+ Jörg Sawatzki <joerg.sawatzki(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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
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 e886078fce0dea32d68195037a0b5f73ffb429ab
Author: mike <mike@cdb5e8f1-f799-4276-8919-bce57fd91830>
Date: Thu Oct 28 21:24:00 2010 +0000
* remove ppring import
* added __doc__ strings that allude that documentation work is still
missing
git-svn-id: https://svn.das-netzwerkteam.de/x2go/pyhoca-cli/trunk@14 cdb5e8f1-f799-4276-8919-bce57fd91830
---
pyhoca/cli/frontend.py | 37 ++++++++++++++++++++++++++++++-------
1 file changed, 30 insertions(+), 7 deletions(-)
diff --git a/pyhoca/cli/frontend.py b/pyhoca/cli/frontend.py
index 4c07f325..7c41b537 100644
--- a/pyhoca/cli/frontend.py
+++ b/pyhoca/cli/frontend.py
@@ -24,15 +24,11 @@
import sys, os
import time
-import argparse
import getpass
import x2go
import paramiko
from types import *
-# for debugging
-import pprint
-
# a list of available X2go print actions
from x2go.defaults import X2GO_PRINT_ACTIONS
@@ -63,11 +59,17 @@ class PyHocaCLI(x2go.X2goClient):
# sometimes we have to fail...
def runtime_error(self, m, exitcode=-1):
+ """\
+ STILL UNDOCUMENTED
+ """
sys.stderr.write ("%s: error: %s\n" % (sys.argv[0], m))
sys.exit(exitcode)
def list_sessions(self, s_hash):
+ """\
+ STILL UNDOCUMENTED
+ """
# retrieve a session list
print
print "Available runing/suspended X2go sessions"
@@ -96,12 +98,18 @@ class PyHocaCLI(x2go.X2goClient):
def clean_sessions(self, s_hash):
+ """\
+ STILL UNDOCUMENTED
+ """
# clean all sessions from X2go server
self.logger('cleaning up all running sessions from X2go server: %s' % self.args.server, x2go.loglevel_NOTICE, )
X2goClient.clean_sessions(self, s_hash)
def new_session(self, s_hash):
+ """\
+ STILL UNDOCUMENTED
+ """
# start a new session and run a command
self.logger('starting a new X2go session', x2go.loglevel_INFO, )
self.logger('Command for new session is: %s' % self.args.command, x2go.loglevel_DEBUG, )
@@ -109,6 +117,9 @@ class PyHocaCLI(x2go.X2goClient):
def resume_session(self, s_hash):
+ """\
+ STILL UNDOCUMENTED
+ """
# resume a running session
self.logger('resuming X2go session: %s' % self.args.resume, x2go.loglevel_INFO, )
available_sessions = self.list_sessions(s_hash)
@@ -119,6 +130,9 @@ class PyHocaCLI(x2go.X2goClient):
def suspend_session(self, s_hash):
+ """\
+ STILL UNDOCUMENTED
+ """
# send a suspend request to a session
self.logger('requesting X2go session suspend of session: %s' % self.args.suspend, x2go.loglevel_INFO, )
available_sessions = self.list_sessions(s_hash)
@@ -129,6 +143,9 @@ class PyHocaCLI(x2go.X2goClient):
def terminate_session(self, s_hash):
+ """\
+ STILL UNDOCUMENTED
+ """
# send a terminate request to a session
self.logger('requesting X2go session terminate of session: %s' % self.args.terminate, x2go.loglevel_INFO, )
available_sessions = self.list_sessions(s_hash)
@@ -139,7 +156,9 @@ class PyHocaCLI(x2go.X2goClient):
def __init__(self, args, logger=None, liblogger=None):
-
+ """\
+ STILL UNDOCUMENTED
+ """
self.args = args
if logger is None:
logger = x2go.X2goLogger(tag='PyHocaCLI')
@@ -170,7 +189,9 @@ class PyHocaCLI(x2go.X2goClient):
def authenticate(self):
-
+ """\
+ STILL UNDOCUMENTED
+ """
connected = False
force_password_auth = False
while not connected:
@@ -189,7 +210,9 @@ class PyHocaCLI(x2go.X2goClient):
def MainLoop(self):
-
+ """\
+ STILL UNDOCUMENTED
+ """
# give the session some time to come up...
# no CTRL-C is allowed during this phase...
i=0
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
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 052f0527497ec8b9a5a327dbad270c4c6bb47490
Author: mike <mike@cdb5e8f1-f799-4276-8919-bce57fd91830>
Date: Thu Oct 28 21:19:05 2010 +0000
* completely egg'ified / class'ified PyHocaCLI
-> PyHocaCLI(args, logger, liblogger) can now be called from within
your programmes
git-svn-id: https://svn.das-netzwerkteam.de/x2go/pyhoca-cli/trunk@13 cdb5e8f1-f799-4276-8919-bce57fd91830
---
debian/changelog | 6 +
pyhoca-cli | 260 ++++----------------------------
pyhoca/__init__.py | 19 +++
pyhoca/cli/{__init.py__ => __init__.py} | 2 +
pyhoca/cli/frontend.py | 226 ++++++++++++++++++++++++++-
pyhoca/cli/x2go | 2 +-
setup.py | 7 +-
x2go | 2 +-
8 files changed, 284 insertions(+), 240 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index cadeb438..0ff76868 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+pyhoca-cli (0.1.0-0~nwt1) lucid maverick testing unstable; urgency=low
+
+ * class'ified and egg'ified: PyHocaCLI is now a class
+
+ -- Mike Gabriel <m.gabriel(a)das-netzwerkteam.de> Thu, 28 Oct 2010 23:30:00 +0200
+
pyhoca-cli (0.0.15-0~nwt1) lucid maverick testing unstable; urgency=low
* updated man page
diff --git a/pyhoca-cli b/pyhoca-cli
index 12da2004..fdda7332 100755
--- a/pyhoca-cli
+++ b/pyhoca-cli
@@ -1,28 +1,26 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-"""
- Copyright (C) 2010 by Mike Gabriel <m.gabriel(a)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(a)web.de>
-"""
-
+# Copyright (C) 2010 by Mike Gabriel <m.gabriel(a)das-netzwerkteam.de>
+#
+# PyHoca CLI 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.
+#
+# PyHoca CLI 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:
+# 2010 Dick Kniep <dick.kniep(a)lindix.nl>
+# 2010 Jörg Sawatzki <joerg.sawatzki(a)web.de>
###
### module section
@@ -41,15 +39,18 @@ 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
+from pyhoca.cli import PyHocaCLI
+
# version information
PROG_NAME = os.path.basename(sys.argv[0])
PROG_PID = os.getpid()
-VERSION="0.0.14"
+VERSION="0.1.0"
VERSION_TEXT="""
%s[%s] - an X2go command line client written in Python
----------------------------------------------------------------------
@@ -59,32 +60,11 @@ VERSION: %s
""" % (PROG_NAME, PROG_PID, VERSION)
+PRINT_ACTIONS = X2GO_PRINT_ACTIONS.keys()
+print_actions_args = {}
-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
@@ -155,18 +135,11 @@ def version():
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
+ global logger
p = argparse.ArgumentParser(description='X2go command line client implemented in Python.',\
epilog="""
@@ -290,6 +263,7 @@ Possible values for the --pack NX option are:
###
# check if SERVER is in .ssh/config file, extract information from there...
ssh_config = paramiko.SSHConfig()
+ from pyhoca.cli import ssh_config_filename
ssh_config_fileobj = open(ssh_config_filename)
ssh_config.parse(ssh_config_fileobj)
ssh_host = ssh_config.lookup(a.server)
@@ -310,79 +284,8 @@ Possible values for the --pack NX option are:
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()
@@ -390,111 +293,10 @@ if __name__ == '__main__':
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, )
+ thisPyHocaCLI = PyHocaCLI(args, logger=logger, liblogger=liblogger)
+ thisPyHocaCLI.authenticate()
+ thisPyHocaCLI.MainLoop()
sys.exit(0)
except (KeyboardInterrupt, SystemExit), e:
diff --git a/pyhoca/__init__.py b/pyhoca/__init__.py
index e69de29b..6d579482 100644
--- a/pyhoca/__init__.py
+++ b/pyhoca/__init__.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2010 by Dick Kniep <m.gabriel(a)das-netzwerkteam.de>
+#
+# PyHoca CLI 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.
+#
+# PyHoca CLI 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.,
+# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
diff --git a/pyhoca/cli/__init.py__ b/pyhoca/cli/__init__.py
similarity index 94%
rename from pyhoca/cli/__init.py__
rename to pyhoca/cli/__init__.py
index aa21dc44..aaeed7ba 100644
--- a/pyhoca/cli/__init.py__
+++ b/pyhoca/cli/__init__.py
@@ -20,4 +20,6 @@
"""\
STILL UNDOCUMENTED
"""
+__VERSION__ = "0.1.0"
+
from frontend import *
\ No newline at end of file
diff --git a/pyhoca/cli/frontend.py b/pyhoca/cli/frontend.py
index 47a11461..4c07f325 100644
--- a/pyhoca/cli/frontend.py
+++ b/pyhoca/cli/frontend.py
@@ -1,6 +1,7 @@
+#!/usr/bin/python
# -*- coding: utf-8 -*-
-# Copyright (C) 2010 by Dick Kniep <dick.kniep(a)lindix.nl>
+# Copyright (C) 2010 by Mike Gabriel <m.gabriel(a)das-netzwerkteam.de>
#
# PyHoca CLI is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -15,10 +16,223 @@
# 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.,
-# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Contributors to the code of this programme:
+# 2010 Dick Kniep <dick.kniep(a)lindix.nl>
+# 2010 Jörg Sawatzki <joerg.sawatzki(a)web.de>
+
+import sys, os
+import time
+import argparse
+import getpass
+import x2go
+import paramiko
+from types import *
+
+# for debugging
+import pprint
+
+# a list of available X2go print actions
+from x2go.defaults import X2GO_PRINT_ACTIONS
+
+# 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):
+ self._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):
+ self._touch_file(ssh_config_filename)
+
+def _touch_file(self, filename):
+
+ if not os.path.isfile(filename):
+ f = open(filename, 'w')
+ f.close()
+
+
+class PyHocaCLI(x2go.X2goClient):
+ """\
+ STILL UNDOCUMENTED
+ """
+ x2go_session_hash = None
+
+ # sometimes we have to fail...
+ def runtime_error(self, m, exitcode=-1):
+ sys.stderr.write ("%s: error: %s\n" % (sys.argv[0], m))
+ sys.exit(exitcode)
+
+
+ def list_sessions(self, s_hash):
+ # retrieve a session list
+ print
+ print "Available runing/suspended X2go sessions"
+ print "========================================"
+ print "Hostname: [%s]:%s" % self.get_server(s_hash)
+ print "Username: %s" % self.get_username(s_hash)
+ print
+ session_infos = x2go.X2goClient.list_sessions(self, 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(self, s_hash):
+ # clean all sessions from X2go server
+ self.logger('cleaning up all running sessions from X2go server: %s' % self.args.server, x2go.loglevel_NOTICE, )
+ X2goClient.clean_sessions(self, s_hash)
+
+
+ def new_session(self, s_hash):
+ # start a new session and run a command
+ self.logger('starting a new X2go session', x2go.loglevel_INFO, )
+ self.logger('Command for new session is: %s' % self.args.command, x2go.loglevel_DEBUG, )
+ self.start_session(s_hash)
+
+
+ def resume_session(self, s_hash):
+ # resume a running session
+ self.logger('resuming X2go session: %s' % self.args.resume, x2go.loglevel_INFO, )
+ available_sessions = self.list_sessions(s_hash)
+ if self.args.resume in available_sessions.keys():
+ x2go.X2goClient.resume_session(self, s_hash, self.args.resume)
+ else:
+ self.runtime_error('requested session not available on X2go server [%s]:%s.' % (self.args.server, self.args.remote_ssh_port), exitcode=20)
+
+
+ def suspend_session(self, s_hash):
+ # send a suspend request to a session
+ self.logger('requesting X2go session suspend of session: %s' % self.args.suspend, x2go.loglevel_INFO, )
+ available_sessions = self.list_sessions(s_hash)
+ if self.args.suspend in available_sessions.keys():
+ x2go.X2goClient.suspend_session(self, s_hash, self.args.suspend)
+ else:
+ self.runtime_error('requested session not available on X2go server [%s]:%s.' % (self.args.server, self.args.remote_ssh_port), exitcode=21)
+
+
+ def terminate_session(self, s_hash):
+ # send a terminate request to a session
+ self.logger('requesting X2go session terminate of session: %s' % self.args.terminate, x2go.loglevel_INFO, )
+ available_sessions = self.list_sessions(s_hash)
+ if self.args.terminate in available_sessions.keys():
+ x2go.X2goClient.terminate_session(self, s_hash, self.args.terminate)
+ else:
+ self.runtime_error('requested session not available on X2go server [%s]:%s.' % (self.args.server, self.args.remote_ssh_port), exitcode=22)
+
+
+ def __init__(self, args, logger=None, liblogger=None):
+
+ self.args = args
+ if logger is None:
+ logger = x2go.X2goLogger(tag='PyHocaCLI')
+
+ # initialize the X2goClient context and start the connection to the X2go server
+ self.logger('preparing requested X2go session', x2go.loglevel_NOTICE, )
+
+ x2go.X2goClient.__init__(logger=liblogger)
+ self.x2go_session_hash = self.register_session(args.server, port=int(self.args.remote_ssh_port),
+ username=self.args.username,
+ password=self.args.password,
+ key_filename=self.args.ssh_privkey,
+ add_to_known_hosts=self.args.add_to_known_hosts,
+ profile_name = 'Pyhoca-Client_Session',
+ session_type=self.args.session_type,
+ link=self.args.link,
+ geometry=self.args.geometry,
+ pack=self.args.pack,
+ cache_type='unix-kde',
+ kblayout=self.args.kbd_layout,
+ kbtype=self.args.kbd_type,
+ snd_system=self.args.sound,
+ printing=self.args.printing,
+ print_action=self.args.print_action,
+ print_action_args=print_action_args,
+ cmd=self.args.command)
+ self.with_session(self.x2go_session_hash).load_host_keys(ssh_known_hosts_filename)
+
+
+ def authenticate(self):
+
+ connected = False
+ force_password_auth = False
+ while not connected:
+ try:
+ self.connect_session(self.x2go_session_hash, password=self.args.password, force_password_auth=force_password_auth)
+ connected = True
+ except x2go.AuthenticationException:
+ force_password_auth = True
+ self.args.password = getpass.getpass()
+ except x2go.PasswordRequiredException:
+ self.args.password = getpass.getpass()
+ except x2go.BadHostKeyException:
+ self.runtime_error('SSH host key verification for remote host [%s]:%s failed' % (self.args.server, self.args.remote_ssh_port), exitcode=-254)
+ except x2go.SSHException, e:
+ self.runtime_error(str(e), exitcode=253)
+
+
+ def MainLoop(self):
+
+ # give the session some time to come up...
+ # no CTRL-C is allowed during this phase...
+ i=0
+ self.logger("give the X2go session some time to come up...", x2go.loglevel_NOTICE, )
+ while i < self.args.time_to_wait:
+ time.sleep(1)
+ i+=1
+
+ if self.session_ok(self.x2go_session_hash):
+
+ profile_name = self.get_profile_name(self.x2go_session_hash)
+ session_name = self.get_session_name(self.x2go_session_hash)
+ self.logger("X2go session is now running, the X2go client's profile name is: %s." % profile_name, x2go.loglevel_INFO, )
+ self.logger("X2go session name is: %s." % session_name, x2go.loglevel_INFO, )
+ self.logger("Press CTRL+C to suspend the running session.", x2go.loglevel_NOTICE, )
+ try:
+
+ session_duration = 0
+ mounted = False
+ while self.session_ok(self.x2go_session_hash):
+ time.sleep(2)
+ session_duration +=2
+
+ if session_duration > 2 and not mounted and self.args.share_local_folders is not None:
+ if self.with_session(self.x2go_session_hash).get_transport().reverse_tunnels['sshfs'][1] is not None:
+ for _folder in self.args.share_local_folders:
+ self.share_local_folder(self.x2go_session_hash, _folder)
+ mounted = True
+
+ # wait a little longer before telling the user what had happened
+ time.sleep(2)
+
+ if self.has_terminated(self.x2go_session_hash):
+ self.logger("X2go session %s has terminated." % session_name, x2go.loglevel_NOTICE, )
+ elif self.is_suspended(self.x2go_session_hash):
+ self.logger("X2go session %s has been suspended." % session_name, x2go.loglevel_NOTICE, )
+ elif self.is_running(self.x2go_session_hash):
+ self.logger("X2go session %s has been moved to a different screen." % session_name, x2go.loglevel_NOTICE, )
-"""\
-STILL UNDOCUMENTED
-"""
+ except KeyboardInterrupt:
+ self.logger("Suspending X2go session %s." % session_name, x2go.loglevel_INFO, )
+ self.suspend_session(self.x2go_session_hash)
+ # giving nxproxy's SSH tunnel some time to settle
+ time.sleep(2)
+ self.logger("X2go session %s has been suspended." % session_name, x2go.loglevel_NOTICE, )
-class ...
diff --git a/pyhoca/cli/x2go b/pyhoca/cli/x2go
index b7003701..6c7076fe 120000
--- a/pyhoca/cli/x2go
+++ b/pyhoca/cli/x2go
@@ -1 +1 @@
-../../../../python/python-x2go/trunk/x2go
\ No newline at end of file
+../../../../python/python-x2go/trunk/x2go/
\ No newline at end of file
diff --git a/setup.py b/setup.py
index a257db18..3ba5fe43 100755
--- a/setup.py
+++ b/setup.py
@@ -22,13 +22,14 @@ from setuptools import setup, find_packages
import pyhoca.cli
setup(
- name = "pyhoca-cli",
+ name = "PyHoca CLI",
version = pyhoca.cli.__VERSION__,
description = "PyHoca CLI is a cross-platform (Windows, MacOS X, Linux) X2go client for the command line.",
license = 'GPL',
author = 'Mike Gabriel',
url = 'http://www.x2go.org',
- packages = find_packages('.'),
+ packages = [ 'pyhoca.cli', ],
package_dir = {'': '.'},
- install_requires = ['setuptools', ]
+ exclude = [ 'pyhoca.cli.x2go', ],
+ install_requires = [ 'setuptools', ]
)
diff --git a/x2go b/x2go
index 3e762901..74dfe276 120000
--- a/x2go
+++ b/x2go
@@ -1 +1 @@
-../../python/python-x2go/trunk/x2go
\ No newline at end of file
+../../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