From 93820cd2964297107aba675efb8083b993d1252f Mon Sep 17 00:00:00 2001
From: Romain Boman <romain.boman@gmail.com>
Date: Sat, 2 May 2020 16:28:29 +0200
Subject: [PATCH] futurize pyw

---
 externalProgramPathGui.pyw | 13 +++++++------
 launchGui.pyw              | 25 ++++++++++++++-----------
 postProLoopGui.pyw         | 13 +++++++------
 3 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/externalProgramPathGui.pyw b/externalProgramPathGui.pyw
index ef95028..8c5f805 100755
--- a/externalProgramPathGui.pyw
+++ b/externalProgramPathGui.pyw
@@ -4,6 +4,7 @@
 # Gui to configure externals program path according to local configuration
 
 ## Qt ##
+from __future__ import print_function
 foundQt=0
 try:
     from PyQt4.QtCore import *
@@ -137,20 +138,20 @@ class ExtProgsConfGui(QWidget):
     def updateWidgetsValues(self):
         self.extProgPath.applyDependencies()
         if self.extProgPath.debug :
-            print "updateWidgetsValues"
+            print("updateWidgetsValues")
         for var in self.sf:
             self.sf[var].setParamValue()
              
     def updateWidgetsVisibility(self):
         if self.extProgPath.debug :
-            print "updateWidgetsVisibility"
+            print("updateWidgetsVisibility")
         # update enabled/disabled of options  
         self.extProgPath.configActions()
         for var in self.sf:
             self.sf[var].setEnabled(self.extProgPath.pars[var].enabled)           
     def updateWidgetsValues(self):
         if self.extProgPath.debug :
-            print "updateWidgetsVisibility"
+            print("updateWidgetsVisibility")
         # update enabled/disabled of options  
         self.extProgPath.configActions()
         for var in self.sf:
@@ -158,17 +159,17 @@ class ExtProgsConfGui(QWidget):
             
     def userSave(self):     
         if self.extProgPath.debug :
-            print "Save pressed"
+            print("Save pressed")
         self.extProgPath.savePars()  
          
     def progSave(self):   
         if self.extProgPath.debug :  
-            print "Save pressed"
+            print("Save pressed")
         self.extProgPath.savePars('.')
 
     def quit(self):
         if self.extProgPath.debug :
-            print "Quit pressed"   
+            print("Quit pressed")   
         sys.exit()     
         
         
diff --git a/launchGui.pyw b/launchGui.pyw
index c9e7a28..936fa7c 100755
--- a/launchGui.pyw
+++ b/launchGui.pyw
@@ -11,6 +11,9 @@
 #     unicodestr.encode('ascii','ignore')
 #
 
+from __future__ import print_function
+from builtins import map
+from builtins import str
 import os,sys
 from prmClassesGui import *
 from launch import *
@@ -239,7 +242,7 @@ class LaunchGui(QWidget):
     # ----------------------------------------------------------------------------------    
     
     def go(self):    
-        print "Go pressed"
+        print("Go pressed")
         
         # disable the gui modifications during run
         self.guiEnable(False)
@@ -274,7 +277,7 @@ class LaunchGui(QWidget):
             # launch.go() ...
             self.launch.go()    
             
-        except Exception, e:
+        except Exception as e:
             #print e
             QMessageBox.information(self, 'Error', str(e))     
         
@@ -282,9 +285,9 @@ class LaunchGui(QWidget):
         self.guiEnable(True)
         
     def interrupt(self):
-        print "interrupt pressed"
+        print("interrupt pressed")
         self.process.kill()
-        print "interrupt done"
+        print("interrupt done")
         
     # Boucle d'execution du Qprocess avec recuperation des events 
     def waitQProcessForFinish(self):
@@ -300,25 +303,25 @@ class LaunchGui(QWidget):
         return retcode                                
     
     def save(self):     
-        print "Save pressed"
+        print("Save pressed")
         self.baseDir.savePars()
         #self.launch.printPars()
         self.launch.savePars()   
 
     def quit(self):
-        print "Quit pressed"   
+        print("Quit pressed")   
         sys.exit()    
                   
     def updateWidgetsValues(self):
         self.launch.applyDependencies()
         if self.launch.debug :
-            print "updateWidgetsValues"
+            print("updateWidgetsValues")
         for var in self.sf:
             self.sf[var].setParamValue()
                 
     def updateWidgetsVisibility(self):
         if self.launch.debug :
-            print "updateWidgetsVisibility"
+            print("updateWidgetsVisibility")
         # update enabled/disabled of options  
         self.launch.configActions()
         for var in self.sf:
@@ -367,7 +370,7 @@ class LaunchGui(QWidget):
                 
     def write(self, stuff):
         if '\n' in stuff:
-            map( self.writeLine, stuff.split("\n") )
+            list(map( self.writeLine, stuff.split("\n") ))
         else:
             self.buf += stuff 
         self.app.processEvents()
@@ -386,14 +389,14 @@ def main():
     #define launcher
     launch = LaunchJob()
     if launch.debug :
-        print "launch defined"
+        print("launch defined")
     # create gui    
     launchGui = LaunchGui(launch) 
     # opening Gui 
     launchGui.show()    
     # signal pour cloturer proprement l'application PyQt quand on ferme la fenetre
     launchGui.app.lastWindowClosed.connect(launchGui.app.quit)
-    print "ready."
+    print("ready.")
     sys.exit(launchGui.app.exec_())
 
 if __name__=="__main__":
diff --git a/postProLoopGui.pyw b/postProLoopGui.pyw
index 84bbc9a..9dd2609 100755
--- a/postProLoopGui.pyw
+++ b/postProLoopGui.pyw
@@ -7,6 +7,7 @@
 # 
 
 ## Qt ##
+from __future__ import print_function
 foundQt=0
 try:
     from PyQt4.QtCore import *
@@ -176,13 +177,13 @@ class PostProLoopGui(QWidget):
     def updateWidgetsValues(self):
         self.postProLoop.applyDependencies()
         if self.postProLoop.debug:
-            print "updateWidgetsValues"
+            print("updateWidgetsValues")
         for var in self.sf:
             self.sf[var].setParamValue() 
                         
     def updateWidgetsVisibility(self):
         if self.postProLoop.debug:
-            print "updateWidgetsVisibility"
+            print("updateWidgetsVisibility")
         # update enabled/disabled of options  
         self.postProLoop.configActions()
         for var in self.sf:
@@ -190,7 +191,7 @@ class PostProLoopGui(QWidget):
                    
     def updateWidgetsValues(self):
         if self.postProLoop.debug:
-            print "updateWidgetsVisibility"
+            print("updateWidgetsVisibility")
         # update enabled/disabled of options  
         self.postProLoop.configActions()
         for var in self.sf:
@@ -198,17 +199,17 @@ class PostProLoopGui(QWidget):
             
     def go(self):     
         if self.postProLoop.debug:
-            print "Go pressed"
+            print("Go pressed")
         self.postProLoop.go()
         
     def save(self):     
         if self.postProLoop.debug:
-            print "Save pressed"
+            print("Save pressed")
         self.postProLoop.savePars('.')   
 
     def quit(self):
         if self.postProLoop.debug:
-            print "Quit pressed"   
+            print("Quit pressed")   
         sys.exit()     
         
 # ============== Main ========================        
-- 
GitLab