The branch, twofactorauth has been updated via 9aef83f1d18bf927d33765836293b2296d87c73a (commit) from 441b8571dbd5d8c641af0237160d008ee3fbcad9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: x2go/cleanup.py | 14 ++++++++++++++ x2go/client.py | 15 ++++++++++++++- x2go/defaults.py | 10 +++++----- x2go/xserver.py | 55 ++++++++++++++++++++++++++++++++++++++---------------- 4 files changed, 72 insertions(+), 22 deletions(-) The diff of changes is: diff --git a/x2go/cleanup.py b/x2go/cleanup.py index a6f3219..ace141e 100644 --- a/x2go/cleanup.py +++ b/x2go/cleanup.py @@ -21,11 +21,17 @@ A recommended X2go session clean up helper function. """ +import gevent import paramiko import threading + +# Python X2go modules import guardian import rforward +from defaults import X2GOCLIENT_OS as _X2GOCLIENT_OS +if _X2GOCLIENT_OS == 'Windows': + import xserver def x2go_cleanup(e=None, threads=None): """\ @@ -71,5 +77,13 @@ def x2go_cleanup(e=None, threads=None): t.stop_thread() del t + # on Windows: stop the XServer that we evoked + if _X2GOCLIENT_OS == 'Windows': + for t in threads: + if type(t) == xserver.X2goXServer: + t.stop_thread() + gevent.sleep(1) + del t + if e is not None: raise e diff --git a/x2go/client.py b/x2go/client.py index 3728439..575ade9 100644 --- a/x2go/client.py +++ b/x2go/client.py @@ -120,8 +120,10 @@ __NAME__ = 'x2goclient-pylib' import uuid import copy import sys +import types # Python X2go modules +from xserver import X2goClientXConfig, X2goXServer from settings import X2goClientSettings from printing import X2goClientPrinting from registry import X2goSessionRegistry @@ -132,6 +134,7 @@ import log import utils # we hide the default values from epydoc (that's why we transform them to _UNDERSCORE variables) +from defaults import X2GOCLIENT_OS as _X2GOCLIENT_OS from defaults import LOCAL_HOME as _LOCAL_HOME from defaults import CURRENT_LOCAL_USER as _CURRENT_LOCAL_USER from defaults import X2GO_CLIENT_ROOTDIR as _X2GO_CLIENT_ROOTDIR @@ -148,7 +151,7 @@ class X2goClient(object): session object etc.) and connected to it (authentication). For these two steps use these methods: L{X2goClient.register_session()} and L{X2goClient.connect_session()}. """ - def __init__(self, use_cache=True, logger=None, loglevel=log.loglevel_DEFAULT): + def __init__(self, use_cache=True, start_xserver=False, logger=None, loglevel=log.loglevel_DEFAULT): """\ @param logger: you can pass an L{X2goLogger} object to the L{X2goClient} constructor @@ -168,6 +171,16 @@ class X2goClient(object): if self.logger.tag is None: self.logger.tag = self._logger_tag + if _X2GOCLIENT_OS == 'Windows' and start_xserver: + self.client_xconfig = X2goClientXConfig(logger=self.logger) + if not self.client_xconfig.running_xservers: + if type(start_xserver) is types.BooleanType: + p_xs = self.client_xconfig.preferred_xserver + elif type(start_xserver) is types.StringType: + p_xs = (start_xserver, self.client_xconfig.get_xserver_config(start_xserver)) + if p_xs is not None: + self.xserver = X2goXServer(p_xs[0], p_xs[1], logger=self.logger) + self.session_profiles = X2goSessionProfiles(logger=self.logger) self.session_registry = X2goSessionRegistry(logger=self.logger) self.session_guardian = X2goSessionGuardian(self, enable_cache=use_cache, logger=self.logger) diff --git a/x2go/defaults.py b/x2go/defaults.py index 4091bdb..c2c1a47 100644 --- a/x2go/defaults.py +++ b/x2go/defaults.py @@ -163,19 +163,19 @@ X2GO_CLIENTPRINTING_DEFAULTS = { if X2GOCLIENT_OS == 'Windows': X2GO_CLIENTXCONFIG_DEFAULTS = { 'XServers': { - 'known_xservers': ['XMing', 'Cygwin-X', ], + 'known_xservers': ['Xming', 'Cygwin-X', ], }, 'Cygwin-X': { 'process_name': 'XWin.exe', - 'test_installed': os.path.join(os.environ['SystemDrive'], '\\', 'cygwin', 'bin', 'startxwin.exe'), - 'run_command':os.path.join(os.environ['SystemDrive'], '\\', 'cygwin', 'bin', 'run.exe') + ' /usr/bin/bash.exe -l -c /usr/bin/startxwin.exe', - 'parameters':[], + 'test_installed': os.path.join(os.environ['SystemDrive'], '\\', 'cygwin', 'bin', 'XWin.exe'), + 'run_command':os.path.join(os.environ['SystemDrive'], '\\', 'cygwin', 'bin', 'XWin.exe'), + 'parameters':[':0', '-clipboard', '-multiwindow', '-notrayicon', '-nowinkill', ], }, 'Xming': { 'process_name': 'Xming.exe', 'test_installed': os.path.join(os.environ['ProgramFiles'], 'Xming', 'Xming.exe'), 'run_command': os.path.join(os.environ['ProgramFiles'], 'Xming', 'Xming.exe'), - 'parameters': [':0', '-clibboard', '-multiwindow',], + 'parameters': [':0', '-clipboard', '-multiwindow', '-notrayicon', '-nowinkill', ], }, } diff --git a/x2go/xserver.py b/x2go/xserver.py index 20828c1..191fab5 100644 --- a/x2go/xserver.py +++ b/x2go/xserver.py @@ -25,7 +25,7 @@ # Other contributors: # none so far -__NAME__ = 'x2gosettings-pylib' +__NAME__ = 'x2goxserver-pylib' from defaults import X2GOCLIENT_OS as _X2GOCLIENT_OS @@ -39,6 +39,8 @@ import os import wmi import subprocess import threading +import gevent +import copy # Python X2go modules import log @@ -127,7 +129,7 @@ class X2goClientXConfig(inifiles.X2goIniFile): STILL UNDOCUMENTED """ - return not bool(self.installed_xservers) + return bool(self.installed_xservers) @property def xserver_launch_needed(self): @@ -143,7 +145,7 @@ class X2goClientXConfig(inifiles.X2goIniFile): STILL UNDOCUMENTED """ - if self.xserver_launch_possible + if self.xserver_launch_possible and self.xserver_launch_needed: return (self.installed_xservers[0], self.get_xserver_config(self.installed_xservers[0])) else: return None @@ -155,24 +157,45 @@ class X2goXServer(threading.Thread): already """ - def __init__(self, XServerParms): - - process_name = XServerParms.process_name - for line in os.popen("ps xa"): - fields = line.split() - pid = fields[0] - process = fields[4] + def __init__(self, xserver_name, xserver_config, logger=None, loglevel=log.loglevel_DEFAULT): + """\ + STILL UNDOCUMENTED - if process.find(process_name) > 0: - # XServer is already running - return + """ + if logger is None: + self.logger = log.X2goLogger(loglevel=loglevel) + else: + self.logger = copy.deepcopy(logger) + self.logger.tag = __NAME__ + + self._keepalive = None - self.XServerParms = XServerParms + self.xserver_name = xserver_name + self.xserver_config = xserver_config threading.Thread.__init__(self) self.daemon = True self.start() def run(self): + """\ + STILL UNDOCUMENTED + + """ + self._keepalive = True + cmd_line = [self.xserver_config['run_command']] + cmd_line.extend(self.xserver_config['parameters']) + self.logger('starting XServer ,,%s\'\' with command line: %s' % (self.xserver_name, ' '.join(cmd_line)), loglevel=log.loglevel_DEBUG) + p = subprocess.Popen(cmd_line, shell=False) + while self._keepalive: + gevent.sleep(1) + self.logger('killing running XServer ,,%s\'\'' % self.xserver_name, loglevel=log.loglevel_DEBUG) + p.terminate() + + def stop_thread(self): + """\ + STILL UNDOCUMENTED - p = subprocess.Popen([self.XServerParms.run_command, self.XServerParms.parameters], shell=True) - sts = os.waitpid(p.pid, 0)[1] + """ + self.logger('stop_thread() method has been called', loglevel=log.loglevel_DEBUG) + self._keepalive = False + hooks/post-receive -- python-x2go.git (Python X2Go Client API) This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "python-x2go.git" (Python X2Go Client API).