This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch master in repository python-x2go. from 6d7f154 x2go/backends/control/plain.py: Raise log priority for reporting that the user enabled SSH agent forwarding. new b779a02 x2go/session.py: Don't fail in set_master_session() if the client instance lacks a session profile config. new bcdc1b5 x2go/guardian.py: White-space cleanup. new 118f014 x2go/*.py: Drop 'from builtins import <bla>'. Not required. new 29006c6 x2go/inifiles.py: Correctly import ConfigParser as configparser on Python2. new 90db159 InstanceType does not exist in Python3. Let's omit it in __repr__ method. new 3fbee6a Correctly handle IO objects (BytesIO in Python3, StringIO in Python2). new 4ba693e x2go/backends/terminal/plain.py: Correctly update session window file in Python3. The 7 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: x2go/_paramiko.py | 1 - x2go/backends/control/plain.py | 59 ++++++++++++++++++++------------ x2go/backends/info/plain.py | 4 +-- x2go/backends/printing/file.py | 1 - x2go/backends/profiles/base.py | 2 -- x2go/backends/profiles/httpbroker.py | 1 - x2go/backends/proxy/base.py | 1 - x2go/backends/terminal/plain.py | 65 ++++++++++++++++++++++++++---------- x2go/cache.py | 2 -- x2go/checkhosts.py | 2 -- x2go/client.py | 2 -- x2go/defaults.py | 2 -- x2go/gevent_subprocess.py | 1 - x2go/guardian.py | 2 -- x2go/inifiles.py | 14 +++++--- x2go/log.py | 1 - x2go/mimeboxactions.py | 2 -- x2go/printactions.py | 2 -- x2go/registry.py | 4 +-- x2go/rforward.py | 1 - x2go/session.py | 12 ++++--- x2go/sftpserver.py | 1 - x2go/sshproxy.py | 2 -- x2go/telekinesis.py | 1 - x2go/utils.py | 3 -- x2go/xserver.py | 1 - 26 files changed, 104 insertions(+), 85 deletions(-) -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository python-x2go. commit b779a026bae82cd28d5edb94ee61d0f7173408ad Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Tue Sep 18 12:38:39 2018 +0000 x2go/session.py: Don't fail in set_master_session() if the client instance lacks a session profile config. --- x2go/session.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/x2go/session.py b/x2go/session.py index 99cafd9..7a978ad 100644 --- a/x2go/session.py +++ b/x2go/session.py @@ -687,8 +687,12 @@ class X2GoSession(object): # retrieve an up-to-date list of sharable local folders from the client instance if self.client_instance: - _exports = self.client_instance.get_profile_config(self.profile_name, 'export') - self.share_local_folders = [ sf for sf in list(_exports.keys()) if _exports[sf] ] + try: + _exports = self.client_instance.get_profile_config(self.profile_name, 'export') + self.share_local_folders = [ sf for sf in list(_exports.keys()) if _exports[sf] ] + except x2go_exceptions.X2GoProfileException: + # not all client instances may necessarily have a sesion profile config... + pass i = 0 while i < max_wait: -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository python-x2go. commit bcdc1b504f4f358280c0becaec4de35a3120ca4d Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Tue Sep 18 12:38:57 2018 +0000 x2go/guardian.py: White-space cleanup. --- x2go/guardian.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/x2go/guardian.py b/x2go/guardian.py index 014663d..6aa90f7 100644 --- a/x2go/guardian.py +++ b/x2go/guardian.py @@ -142,5 +142,3 @@ class X2GoSessionGuardian(threading.Thread): """ self._keepalive = False - - -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository python-x2go. commit 118f0143a13ca72f5bf63f1f57cd17544a15cd1e Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Tue Sep 18 16:23:16 2018 +0000 x2go/*.py: Drop 'from builtins import <bla>'. Not required. --- x2go/_paramiko.py | 1 - x2go/backends/control/plain.py | 2 -- x2go/backends/info/plain.py | 2 -- x2go/backends/printing/file.py | 1 - x2go/backends/profiles/base.py | 2 -- x2go/backends/profiles/httpbroker.py | 1 - x2go/backends/proxy/base.py | 1 - x2go/backends/terminal/plain.py | 2 -- x2go/cache.py | 2 -- x2go/checkhosts.py | 2 -- x2go/client.py | 2 -- x2go/defaults.py | 2 -- x2go/gevent_subprocess.py | 1 - x2go/inifiles.py | 2 -- x2go/log.py | 1 - x2go/mimeboxactions.py | 2 -- x2go/printactions.py | 2 -- x2go/registry.py | 2 -- x2go/rforward.py | 1 - x2go/session.py | 2 -- x2go/sftpserver.py | 1 - x2go/sshproxy.py | 2 -- x2go/telekinesis.py | 1 - x2go/utils.py | 3 --- x2go/xserver.py | 1 - 25 files changed, 41 deletions(-) diff --git a/x2go/_paramiko.py b/x2go/_paramiko.py index 0fec247..c66ba94 100644 --- a/x2go/_paramiko.py +++ b/x2go/_paramiko.py @@ -21,7 +21,6 @@ Monkey Patch and feature map for Python Paramiko """ -from builtins import str __package__ = 'x2go' __name__ = 'x2go._paramiko' diff --git a/x2go/backends/control/plain.py b/x2go/backends/control/plain.py index 53bb25c..104a25b 100644 --- a/x2go/backends/control/plain.py +++ b/x2go/backends/control/plain.py @@ -23,8 +23,6 @@ This backend handles X2Go server implementations that respond via server-side PLAIN text output. """ -from builtins import str -from builtins import range __NAME__ = 'x2gocontrolsession-pylib' __package__ = 'x2go.backends.control' diff --git a/x2go/backends/info/plain.py b/x2go/backends/info/plain.py index b01bb59..cc32fbe 100644 --- a/x2go/backends/info/plain.py +++ b/x2go/backends/info/plain.py @@ -27,8 +27,6 @@ via server-side PLAIN text output. """ from __future__ import print_function -from builtins import str -from builtins import object __NAME__ = 'x2goserversessioninfo-pylib' __package__ = 'x2go.backends.info' diff --git a/x2go/backends/printing/file.py b/x2go/backends/printing/file.py index d16c613..cc486a4 100644 --- a/x2go/backends/printing/file.py +++ b/x2go/backends/printing/file.py @@ -26,7 +26,6 @@ Use this class in your Python X2Go based applications to access the »printing« configuration of your X2Go client application. """ -from builtins import str __NAME__ = 'x2goprinting-pylib' __package__ = 'x2go.backends.printing' diff --git a/x2go/backends/profiles/base.py b/x2go/backends/profiles/base.py index 2b46ef3..37f4ed6 100644 --- a/x2go/backends/profiles/base.py +++ b/x2go/backends/profiles/base.py @@ -24,8 +24,6 @@ applications. """ -from builtins import str -from builtins import object __NAME__ = 'x2gosessionprofiles-pylib' __package__ = 'x2go.backends.profiles' diff --git a/x2go/backends/profiles/httpbroker.py b/x2go/backends/profiles/httpbroker.py index 30e8105..e52567e 100644 --- a/x2go/backends/profiles/httpbroker.py +++ b/x2go/backends/profiles/httpbroker.py @@ -25,7 +25,6 @@ applications. """ from __future__ import print_function -from builtins import str __NAME__ = 'x2gosessionprofiles-pylib' __package__ = 'x2go.backends.profiles' diff --git a/x2go/backends/proxy/base.py b/x2go/backends/proxy/base.py index 828f04e..424f761 100644 --- a/x2go/backends/proxy/base.py +++ b/x2go/backends/proxy/base.py @@ -21,7 +21,6 @@ X2GoProxy class - proxying your connection through NX3 and others. """ -from builtins import str __NAME__ = 'x2goproxy-pylib' __package__ = 'x2go.backends.proxy' diff --git a/x2go/backends/terminal/plain.py b/x2go/backends/terminal/plain.py index 217cc5d..df143d0 100644 --- a/x2go/backends/terminal/plain.py +++ b/x2go/backends/terminal/plain.py @@ -24,8 +24,6 @@ This backend handles X2Go server implementations that respond with session infos via server-side PLAIN text output. """ -from builtins import str -from builtins import object __NAME__ = 'x2goterminalsession-pylib' __package__ = 'x2go.backends.terminal' diff --git a/x2go/cache.py b/x2go/cache.py index 2d5298e..ded8740 100644 --- a/x2go/cache.py +++ b/x2go/cache.py @@ -21,8 +21,6 @@ X2GoListSessionCache class - caching X2Go session information. """ -from builtins import str -from builtins import object __NAME__ = 'x2gocache-pylib' __package__ = 'x2go' diff --git a/x2go/checkhosts.py b/x2go/checkhosts.py index 293037a..f0a0130 100644 --- a/x2go/checkhosts.py +++ b/x2go/checkhosts.py @@ -21,8 +21,6 @@ Providing mechanisms to ``X2GoControlSession*`` backends for checking host validity. """ -from builtins import str -from builtins import range __NAME__ = 'x2gocheckhosts-pylib' __package__ = 'x2go' diff --git a/x2go/client.py b/x2go/client.py index 6ffb562..7d87c5d 100644 --- a/x2go/client.py +++ b/x2go/client.py @@ -119,8 +119,6 @@ Session Suspending / Terminating x2go_client.terminate_session(x2go_sess_uuid) """ -from builtins import str -from builtins import object __NAME__ = 'x2goclient-pylib' __package__ = 'x2go' diff --git a/x2go/defaults.py b/x2go/defaults.py index 0cf2d41..16de520 100644 --- a/x2go/defaults.py +++ b/x2go/defaults.py @@ -21,8 +21,6 @@ Default variables and values for Python X2Go. """ -from builtins import str -from builtins import range __NAME__ = 'x2godefaults-pylib' __package__ = 'x2go' diff --git a/x2go/gevent_subprocess.py b/x2go/gevent_subprocess.py index 821471a..d27ca84 100644 --- a/x2go/gevent_subprocess.py +++ b/x2go/gevent_subprocess.py @@ -41,7 +41,6 @@ __name__ = 'x2go.gevent_subprocess' """Implementation of the standard :mod:`subprocess` module that spawns greenlets""" -from builtins import object import errno import sys import fcntl, os diff --git a/x2go/inifiles.py b/x2go/inifiles.py index c4de620..7531ef0 100644 --- a/x2go/inifiles.py +++ b/x2go/inifiles.py @@ -28,8 +28,6 @@ X2GoProcessIniFile - helper class for parsing .ini files """ from __future__ import print_function -from builtins import str -from builtins import object __NAME__ = 'x2goinifiles-pylib' __package__ = 'x2go' diff --git a/x2go/log.py b/x2go/log.py index 7c8e89f..2b00019 100644 --- a/x2go/log.py +++ b/x2go/log.py @@ -21,7 +21,6 @@ X2GoLogger class - flexible handling of log and debug output. """ -from builtins import object __NAME__ = 'x2gologger-pylib' __package__ = 'x2go' diff --git a/x2go/mimeboxactions.py b/x2go/mimeboxactions.py index 24fe431..32db8f8 100644 --- a/x2go/mimeboxactions.py +++ b/x2go/mimeboxactions.py @@ -22,8 +22,6 @@ For MIME box jobs there are currently three handling actions available: :class:`x2go.mimeboxactions.X2GoMIMEboxActionOPEN`, :class:`x2go.mimeboxactions.X2GoMIMEboxActionOPENWITH` and :class:`x2go.mimeboxactions.X2GoMIMEboxActionSAVEAS`. """ -from builtins import str -from builtins import object __NAME__ = 'x2gomimeboxactions-pylib' __package__ = 'x2go' diff --git a/x2go/printactions.py b/x2go/printactions.py index 027f0e0..2ba292e 100644 --- a/x2go/printactions.py +++ b/x2go/printactions.py @@ -25,8 +25,6 @@ over to a custom (print) command. This is defined by four print action classes :class:`x2go.printactions.X2GoPrintActionPRINTCMD`). """ -from builtins import str -from builtins import object __NAME__ = 'x2goprintactions-pylib' __package__ = 'x2go' diff --git a/x2go/registry.py b/x2go/registry.py index 7f4b3d8..d8a17cc 100644 --- a/x2go/registry.py +++ b/x2go/registry.py @@ -21,8 +21,6 @@ X2GoSessionRegistry class - the X2GoClient's session registry backend """ -from builtins import str -from builtins import object __NAME__ = 'x2gosessregistry-pylib' __package__ = 'x2go' diff --git a/x2go/rforward.py b/x2go/rforward.py index 379b20a..c21f117 100644 --- a/x2go/rforward.py +++ b/x2go/rforward.py @@ -21,7 +21,6 @@ X2Go sshfs for folder sharing and mounting remote devices in X2Go terminal server sessions. """ -from builtins import str __NAME__ = 'x2gorevtunnel-pylib' __package__ = 'x2go' diff --git a/x2go/session.py b/x2go/session.py index 7a978ad..63e2b85 100644 --- a/x2go/session.py +++ b/x2go/session.py @@ -46,8 +46,6 @@ simple steps::
while True: gevent.sleep(1)
""" -from builtins import str -from builtins import object __NAME__ = 'x2gosession-pylib' diff --git a/x2go/sftpserver.py b/x2go/sftpserver.py index 35d7a19..916c6d5 100644 --- a/x2go/sftpserver.py +++ b/x2go/sftpserver.py @@ -29,7 +29,6 @@ The Python X2Go sFTP server code was originally written by Richard Murri, for further information see his website: http://www.richardmurri.com """ -from builtins import str __NAME__ = "x2gosftpserver-pylib" __package__ = 'x2go' diff --git a/x2go/sshproxy.py b/x2go/sshproxy.py index a1cb368..2e03c01 100644 --- a/x2go/sshproxy.py +++ b/x2go/sshproxy.py @@ -22,8 +22,6 @@ """ from __future__ import print_function -from builtins import str -from builtins import range __NAME__ = 'x2gosshproxy-pylib' __package__ = 'x2go' diff --git a/x2go/telekinesis.py b/x2go/telekinesis.py index 9c8c6d2..0f131f4 100644 --- a/x2go/telekinesis.py +++ b/x2go/telekinesis.py @@ -21,7 +21,6 @@ X2GoTelekinesisClient class - Connect to Telekinesis Server on X2Go Server. """ -from builtins import str __NAME__ = 'x2gotelekinesisclient-pylib' __package__ = 'x2go' diff --git a/x2go/utils.py b/x2go/utils.py index f873546..c30d2a9 100644 --- a/x2go/utils.py +++ b/x2go/utils.py @@ -21,9 +21,6 @@ Python X2Go helper functions, constants etc. """ -from builtins import str -from builtins import range -from builtins import object __NAME__ = 'x2goutils-pylib' __package__ = 'x2go' diff --git a/x2go/xserver.py b/x2go/xserver.py index 8e3f8f2..3454b40 100644 --- a/x2go/xserver.py +++ b/x2go/xserver.py @@ -1,4 +1,3 @@ -from builtins import str # -*- coding: utf-8 -*- # Copyright (C) 2010-2016 by Mike Gabriel <mike.gabriel@das-netzwerkteam.de> -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository python-x2go. commit 29006c68ff5212da3a57c36f9ada236376bb37ae Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Tue Sep 18 16:24:08 2018 +0000 x2go/inifiles.py: Correctly import ConfigParser as configparser on Python2. --- x2go/inifiles.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x2go/inifiles.py b/x2go/inifiles.py index 7531ef0..f2c5928 100644 --- a/x2go/inifiles.py +++ b/x2go/inifiles.py @@ -35,7 +35,10 @@ __name__ = 'x2go.inifiles' # modules import os -import configparser +try: + import configparser +except: + import ConfigParser as configparser import types import io import copy -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository python-x2go. commit 90db1590fd2c5be360098e1e513a791a6dd082d1 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Tue Sep 18 16:24:56 2018 +0000 InstanceType does not exist in Python3. Let's omit it in __repr__ method. --- x2go/backends/info/plain.py | 2 +- x2go/inifiles.py | 2 +- x2go/registry.py | 2 +- x2go/session.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x2go/backends/info/plain.py b/x2go/backends/info/plain.py index cc32fbe..e173036 100644 --- a/x2go/backends/info/plain.py +++ b/x2go/backends/info/plain.py @@ -49,7 +49,7 @@ class X2GoServerSessionInfo(object): def __repr__(self): result = 'X2GoServerSessionInfo(' for p in dir(self): - if '__' in p or not p in self.__dict__ or type(p) is types.InstanceType: continue + if '__' in p or not p in self.__dict__: continue result += p + '=' + str(self.__dict__[p]) +',' return result.strip(',') + ')' diff --git a/x2go/inifiles.py b/x2go/inifiles.py index f2c5928..f549d5c 100644 --- a/x2go/inifiles.py +++ b/x2go/inifiles.py @@ -139,7 +139,7 @@ class X2GoIniFile(object): def __repr__(self): result = 'X2GoIniFile(' for p in dir(self): - if '__' in p or not p in self.__dict__ or type(p) is types.InstanceType: continue + if '__' in p or not p in self.__dict__: continue result += p + '=' + str(self.__dict__[p]) + ',' result = result.strip(',') return result + ')' diff --git a/x2go/registry.py b/x2go/registry.py index d8a17cc..bfaf974 100644 --- a/x2go/registry.py +++ b/x2go/registry.py @@ -97,7 +97,7 @@ class X2GoSessionRegistry(object): def __repr__(self): result = 'X2GoSessionRegistry(' for p in dir(self): - if '__' in p or not p in self.__dict__ or type(p) is types.InstanceType: continue + if '__' in p or not p in self.__dict__: continue result += p + '=' + str(self.__dict__[p]) + ',' result = result.strip(',') return result + ')' diff --git a/x2go/session.py b/x2go/session.py index 63e2b85..99f6b1c 100644 --- a/x2go/session.py +++ b/x2go/session.py @@ -375,7 +375,7 @@ class X2GoSession(object): def __repr__(self): result = 'X2GoSession(' for p in dir(self): - if '__' in p or not p in self.__dict__ or type(p) is types.InstanceType: continue + if '__' in p or not p in self.__dict__: continue result += p + '=' + str(self.__dict__[p]) + ',' result = result.strip(',') return result + ')' -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository python-x2go. commit 4ba693e284929855a2cd4202f54cd906f85f342d Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Tue Sep 18 18:44:22 2018 +0200 x2go/backends/terminal/plain.py: Correctly update session window file in Python3. --- x2go/backends/terminal/plain.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x2go/backends/terminal/plain.py b/x2go/backends/terminal/plain.py index 7717be6..de31884 100644 --- a/x2go/backends/terminal/plain.py +++ b/x2go/backends/terminal/plain.py @@ -1169,7 +1169,10 @@ class X2GoTerminalSession(object): _id = self.session_window.id else: _id = self.session_window - f.write(u'ID:{window_id}\n'.format(window_id=_id)) + if sys.version_info[0] >= 3: + f.write(b'ID:{window_id}\n'.format(window_id=_id)) + else: + f.write(u'ID:{window_id}\n'.format(window_id=_id)) f.close() self.logger('Updating session.window file %s: Window-ID->%s' % (session_window_file, _id), loglevel=log.loglevel_DEBUG) else: -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository python-x2go. commit 3fbee6ad5c04d3c49f73b4232f580248ba24714a Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Tue Sep 18 16:26:40 2018 +0000 Correctly handle IO objects (BytesIO in Python3, StringIO in Python2). --- x2go/backends/control/plain.py | 57 ++++++++++++++++++++++++++-------------- x2go/backends/terminal/plain.py | 58 +++++++++++++++++++++++++++++++---------- x2go/inifiles.py | 5 +++- 3 files changed, 86 insertions(+), 34 deletions(-) diff --git a/x2go/backends/control/plain.py b/x2go/backends/control/plain.py index 104a25b..40c4a0f 100644 --- a/x2go/backends/control/plain.py +++ b/x2go/backends/control/plain.py @@ -473,7 +473,10 @@ class X2GoControlSession(paramiko.SSHClient): if self.session_died: self.logger("control session seams to be dead, not executing command ,,%s'' on X2Go server %s" % (_rerewrite_blanks(cmd), self.profile_name,), loglevel=loglevel) - return (io.StringIO(), io.StringIO(), io.StringIO(u'failed to execute command')) + if sys.version_info[0] >= 3: + return (io.BytesIO(), io.BytesIO(), io.BytesIO(b'failed to execute command')) + else: + return (io.StringIO(), io.StringIO(), io.StringIO(u'failed to execute command')) self._transport_lock.acquire() @@ -531,13 +534,13 @@ class X2GoControlSession(paramiko.SSHClient): if self._transport_lock.locked(): self._transport_lock.release() - # sanitized X2Go relevant data, protect against data injection via .bashrc files - (_stdin, _stdout, _stderr) = _retval - raw_stdout = _stdout.read() - sanitized_stdout = u'' is_x2go_data = False + # sanitized X2Go relevant data, protect against data injection via .bashrc files + (stdin, stdout, stderr) = _retval + raw_stdout = stdout.read() + # Python 3 needs a decoding from bytestring to string if sys.version_info[0] >= 3: raw_stdout = raw_stdout.decode() @@ -553,9 +556,12 @@ class X2GoControlSession(paramiko.SSHClient): if line.startswith('X2GODATAEND:'+cmd_uuid): break sanitized_stdout += line + "\n" - _stdout_new = io.StringIO(sanitized_stdout) + if sys.version_info[0] >= 3: + _stdout_new = io.BytesIO(sanitized_stdout.encode()) + else: + _stdout_new = io.StringIO(sanitized_stdout) - _retval = (_stdin, _stdout_new, _stderr) + _retval = (stdin, _stdout_new, stderr) return _retval @property @@ -602,7 +608,10 @@ class X2GoControlSession(paramiko.SSHClient): """ if self._server_features is None: (stdin, stdout, stderr) = self._x2go_exec_command('which x2gofeaturelist >/dev/null && x2gofeaturelist') - self._server_features = stdout.read().split('\n') + _stdout = stdout.read() + if sys.version_info[0] >= 3: + _stdout = _stdout.decode() + self._server_features = _stdout.split('\n') self._server_features = [ f for f in self._server_features if f ] self._server_features.sort() self.logger('server-side X2Go features are: %s' % self._server_features, loglevel=log.loglevel_DEBUG) @@ -632,9 +641,11 @@ class X2GoControlSession(paramiko.SSHClient): """ if self._remote_home is None: (stdin, stdout, stderr) = self._x2go_exec_command('echo $HOME') - stdout_r = stdout.read() - if stdout_r: - self._remote_home = stdout_r.split()[0] + _stdout = stdout.read() + if sys.version_info[0] >= 3: + _stdout = _stdout.decode() + if _stdout: + self._remote_home = _stdout.split()[0] self.logger('remote user\' home directory: %s' % self._remote_home, loglevel=log.loglevel_DEBUG) return self._remote_home else: @@ -1261,8 +1272,10 @@ class X2GoControlSession(paramiko.SSHClient): :rtype: ``bool`` """ - (_stdin, _stdout, _stderr) = self._x2go_exec_command('stat -tL "%s"' % self._x2go_remote_home, loglevel=log.loglevel_DEBUG) - if _stdout.read(): + (stdin, stdout, stderr) = self._x2go_exec_command('stat -tL "%s"' % self._x2go_remote_home, loglevel=log.loglevel_DEBUG) + _stdout = stdout.read() + print (_stdout) + if _stdout: return True return False @@ -1653,8 +1666,10 @@ class X2GoControlSession(paramiko.SSHClient): timeout.start() try: (stdin, stdout, stderr) = self._x2go_exec_command("export HOSTNAME && x2golistdesktops") - _stdout_read = stdout.read() - _listdesktops = _stdout_read.split('\n') + _stdout = stdout.read() + if sys.version_info[0] >= 3: + _stdout = _stdout.decode() + _listdesktops = _stdout.split('\n') except gevent.timeout.Timeout: # if we do not get a reply here after <maxwait> seconds we will raise a time out, we have to # make sure that we catch this at places where we want to ignore timeouts (e.g. in the @@ -1698,8 +1713,10 @@ class X2GoControlSession(paramiko.SSHClient): timeout.start() try: (stdin, stdout, stderr) = self._x2go_exec_command("export HOSTNAME && x2golistmounts %s" % session_name) - _stdout_read = stdout.read() - _listmounts = {session_name: [ line for line in _stdout_read.split('\n') if line ] } + _stdout = stdout.read() + if sys.version_info[0] >= 3: + _stdout = _stdout.decode() + _listmounts = {session_name: [ line for line in _stdout.split('\n') if line ] } except gevent.timeout.Timeout: # if we do not get a reply here after <maxwait> seconds we will raise a time out, we have to # make sure that we catch this at places where we want to ignore timeouts @@ -1749,8 +1766,10 @@ class X2GoControlSession(paramiko.SSHClient): (stdin, stdout, stderr) = self._x2go_exec_command("export HOSTNAME && { x2golistsessions; x2golistshadowsessions; }") else: (stdin, stdout, stderr) = self._x2go_exec_command("export HOSTNAME && x2golistsessions") - _stdout_read = stdout.read() - _listsessions = self._list_backend(_stdout_read, info_backend=self._info_backend).sessions + _stdout = stdout.read() + if sys.version_info[0] >= 3: + _stdout = _stdout.decode() + _listsessions = self._list_backend(_stdout, info_backend=self._info_backend).sessions _success = True except KeyError: gevent.sleep(1) diff --git a/x2go/backends/terminal/plain.py b/x2go/backends/terminal/plain.py index df143d0..7717be6 100644 --- a/x2go/backends/terminal/plain.py +++ b/x2go/backends/terminal/plain.py @@ -892,13 +892,19 @@ class X2GoTerminalSession(object): _auth_rsakey = self.control_session._x2go_session_auth_rsakey _host_rsakey = defaults.RSAHostKey - _tmp_io_object = io.StringIO() + if sys.version_info[0] >= 3: + _tmp_io_object = io.BytesIO() + else: + _tmp_io_object = io.StringIO() _auth_rsakey.write_private_key(_tmp_io_object) - _tmp_io_object.write(u'----BEGIN RSA IDENTITY----') - _tmp_io_object.write(u'%s %s' % (_host_rsakey.get_name(),_host_rsakey.get_base64(),)) - + if sys.version_info[0] >= 3: + _tmp_io_object.write(b'----BEGIN RSA IDENTITY----') + _tmp_io_object.write(b'%b %b' % (_host_rsakey.get_name().encode(),_host_rsakey.get_base64().encode(),)) + else: + _tmp_io_object.write(u'----BEGIN RSA IDENTITY----') + _tmp_io_object.write(u'%s %s' % (_host_rsakey.get_name(),_host_rsakey.get_base64(),)) # _x2go_key_fname must be a UniX path - _x2go_key_fname = u'%s/%s/%s' % (os.path.dirname(self.session_info.remote_container), 'ssh', 'key.z%s' % self.session_info.agent_pid) + _x2go_key_fname = '%s/%s/%s' % (os.path.dirname(self.session_info.remote_container), 'ssh', 'key.z%s' % self.session_info.agent_pid) _x2go_key_bundle = _tmp_io_object.getvalue() # if there is another call to this method currently being processed, wait for that one to finish @@ -968,10 +974,15 @@ class X2GoTerminalSession(object): ] (stdin, stdout, stderr) = self.control_session._x2go_exec_command(cmd_line) - _stdout = stdout.read().split('\n') + _stdout = stdout.read() + _stderr = stderr.read() + if sys.version_info[0] >= 3: + _stdout = _stdout.decode() + _stderr = _stderr.decode() + _stdout = _stdout.split('\n') if _stdout[0]: self.logger('x2gomountdirs stdout is: %s' % _stdout, log.loglevel_NOTICE) - _stderr = stderr.read().split('\n') + _stderr = _stderr.split('\n') if _stderr[0]: self.logger('x2gomountdirs stderr is: %s' % _stderr, log.loglevel_WARN) @@ -1002,7 +1013,10 @@ class X2GoTerminalSession(object): ] (stdin, stdout, stderr) = self.control_session._x2go_exec_command(cmd_line) - if not stderr.read(): + _stderr = stderr.read() + if sys.version_info[0] >= 3: + _stderr = _stderr.decode() + if not _stderr: self.logger('x2goumount-session (all mounts) for session %s has been successful' % self.session_info, log.loglevel_NOTICE) return True else: @@ -1028,7 +1042,10 @@ class X2GoTerminalSession(object): ] (stdin, stdout, stderr) = self.control_session._x2go_exec_command(cmd_line) - if not stderr.read(): + _stderr = stderr.read() + if sys.version_info[0] >= 3: + _stderr = _stderr.decode() + if not _stderr: self.logger('x2goumount-session (%s) for session %s has been successful' % (local_path, self.session_info, ), log.loglevel_NOTICE) return True else: @@ -1273,6 +1290,8 @@ class X2GoTerminalSession(object): if test_cmd: (stdin, stdout, stderr) = self.control_session._x2go_exec_command([test_cmd]) _stdout = stdout.read() + if sys.version_info[0] >= 3: + _stdout = _stdout.decode() return _stdout.find('OK') != -1 else: return False @@ -1342,7 +1361,10 @@ class X2GoTerminalSession(object): if self.params.kbtype not in ('null/null', 'auto') and (self.params.kblayout not in ('null', '') or self.params.kbvariant not in ('null', '')): self.set_keyboard(layout=self.params.kblayout, variant=self.params.kbvariant) - return stdout.read(), stderr.read() + if sys.version_info[0] >= 3: + return stdout.read().decode(), stderr.read().decode() + else: + return stdout.read(), stderr.read() def is_desktop_session(self): """\ @@ -1400,12 +1422,12 @@ class X2GoTerminalSession(object): (stdin, stdout, stderr) = self.control_session._x2go_exec_command(cmd_line) _stderr = stderr.read() + if sys.version_info[0] >= 3: + _stderr.decode() if not _stderr: self.logger('setting keyboard layout ,,%s\'\' and variant ,,%s\'\' for session %s has been successful' % (layout, variant, self.session_info), log.loglevel_NOTICE) return True else: - if sys.version_info[0] >= 3: - _stderr = _stderr.decode() self.logger('setting keyboard layout ,,%s\'\' and variant ,,%s\'\' for session %s failed: %s' % (layout, variant, self.session_info, _stderr.replace('\n', ' ')), log.loglevel_ERROR) return False @@ -1566,9 +1588,13 @@ class X2GoTerminalSession(object): _stdout = stdout.read() _stderr = stderr.read() + if sys.version_info[0] >= 3: + _stdout = _stdout.decode() + _stderr = _stderr.decode() + # if the first line of stdout is a "DEN(Y)" string then we will presume that # we tried to use X2Go desktop sharing and the sharing was rejected - if b"ACCESS DENIED" in _stderr and b"XSHAD" in _stderr: + if "ACCESS DENIED" in _stderr and "XSHAD" in _stderr: raise x2go_exceptions.X2GoDesktopSharingDenied('X2Go desktop sharing has been denied by the remote user') try: @@ -1651,8 +1677,12 @@ class X2GoTerminalSession(object): (stdin, stdout, stderr) = self.control_session._x2go_exec_command(cmd_line) + _stdout = stdout.read() + if sys.version_info[0] >= 3: + _stdout = _stdout.decode() + # re-allocate (if needed) server-side ports for graphics, sound and sshfs - for stdout_line in stdout.read(): + for stdout_line in _stdout.split('\n'): try: _new_value = stdout_line.split("=")[1].strip() if 'gr_port=' in stdout_line and _new_value != str(self.session_info.graphics_port): diff --git a/x2go/inifiles.py b/x2go/inifiles.py index f549d5c..244602c 100644 --- a/x2go/inifiles.py +++ b/x2go/inifiles.py @@ -286,7 +286,10 @@ class X2GoIniFile(object): """ - stdout = io.StringIO() + if sys.version_info[0] >= 3: + stdout = io.BytesIO() + else: + stdout = io.StringIO() self.iniConfig.write(stdout) _ret_val = stdout.getvalue() stdout.close() -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/python-x2go.git