From: vsr Date: Tue, 22 Mar 2016 08:26:23 +0000 (+0300) Subject: 0023235: [CEA 1730] Patches for SMESH on Windows X-Git-Tag: V7_8_0a2~4^2~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c445ce74d816a2f89830ef0527a7ef9e76144c5e;p=modules%2Fsmesh.git 0023235: [CEA 1730] Patches for SMESH on Windows --- diff --git a/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py b/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py index baef24bc6..b51f9ebc6 100644 --- a/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py +++ b/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py @@ -22,6 +22,7 @@ # Modules Eficas import os, subprocess +import tempfile from MGCleanerPlugDialog_ui import Ui_MGCleanerPlugDialog from MGCleanerMonViewText import MGCleanerMonViewText from PyQt4.QtGui import * @@ -470,7 +471,9 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget): self.fichierIn="" def prepareFichier(self): - self.fichierIn="/tmp/ForMGCleaner_"+str(self.num)+".mesh" + self.fichierIn=tempfile.mktemp(suffix=".mesh",prefix="ForMGCleaner_") + if os.path.exists(self.fichierIn): + os.remove(self.fichierIn) self.__selectedMesh.ExportGMF(self.__selectedMesh, self.fichierIn, True) def PrepareLigneCommande(self): diff --git a/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py b/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py index af7ca7bd5..e4030cc44 100644 --- a/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py +++ b/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py @@ -19,7 +19,8 @@ # # Modules Python -import string,types,os +import string,types,os,sys +import tempfile import traceback from PyQt4 import * @@ -51,16 +52,39 @@ class MGCleanerMonViewText(Ui_ViewExe, QDialog): # Je n arrive pas a utiliser le setEnvironment du QProcess # fonctionne hors Salome mais pas dans Salome ??? cmds='' + ''' + try : + LICENCE_FILE=os.environ["DISTENE_LICENCE_FILE_FOR_MGCLEANER"] + except: + LICENCE_FILE='' + try : + PATH=os.environ["DISTENE_PATH_FOR_MGCLEANER"] + except: + PATH='' + if LICENCE_FILE != '': + cmds+='source '+LICENCE_FILE+'\n' + else: + cmds+="# $DISTENE_LICENCE_FILE_FOR_MGCLEANER NOT SET\n" + if PATH != '': + cmds+='export PATH='+PATH+':$PATH\n' + else: + cmds+="# $DISTENE_PATH_FOR_MGCLEANER NOT SET\n" + #cmds+='env\n' cmds+='rm -f '+self.parent().fichierOut+'\n' + ''' cmds+=txt+'\n' cmds+='echo END_OF_MGCleaner\n' - pid=self.monExe.pid() - nomFichier='/tmp/MGCleaner_'+str(pid)+'.sh' + ext='' + if sys.platform == "win32": + ext = '.bat' + else: + ext = '.sh' + nomFichier=tempfile.mktemp(suffix=ext,prefix="MGCleaner_") f=open(nomFichier,'w') f.write(cmds) f.close() - maBidouille='sh ' + nomFichier + maBidouille=nomFichier self.monExe.start(maBidouille) self.monExe.closeWriteChannel() self.enregistreResultatsDone=False diff --git a/src/Tools/YamsPlug/monViewText.py b/src/Tools/YamsPlug/monViewText.py index d4356a925..7d02228e4 100644 --- a/src/Tools/YamsPlug/monViewText.py +++ b/src/Tools/YamsPlug/monViewText.py @@ -19,8 +19,9 @@ # # Modules Python -import string,types,os +import string,types,os, sys import traceback +import tempfile from PyQt4 import * from PyQt4.QtGui import * @@ -49,16 +50,25 @@ class MonViewText(Ui_ViewExe, QDialog): # Je n arrive pas a utiliser le setEnvironment du QProcess # fonctionne hors Salome mais pas dans Salome ??? cmds='' - cmds+='rm -f '+self.parent().fichierOut+'\n' + #cmds+='#! /usr/bin/env python\n' + #cmds+='# -*- coding: utf-8 -*-\n' cmds+=txt+'\n' - cmds+='echo END_OF_Yams\n' - pid=self.monExe.pid() - nomFichier='/tmp/Yams_'+str(pid)+'.sh' + cmds+='echo "END_OF_Yams"\n' + if os.path.exists(self.parent().fichierOut): + os.remove(self.parent().fichierOut) + + ext='' + if sys.platform == "win32": + ext = '.bat' + else: + ext = '.sh' + + nomFichier=tempfile.mktemp(suffix=ext,prefix='Yams_') f=open(nomFichier,'w') f.write(cmds) f.close() - maBidouille='sh ' + nomFichier + maBidouille=nomFichier self.monExe.start(maBidouille) self.monExe.closeWriteChannel() self.enregistreResultatsDone=False diff --git a/src/Tools/YamsPlug/monYamsPlugDialog.py b/src/Tools/YamsPlug/monYamsPlugDialog.py index e8a792571..37a15f6cc 100644 --- a/src/Tools/YamsPlug/monYamsPlugDialog.py +++ b/src/Tools/YamsPlug/monYamsPlugDialog.py @@ -22,6 +22,7 @@ # Modules Eficas import os, subprocess +import tempfile from YamsPlugDialog_ui import Ui_YamsPlugDialog from monViewText import MonViewText from PyQt4.QtGui import * @@ -430,7 +431,9 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget): self.fichierIn="" def prepareFichier(self): - self.fichierIn="/tmp/ForSurfOpt_"+str(self.num)+".meshb" + self.fichierIn=tempfile.mktemp(suffix=".meshb",prefix="ForSurfOpt_") + if os.path.exists(self.fichierIn): + os.remove(self.fichierIn) self.__selectedMesh.ExportGMF(self.__selectedMesh, self.fichierIn, True) def PrepareLigneCommande(self):