From 9bcbbd5cc75d1f3a5b643720c4401681eb034999 Mon Sep 17 00:00:00 2001
From: Luc Papeleux <L.Papeleux@ULiege.be>
Date: Wed, 8 Jul 2020 16:07:19 +0200
Subject: [PATCH] formal cleaning

---
 cleanLocalHdd.py           |  2 +-
 comp.py                    |  2 +-
 externalProgramPath.py     |  2 +-
 externalProgramPathGui.pyw |  2 +-
 launch.py                  | 10 +---------
 launchGui.pyw              |  8 ++------
 parametricJob.py           |  5 +++--
 postProLoop.py             |  2 +-
 postProLoopGui.pyw         |  2 +-
 prmClasses.py              |  1 +
 prmClassesGui.py           | 12 +-----------
 11 files changed, 14 insertions(+), 34 deletions(-)

diff --git a/cleanLocalHdd.py b/cleanLocalHdd.py
index dfe60c6..8f09b5b 100755
--- a/cleanLocalHdd.py
+++ b/cleanLocalHdd.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!python3
 # -*- coding: utf-8 -*-
 #
 # Script cleanLocalHdd.py : listing de l'utilisation et nettoyage des disques locaux sur le cluster
diff --git a/comp.py b/comp.py
index becc120..5969eff 100755
--- a/comp.py
+++ b/comp.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!python3
 # -*- coding: utf-8 -*-
 #
 # Script "comp.py":
diff --git a/externalProgramPath.py b/externalProgramPath.py
index 208b8c9..250cbaa 100755
--- a/externalProgramPath.py
+++ b/externalProgramPath.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!python3
 # -*- coding: utf-8 -*-
 #
 # Define external program paths according to local configuration
diff --git a/externalProgramPathGui.pyw b/externalProgramPathGui.pyw
index 989470f..990ee5c 100755
--- a/externalProgramPathGui.pyw
+++ b/externalProgramPathGui.pyw
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!python3
 # -*- coding: utf-8 -*-
 #
 # Gui to configure externals program path according to local configuration
diff --git a/launch.py b/launch.py
index 9a042f4..3500dc6 100755
--- a/launch.py
+++ b/launch.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!python3
 # -*- coding: utf-8 -*-
 #
 # Script "launch.py": aide au lancement d'un job Metafor
@@ -344,19 +344,12 @@ class LaunchJob(ParametricJob):
         if self.debug:
             pin.write(b'print ("sys.path = ", sys.path)\n')
             pin.write(b'print ("os.getcwd() = ", os.getcwd())\n')
-        #pin.write("raw_input()\n")
-        print ("mtfdir = ", mtfdir)
-        print ("type mtfdir = ", type(mtfdir))
         pin.write(('if os.path.isdir(r"%s"):\n'%mtfdir).encode('utf-8'))
-        #pin.write(('if os.path.isdir(r"%s"):\n'%mtfdir))
         pin.write(('\tsys.path.append(r"%s")\n'%mtfdir).encode('utf-8')) # mtfdir est dorenavant un abspath
-        #pin.write(('\tsys.path.append(r"%s")\n'%mtfdir)) # mtfdir est dorenavant un abspath
-        #pin.write('\tsys.path.append(os.path.abspath(r"%s"))\n'%mtfdir)
         pin.write(b'else:\n')
         pin.write(('\tprint ("metafor dir %s not found!")\n'%mtfdir).encode('utf-8'))
         pin.write(b'\tsys.exit()\n\n')
         pin.write(('exec(open(r"%s").read())\n'%os.path.join(mtfdir,'.pythonrc.py')).encode('utf-8'))
-        #pin.write(('execfile(r"%s")\n'%os.path.join(mtfdir,'.pythonrc.py')).encode())
         pin.write(b'import toolbox.battery as b\n')
         pin.write(b'battery = b.Battery() \n')
         pin.write(b'battery.keepFacs = True\n')
@@ -390,7 +383,6 @@ class LaunchJob(ParametricJob):
             if self.pars['AFFINITY'].val != '':
                 pin.write(('battery.setAffinity("%s")\n'%self.pars['AFFINITY'].val).encode('utf-8'))
             if self.pars['NICE_VALUE'].val != '0':
-                #print ('battery.setNice(%s)\n'%self.pars['NICE_VALUE'].val)
                 pin.write(('battery.setNice(%s)\n'%self.pars['NICE_VALUE'].val).encode('utf-8'))
 
         pin.write(('battery.setNumTasks(%s)\n'%self.pars['NB_TASKS'].val).encode('utf-8'))
diff --git a/launchGui.pyw b/launchGui.pyw
index fe29410..4e15048 100755
--- a/launchGui.pyw
+++ b/launchGui.pyw
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!python3
 # -*- coding: utf-8 -*-
 #
 # GUI de launch.py - version Qt
@@ -242,8 +242,7 @@ class LaunchGui(QWidget):
     # ----------------------------------------------------------------------------------    
     
     def go(self):    
-        print("Go pressed")
-        
+        print("Go pressed")        
         # disable the gui modifications during run
         self.guiEnable(False)
         try:
@@ -263,9 +262,7 @@ class LaunchGui(QWidget):
             if isUnix():
                 mtfdir, mtfexe = os.path.split(self.launch.pars['EXEC_NAME'].val)          
                 ldlp = mtfdir+':'+env.value('LD_LIBRARY_PATH','')
-                #print "old LD_LIBRARY_PATH = ", env.value('LD_LIBRARY_PATH','')
                 env.insert('LD_LIBRARY_PATH',ldlp)
-                #print "new LD_LIBRARY_PATH = ", env.value('LD_LIBRARY_PATH','')
 
             self.process.setProcessEnvironment(env)   
             # gestion du nice sur le QProcess : pas arrive a faire marcher !!!
@@ -278,7 +275,6 @@ class LaunchGui(QWidget):
             self.launch.go()    
             
         except Exception as e:
-            #print e
             QMessageBox.information(self, 'Error', str(e))     
         
         # re enable the gui modifications
diff --git a/parametricJob.py b/parametricJob.py
index 141018b..b5a81d5 100644
--- a/parametricJob.py
+++ b/parametricJob.py
@@ -1,3 +1,4 @@
+#!python3
 # -*- coding: utf-8 -*-
 
 from __future__ import print_function
@@ -236,7 +237,7 @@ class ParametricJob(PRMSet):
             cmd1 = "rsync -avz %s/* %s"%(localNodeDir, homeDir)
             #--remove-source-files permet de nettoyer la source, mais ca risque de poser problème avec le check ci dessous
             # qui plus est, ne supprime pas l'arborescence, juste les fichiers => nettoyage incomplet
-            print("cmd1 = ", cmd1)
+            #print("cmd1 = ", cmd1)
             subprocess.call([cmd1],stderr=subprocess.STDOUT, shell=True) #use of subprocess to be able to catch errors
             #execfile(self.cpNodeResultsScriptName(jobId))
             # check que la copie soit bonne (même fichiers des 2 cotés)
@@ -246,7 +247,7 @@ class ParametricJob(PRMSet):
             if recCmp(cmp): # copie parfaite => nettoyage brutal de l'arborescence
                 print("copie parfaite => nettoyage brutal de l'arborescence ")
                 cmd2 = "rm -rf %s"%localNodeDir
-                print("cmd2 = ", cmd2)
+                #print("cmd2 = ", cmd2)
                 subprocess.call([cmd2],stderr=subprocess.STDOUT, shell=True) # 2 commands for not deleting files if copy throw an exception
                 os.remove(self.cpNodeResultsScriptName(jobId))
                 os.remove(self.rmNodeResultsScriptName(jobId))
diff --git a/postProLoop.py b/postProLoop.py
index 5dc628c..df6bce6 100755
--- a/postProLoop.py
+++ b/postProLoop.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!python3
 # -*- coding: utf-8 -*-
 # $Id: externalProgramPath.py 2645 2016-05-12 06:29:38Z boman $
 #
diff --git a/postProLoopGui.pyw b/postProLoopGui.pyw
index ef1b5d0..3de2651 100755
--- a/postProLoopGui.pyw
+++ b/postProLoopGui.pyw
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!python3
 # -*- coding: utf-8 -*-
 # $Id: externalProgramPathGui.pyw 2384 2015-09-22 10:07:54Z papeleux $
 #
diff --git a/prmClasses.py b/prmClasses.py
index a20a801..01e355a 100644
--- a/prmClasses.py
+++ b/prmClasses.py
@@ -1,3 +1,4 @@
+#!python3
 # -*- coding: utf-8 -*-
 #
 # Classes de gestion des parametres
diff --git a/prmClassesGui.py b/prmClassesGui.py
index 847ed65..6c6b111 100644
--- a/prmClassesGui.py
+++ b/prmClassesGui.py
@@ -1,3 +1,4 @@
+#!python3
 # -*- coding: utf-8 -*-
 # $Id: prmClassesGui.py 2645 2016-05-12 06:29:38Z boman $
 #
@@ -80,7 +81,6 @@ class TextLine(PRMLine):
         self.setEnabled(self.param.enabled)
 
     def action(self):
-        #self.param.val = self.lineEdt.text().encode(coding)
         self.param.val = self.lineEdt.text()
         #print opt.key,'=',opt.val
         # update widgets visibility according to enable/disable
@@ -127,11 +127,8 @@ class PathLine(PRMLine):
     def action(self, dir):
         if dir:
             #print "PathLine.action:dir=", dir
-            #self.param.val = dir.encode(coding).replace('/',os.sep)
             self.param.val = dir.replace('/',os.sep)
-            #self.lineEdt.setText(self.param.val.decode(coding))
             self.lineEdt.setText(self.param.val)
-        #print self.param.key,'=',self.param.val
         # update widgets visibility according to enable/disable
         self.checkValidity()
         self.win.updateWidgetsVisibility()
@@ -191,9 +188,7 @@ class FileLine(PRMLine):
 
     def action(self, file):
         if file:
-            #self.param.val = file.encode(coding).replace('/', os.sep)
             self.param.val = file.replace('/', os.sep)
-            #self.lineEdt.setText(self.param.val.decode(coding))
             self.lineEdt.setText(self.param.val)
         #print "FileLine.action:", self.param.key,'=',self.param.val
         self.checkValidity()
@@ -258,9 +253,7 @@ class MultiPMRLine(PRMLine):
         self.setEnabled(self.param.enabled)
 
     def action(self):
-        #self.param.val = self.comboBox.currentText().encode(coding)
         self.param.val = self.comboBox.currentText()
-        #print self.param.val
         self.win.updateWidgetsVisibility()
         self.win.updateWidgetsValues()
 
@@ -304,7 +297,6 @@ class MultiPathLine(PRMLine):
     def cbIndexChangeAction(self):
         dir = self.comboBox.currentText()
         #print "cbIndexChangeAction:dir=",dir
-        #val = dir.encode(coding).replace('/',os.sep)
         val = dir.replace('/',os.sep)
         self.param.val = val
         if val in self.param.vals: # bidouille pour que la nouvelle valeur soit unique et toujours en premiere position
@@ -322,7 +314,6 @@ class MultiPathLine(PRMLine):
 
     def buttonAction(self):
         dir = QFileDialog.getExistingDirectory(self.win, "Choose %s directory" % self.param.key, self.param.val)
-        #self.setDir(dir)
         if dir:
             # managing comboBox
             idx = self.comboBox.findData(dir)
@@ -349,7 +340,6 @@ class MultiPathLine(PRMLine):
         self.win.updateWidgetsValues()
 
     def setParamValue(self):
-        #idx = self.comboBox.findText(self.param.val.decode(coding))
         idx = self.comboBox.findText(self.param.val)
         self.comboBox.setCurrentIndex(idx)
 
-- 
GitLab