Salome HOME
Merge branch 'V7_dev'
[modules/smesh.git] / src / Tools / YamsPlug / monViewText.py
index 478e1833d0b0f4d46f3125283b552a6b65d163a2..38aeed49bbd1e1e52d3bce8e27191a3d6b41b402 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright (C) 2007-2015  EDF R&D
+# Copyright (C) 2007-2016  EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -19,8 +19,9 @@
 #
 
 # Modules Python
-import string,types,os
+import string,types,os, sys
 import traceback
+import tempfile
 
 from qtsalome import *
 
@@ -47,16 +48,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