From 61a0d059e7003dfd1bfd1c3a73c70519e27e8476 Mon Sep 17 00:00:00 2001
From: Luc Papeleux <L.Papeleux@ULiege.be>
Date: Wed, 22 Sep 2021 18:42:56 +0200
Subject: [PATCH] fix the use of scilab.bat as a scilab launcher and replace
 find_executable by which in checkValidity

---
 externalProgramPath.py     |  8 +++++---
 externalProgramPathGui.pyw | 12 ++++++++----
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/externalProgramPath.py b/externalProgramPath.py
index d31dc0c..f72b659 100755
--- a/externalProgramPath.py
+++ b/externalProgramPath.py
@@ -4,7 +4,7 @@
 # Define external program paths according to local configuration
 
 from prmClasses import *
-import os, os.path, distutils.spawn
+import os, os.path, shutil #,distutils.spawn
 
 class ExtProgs(PRMSet):
     def __init__(self, verb=False):
@@ -66,10 +66,12 @@ class ExtProgs(PRMSet):
             print("\t 3. If %s not in the Script last version, add it program in the Script..."%key)
             return False
 
-        if distutils.spawn.find_executable(os.path.splitext(self.pars[key].val)[0]) :
+        #if distutils.spawn.find_executable(os.path.splitext(self.pars[key].val)[0]) :
+        #if os.path.exists(self.pars[key].val) :
+        if shutil.which(self.pars[key].val) :
             return True
         else:
-            print("%s is not found in %s ..."%(key, self.pars[key].val))
+            print("%s is not found at %s ..."%(key, self.pars[key].val))
             print("\t Check installation and accessibility...")
             print("\t Use 'externalProgramPathGui' to define the full program path (recommanded)")
             print("\t or add %s in your user path (not recommanded)"%key)
diff --git a/externalProgramPathGui.pyw b/externalProgramPathGui.pyw
index 9f35f56..4b9557d 100755
--- a/externalProgramPathGui.pyw
+++ b/externalProgramPathGui.pyw
@@ -94,8 +94,12 @@ class ExtProgsConfGui(QWidget):
         grplay2 = QGridLayout()
         grplay2.setColumnStretch(2,1)
         self.mesherGrpBox.setLayout(grplay2)
-        self.sf['MATLAB']        = ExeFileLine(self, grplay2, self.extProgPath.pars['MATLAB'],     exeFileType, 0, 0, 4)
-        self.sf['SCILAB']        = ExeFileLine(self, grplay2, self.extProgPath.pars['SCILAB'],     exeFileType, 1, 0, 4)
+        self.sf['MATLAB']        = ExeFileLine(self, grplay2, self.extProgPath.pars['MATLAB'],     exeFileType, 0, 0, 4)        
+        if isUnix():
+            self.sf['SCILAB']        = ExeFileLine(self, grplay2, self.extProgPath.pars['SCILAB'],     exeFileType, 1, 0, 4)
+        else:
+            self.sf['SCILAB']        = ExeFileLine(self, grplay2, self.extProgPath.pars['SCILAB'],     "bat files (*.bat)", 1, 0, 4)
+            #self.sf['SCILAB']        = ExeFileLine(self, grplay2, self.extProgPath.pars['SCILAB'],     exeFileType, 1, 0, 4)
         self.sf['GNUPLOT']       = ExeFileLine(self, grplay2, self.extProgPath.pars['GNUPLOT'],    exeFileType, 2, 0, 4)
         
         #Text & image 
@@ -104,8 +108,8 @@ class ExtProgsConfGui(QWidget):
         grplay3 = QGridLayout()
         grplay3.setColumnStretch(2,1)
         self.mesherGrpBox.setLayout(grplay3)
-        self.sf['LATEX']             = ExeFileLine(self, grplay3, self.extProgPath.pars['LATEX'],     exeFileType, 0, 0, 4)
-        self.sf['GHOSTSCRIPT']       = ExeFileLine(self, grplay3, self.extProgPath.pars['GHOSTSCRIPT'],     exeFileType, 1, 0, 4)
+        self.sf['LATEX']             = ExeFileLine(self, grplay3, self.extProgPath.pars['LATEX'],          exeFileType, 0, 0, 4)
+        self.sf['GHOSTSCRIPT']       = ExeFileLine(self, grplay3, self.extProgPath.pars['GHOSTSCRIPT'],    exeFileType, 1, 0, 4)
         self.sf['IMAGEMAGICK']       = ExeFileLine(self, grplay3, self.extProgPath.pars['IMAGEMAGICK'],    exeFileType, 2, 0, 4)
         
     def buildButtonFrame(self, box):      
-- 
GitLab