[X2Go-Commits] [python-x2go] 01/01: x2go/{backends/printing/file.py, defaults.py}: Fix type mismatch (str vs. unicode) when opening print settings dialog in PyHoca-GUI (still using Python2).

git-admin at x2go.org git-admin at x2go.org
Tue Jul 23 21:53:53 CEST 2019


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository python-x2go.

commit 797dc15aecc702e7bc925e29d5bc67c3e78bb612
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Tue Jul 23 15:55:53 2019 +0200

    x2go/{backends/printing/file.py,defaults.py}: Fix type mismatch (str vs. unicode) when opening print settings dialog in PyHoca-GUI (still using Python2).
---
 debian/changelog               | 3 +++
 x2go/backends/printing/file.py | 6 ++++--
 x2go/defaults.py               | 9 +++++++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 4a73fb1..48d2b7e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,6 +14,9 @@ python-x2go (0.6.1.0-0x2go1) UNRELEASED; urgency=medium
     - X2GoServerSessionList: Provide proper accessor method for getting
       the complete list of sessions.
     - Fix CINNAMON (2d) support.
+    - x2go/{backends/printing/file.py,defaults.py}: Fix type mismatch (str
+      vs. unicode) when opening print settings dialog in PyHoca-GUI (still
+      using Python2).
   * debian/control:
     + Add x2gokdriveclient as hard dependency for both bin:pkgs python{,3}-x2go.
 
diff --git a/x2go/backends/printing/file.py b/x2go/backends/printing/file.py
index 9b4b23d..f27bb51 100644
--- a/x2go/backends/printing/file.py
+++ b/x2go/backends/printing/file.py
@@ -34,6 +34,7 @@ __name__    = 'x2go.backends.printing.file'
 
 # modules
 import types
+import sys
 
 # Python X2Go modules
 import x2go.log as log
@@ -205,8 +206,9 @@ class X2GoClientPrinting(inifiles.X2GoIniFile):
             _ini_section = _print_property_map[print_property]['ini_section']
             _ini_option = _print_property_map[print_property]['ini_option']
             _default_type = self.get_type(_ini_section, _ini_option)
-            if type(value) is str:
-                value = value.encode('utf-8')
+            if sys.version_info[0] < 3:
+                if type(value) is str:
+                    value = value.encode('utf-8')
             if  _default_type != type(value):
                 raise x2go_exceptions.X2GoClientPrintingException('Type mismatch error for property ,,%s\'\' - is: %s, should be: %s' % (print_property, str(type(value)), str(_default_type)))
             self.update_value(_ini_section, _ini_option, value)
diff --git a/x2go/defaults.py b/x2go/defaults.py
index c6250d5..6d5aa17 100644
--- a/x2go/defaults.py
+++ b/x2go/defaults.py
@@ -29,6 +29,7 @@ __name__    = 'x2go.defaults'
 import os
 import paramiko
 import platform
+import sys
 
 ##
 ## Common X2Go defaults
@@ -229,6 +230,14 @@ X2GO_CLIENTPRINTING_DEFAULTS = {
         'defaultprinter': 'PDF',
     },
 }
+
+# enforce printing defaults (when of str type) to be of unicode type
+if sys.version_info[0] < 3:
+    X2GO_CLIENTPRINTING_DEFAULTS['print']['command'] = u'lpr'
+    X2GO_CLIENTPRINTING_DEFAULTS['save']['folder'] = u'PDF'
+    X2GO_CLIENTPRINTING_DEFAULTS['view']['command'] = u'xdg-open'
+    X2GO_CLIENTPRINTING_DEFAULTS['CUPS']['defaultprinter'] = u'PDF'
+
 if X2GOCLIENT_OS == 'Windows':
     X2GO_CLIENTPRINTING_DEFAULTS['print'].update({'gsprint': os.path.join(os.environ['ProgramFiles'], 'GhostGum', 'gsview', 'gsprint.exe'), })
 

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/python-x2go.git


More information about the x2go-commits mailing list