[X2Go-Commits] [python-x2go] 07/10: Futurize: Re-add Python2 support back into python-x2go.
git-admin at x2go.org
git-admin at x2go.org
Sun Sep 24 10:51:38 CEST 2017
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository python-x2go.
commit fb1abc40097023943d4e68018d823489ebff56bd
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date: Sat Sep 23 23:06:35 2017 +0200
Futurize: Re-add Python2 support back into python-x2go.
---
x2go/_paramiko.py | 5 +++--
x2go/backends/control/plain.py | 21 +++++++++++++++++++--
x2go/backends/info/plain.py | 3 +++
x2go/backends/printing/file.py | 1 +
x2go/backends/printing/gconf.py | 1 +
x2go/backends/printing/winreg.py | 1 +
x2go/backends/profiles/base.py | 7 +++++--
x2go/backends/profiles/file.py | 2 +-
x2go/backends/profiles/httpbroker.py | 4 +++-
x2go/backends/proxy/base.py | 1 +
x2go/backends/settings/gconf.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 | 3 +++
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 | 5 ++++-
x2go/telekinesis.py | 1 +
x2go/utils.py | 5 ++++-
x2go/xserver.py | 1 +
29 files changed, 74 insertions(+), 10 deletions(-)
diff --git a/x2go/_paramiko.py b/x2go/_paramiko.py
index 746fc3d..7d9c958 100644
--- a/x2go/_paramiko.py
+++ b/x2go/_paramiko.py
@@ -21,6 +21,7 @@
Monkey Patch and feature map for Python Paramiko
"""
+from builtins import str
__PACKAGE__ = 'x2go'
@@ -69,9 +70,9 @@ def _SSHClient_save_host_keys(self, filename):
f = open(filename, 'w')
#f.write('# SSH host keys collected by paramiko\n')
_host_keys = self.get_host_keys()
- for hostname, keys in _host_keys.items():
+ for hostname, keys in list(_host_keys.items()):
- for keytype, key in keys.items():
+ for keytype, key in list(keys.items()):
f.write('%s %s %s\n' % (hostname, keytype, key.get_base64()))
f.close()
diff --git a/x2go/backends/control/plain.py b/x2go/backends/control/plain.py
index 34a32e0..435f5ca 100644
--- a/x2go/backends/control/plain.py
+++ b/x2go/backends/control/plain.py
@@ -23,6 +23,8 @@ L{X2GoControlSession} class - core functions for handling your individual X2Go s
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'
# modules
@@ -532,7 +534,17 @@ class X2GoControlSession(paramiko.SSHClient):
sanitized_stdout = ''
is_x2go_data = False
- for line in raw_stdout.decode().split('\n'):
+
+ # Python 3 needs a decoding from bytestring to (unicode) string
+ try:
+ raw_stdout = raw_stdout.decode()
+ except:
+ pass
+
+ for line in raw_stdout.split('\n'):
+
+ print (type(line))
+
if line.startswith('X2GODATABEGIN:'+cmd_uuid):
is_x2go_data = True
continue
@@ -540,7 +552,12 @@ class X2GoControlSession(paramiko.SSHClient):
if line.startswith('X2GODATAEND:'+cmd_uuid): break
sanitized_stdout += line + "\n"
- _stdout_new = io.StringIO(sanitized_stdout)
+ try:
+ # Python 3:
+ _stdout_new = io.StringIO(sanitized_stdout)
+ except TypeError:
+ # Python 2:
+ _stdout_new = io.StringIO(sanitized_stdout.decode())
_retval = (_stdin, _stdout_new, _stderr)
return _retval
diff --git a/x2go/backends/info/plain.py b/x2go/backends/info/plain.py
index 51558c3..ab7123a 100644
--- a/x2go/backends/info/plain.py
+++ b/x2go/backends/info/plain.py
@@ -25,6 +25,9 @@ This backend handles X2Go server implementations that respond with session infos
via server-side PLAIN text output.
"""
+from __future__ import print_function
+from builtins import str
+from builtins import object
__NAME__ = 'x2goserversessioninfo-pylib'
diff --git a/x2go/backends/printing/file.py b/x2go/backends/printing/file.py
index bdb14c6..131b9cc 100644
--- a/x2go/backends/printing/file.py
+++ b/x2go/backends/printing/file.py
@@ -25,6 +25,7 @@ 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'
# modules
diff --git a/x2go/backends/printing/gconf.py b/x2go/backends/printing/gconf.py
index 556f33f..ce6b568 100644
--- a/x2go/backends/printing/gconf.py
+++ b/x2go/backends/printing/gconf.py
@@ -25,6 +25,7 @@ Use this class in your Python X2Go based applications to access the »printing«
configuration of your X2Go client application.
"""
+from builtins import object
__NAME__ = 'x2goprint-pylib'
# modules
diff --git a/x2go/backends/printing/winreg.py b/x2go/backends/printing/winreg.py
index e0dbc66..56d0c9b 100644
--- a/x2go/backends/printing/winreg.py
+++ b/x2go/backends/printing/winreg.py
@@ -25,6 +25,7 @@ Use this class in your Python X2Go based applications to access the »printing«
configuration of your X2Go client application.
"""
+from builtins import object
__NAME__ = 'x2goprint-pylib'
# modules
diff --git a/x2go/backends/profiles/base.py b/x2go/backends/profiles/base.py
index 3e02492..aa53c69 100644
--- a/x2go/backends/profiles/base.py
+++ b/x2go/backends/profiles/base.py
@@ -24,6 +24,8 @@ L{X2GoSessionProfiles} is a public API class. Use this class in your Python X2Go
applications.
"""
+from builtins import str
+from builtins import object
__NAME__ = 'x2gosessionprofiles-pylib'
import copy
@@ -38,7 +40,7 @@ import x2go.utils as utils
from x2go.x2go_exceptions import X2GoProfileException
-class X2GoSessionProfiles():
+class X2GoSessionProfiles(object):
defaultSessionProfile = copy.deepcopy(_X2GO_SESSIONPROFILE_DEFAULTS)
_non_profile_sections = ('embedded')
@@ -340,7 +342,8 @@ class X2GoSessionProfiles():
if type(value) is bytes:
value = str(value)
- if option == 'export' and type(value) is str:
+ # the type check is a nasty Python2/Python3 hack around unicodes and strings
+ if option == 'export' and (type(value) is type(u'') or type(value) is type('')):
_value = value.replace(',', ';').strip().strip('"').strip().strip(';').strip()
value = {}
diff --git a/x2go/backends/profiles/file.py b/x2go/backends/profiles/file.py
index cb029c3..a91a672 100644
--- a/x2go/backends/profiles/file.py
+++ b/x2go/backends/profiles/file.py
@@ -86,7 +86,7 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles, inifiles.X2GoIniFile):
session_profiles = [ p for p in self.iniConfig.sections() if p not in self._non_profile_sections and p != 'none' ]
_session_profiles_dict = {}
for session_profile in session_profiles:
- for key, default_value in self.defaultSessionProfile.items():
+ for key, default_value in list(self.defaultSessionProfile.items()):
if not self.iniConfig.has_option(session_profile, key):
self._storeValue(session_profile, key, default_value)
# update cached meta type session profile information
diff --git a/x2go/backends/profiles/httpbroker.py b/x2go/backends/profiles/httpbroker.py
index 72b7bdb..4c652a2 100644
--- a/x2go/backends/profiles/httpbroker.py
+++ b/x2go/backends/profiles/httpbroker.py
@@ -24,6 +24,8 @@ L{X2GoSessionProfiles} is a public API class. Use this class in your Python X2Go
applications.
"""
+from __future__ import print_function
+from builtins import str
__NAME__ = 'x2gosessionprofiles-pylib'
import re
@@ -375,7 +377,7 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles):
for session_profile in _session_profiles:
session_profile = str(session_profile)
- for key, default_value in self.defaultSessionProfile.items():
+ for key, default_value in list(self.defaultSessionProfile.items()):
key = str(key)
if type(default_value) is bytes:
default_value = str(default_value)
diff --git a/x2go/backends/proxy/base.py b/x2go/backends/proxy/base.py
index 10c4c21..77ba67f 100644
--- a/x2go/backends/proxy/base.py
+++ b/x2go/backends/proxy/base.py
@@ -21,6 +21,7 @@
X2GoProxy class - proxying your connection through NX3 and others.
"""
+from builtins import str
__NAME__ = 'x2goproxy-pylib'
# modules
diff --git a/x2go/backends/settings/gconf.py b/x2go/backends/settings/gconf.py
index 9a4b62f..759b47c 100644
--- a/x2go/backends/settings/gconf.py
+++ b/x2go/backends/settings/gconf.py
@@ -26,6 +26,7 @@ in your Python X2Go based applications to access the
»settings« configuration file of your X2Go client application.
"""
+from builtins import object
__NAME__ = 'x2gosettings-pylib'
# modules
diff --git a/x2go/backends/terminal/plain.py b/x2go/backends/terminal/plain.py
index c80565f..82e71c4 100644
--- a/x2go/backends/terminal/plain.py
+++ b/x2go/backends/terminal/plain.py
@@ -24,6 +24,8 @@ 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'
# modules
diff --git a/x2go/cache.py b/x2go/cache.py
index b04fca8..c8359c0 100644
--- a/x2go/cache.py
+++ b/x2go/cache.py
@@ -21,6 +21,8 @@
X2GoListSessionCache class - caching X2Go session information.
"""
+from builtins import str
+from builtins import object
__NAME__ = 'x2gocache-pylib'
# modules
diff --git a/x2go/checkhosts.py b/x2go/checkhosts.py
index b118279..825996c 100644
--- a/x2go/checkhosts.py
+++ b/x2go/checkhosts.py
@@ -21,6 +21,8 @@
Providing mechanisms to C{X2GoControlSession*} backends for checking host validity.
"""
+from builtins import str
+from builtins import range
__NAME__ = 'x2gocheckhosts-pylib'
# modules
diff --git a/x2go/client.py b/x2go/client.py
index fa3c53e..6cff86f 100644
--- a/x2go/client.py
+++ b/x2go/client.py
@@ -115,6 +115,8 @@ Session Suspending/Terminating
x2go_client.terminate_session(x2go_sess_uuid)
"""
+from builtins import str
+from builtins import object
__NAME__ = 'x2goclient-pylib'
#modules
diff --git a/x2go/defaults.py b/x2go/defaults.py
index 3d03481..2b9ed83 100644
--- a/x2go/defaults.py
+++ b/x2go/defaults.py
@@ -21,6 +21,8 @@
Default variables and values for Python X2Go.
"""
+from builtins import str
+from builtins import range
__NAME__ = 'x2godefaults-pylib'
import os
diff --git a/x2go/gevent_subprocess.py b/x2go/gevent_subprocess.py
index 8e823df..24d3bde 100644
--- a/x2go/gevent_subprocess.py
+++ b/x2go/gevent_subprocess.py
@@ -38,6 +38,7 @@
"""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 6b9c268..ea06f8f 100644
--- a/x2go/inifiles.py
+++ b/x2go/inifiles.py
@@ -27,6 +27,9 @@
X2GoProcessIniFile - helper class for parsing .ini files
"""
+from __future__ import print_function
+from builtins import str
+from builtins import object
__NAME__ = 'x2goinifiles-pylib'
# modules
diff --git a/x2go/log.py b/x2go/log.py
index 20bc3b0..1b10c3b 100644
--- a/x2go/log.py
+++ b/x2go/log.py
@@ -21,6 +21,7 @@
X2GoLogger class - flexible handling of log and debug output.
"""
+from builtins import object
__NAME__ = 'x2gologger-pylib'
# modules
diff --git a/x2go/mimeboxactions.py b/x2go/mimeboxactions.py
index cc03c08..37b9018 100644
--- a/x2go/mimeboxactions.py
+++ b/x2go/mimeboxactions.py
@@ -22,6 +22,8 @@ For MIME box jobs there are currently three handling actions available:
L{X2GoMIMEboxActionOPEN}, L{X2GoMIMEboxActionOPENWITH} and L{X2GoMIMEboxActionSAVEAS}.
"""
+from builtins import str
+from builtins import object
__NAME__ = 'x2gomimeboxactions-pylib'
# modules
diff --git a/x2go/printactions.py b/x2go/printactions.py
index c730eba..468ec09 100644
--- a/x2go/printactions.py
+++ b/x2go/printactions.py
@@ -25,6 +25,8 @@ over to a custom (print) command. This is defined by four print action classes
L{X2GoPrintActionPRINTCMD}).
"""
+from builtins import str
+from builtins import object
__NAME__ = 'x2goprintactions-pylib'
# modules
diff --git a/x2go/registry.py b/x2go/registry.py
index 6dde80d..5ad68bc 100644
--- a/x2go/registry.py
+++ b/x2go/registry.py
@@ -21,6 +21,8 @@
X2GoSessionRegistry class - the X2GoClient's session registry backend
"""
+from builtins import str
+from builtins import object
__NAME__ = 'x2gosessregistry-pylib'
import os
diff --git a/x2go/rforward.py b/x2go/rforward.py
index 77146f5..5c84b16 100644
--- a/x2go/rforward.py
+++ b/x2go/rforward.py
@@ -21,6 +21,7 @@ X2Go sshfs for folder sharing and mounting remote devices in X2Go terminal
server sessions.
"""
+from builtins import str
__NAME__ = 'x2gorevtunnel-pylib'
# modules
diff --git a/x2go/session.py b/x2go/session.py
index 08541a6..dedac10 100644
--- a/x2go/session.py
+++ b/x2go/session.py
@@ -48,6 +48,8 @@ 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 3e66b9a..cfc0aee 100644
--- a/x2go/sftpserver.py
+++ b/x2go/sftpserver.py
@@ -29,6 +29,7 @@ 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"
import os
diff --git a/x2go/sshproxy.py b/x2go/sshproxy.py
index 690c225..0b86159 100644
--- a/x2go/sshproxy.py
+++ b/x2go/sshproxy.py
@@ -21,6 +21,9 @@
L{X2GoSSHProxy} class - providing a forwarding tunnel for connecting to servers behind firewalls.
"""
+from __future__ import print_function
+from builtins import str
+from builtins import range
__NAME__ = 'x2gosshproxy-pylib'
# modules
@@ -193,7 +196,7 @@ class X2GoSSHProxy(paramiko.SSHClient, threading.Thread):
remote_host = [remote_host]
if remote_host and type(remote_host) in (list, tuple):
remote_host = random.choice(remote_host)
- print("LOCAL_HOST: ", local_host)
+ print(("LOCAL_HOST: ", local_host))
self.local_host = local_host
self.local_port = int(local_port)
self.remote_host = remote_host
diff --git a/x2go/telekinesis.py b/x2go/telekinesis.py
index babb747..1ce9564 100644
--- a/x2go/telekinesis.py
+++ b/x2go/telekinesis.py
@@ -21,6 +21,7 @@
X2GoTelekinesisClient class - Connect to Telekinesis Server on X2Go Server.
"""
+from builtins import str
__NAME__ = 'x2gotelekinesisclient-pylib'
# modules
diff --git a/x2go/utils.py b/x2go/utils.py
index 5b89cd5..1b9fca1 100644
--- a/x2go/utils.py
+++ b/x2go/utils.py
@@ -21,6 +21,9 @@
Python X2Go helper functions, constants etc.
"""
+from builtins import str
+from builtins import range
+from builtins import object
__NAME__ = 'x2goutils-pylib'
import sys
@@ -229,7 +232,7 @@ def _convert_SessionProfileOptions_2_SessionParams(options):
'4': 'lan',
}
- for opt, val in options.items():
+ for opt, val in list(options.items()):
# rename options if necessary
if opt in list(_rename_dict.keys()):
diff --git a/x2go/xserver.py b/x2go/xserver.py
index a9e577b..9b0c761 100644
--- a/x2go/xserver.py
+++ b/x2go/xserver.py
@@ -1,3 +1,4 @@
+from builtins import str
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2016 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
--
Alioth's /srv/git/code.x2go.org/python-x2go.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
More information about the x2go-commits
mailing list