Fixed issues with the install script under Python2.

Tue, 25 Nov 2014 19:29:19 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 25 Nov 2014 19:29:19 +0100
changeset 3939
fc1ea4bbb201
parent 3938
d2b103d42907
child 3942
a79c9261e7a8

Fixed issues with the install script under Python2.

install.py file | annotate | diff | comparison | revisions
--- a/install.py	Tue Nov 25 19:16:34 2014 +0100
+++ b/install.py	Tue Nov 25 19:29:19 2014 +0100
@@ -27,6 +27,12 @@
 import distutils.sysconfig
 import codecs
 
+if sys.version_info[0] == 2:
+    import sip
+    sip.setapi('QString', 2)
+    sip.setapi('QVariant', 2)
+    sip.setapi('QTextStream', 2)
+
 # Define the globals.
 progName = None
 currDir = os.getcwd()
@@ -263,13 +269,19 @@
     @param dst destination file name (string)
     @param marker marker to be used (string)
     """
-    f = open(src, "r")
+    if sys.version_info[0] == 2:
+        f = codecs.open(src, "r", "utf-8")
+    else:
+        f = open(src, "r")
     text = f.read()
     f.close()
     
     text = text.replace("@MARKER@", marker)
     
-    f = open(dst, "w")
+    if sys.version_info[0] == 2:
+        f = codecs.open(dst, "w", "utf-8")
+    else:
+        f = open(dst, "w")
     f.write(text)
     f.close()
     os.chmod(dst, 0o644)

eric ide

mercurial