2022-05-05 18:51:12 +05:00
|
|
|
# Copyright (C) 2016-2022 EDF R&D
|
2019-02-14 16:55:47 +05:00
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
|
|
#
|
2016-11-24 23:00:44 +05:00
|
|
|
|
|
|
|
from subprocess import Popen
|
|
|
|
from os import remove, getpid, path
|
|
|
|
|
|
|
|
def init(tmpdir):
|
|
|
|
global log
|
|
|
|
log=output(tmpdir)
|
|
|
|
log.initialise()
|
|
|
|
|
|
|
|
def message(typ, message, goOn=False):
|
|
|
|
global log
|
|
|
|
log.message(typ,message,goOn)
|
|
|
|
|
|
|
|
class output():
|
|
|
|
def __init__(self, tmpDir, tmpFile='Messages.txt'):
|
|
|
|
self.tmpFile=path.join(tmpDir,tmpFile)
|
|
|
|
|
|
|
|
def initialise(self):
|
|
|
|
try:
|
|
|
|
remove(self.tmpFile)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
f = open(self.tmpFile,'w')
|
|
|
|
f.write('\n ------------------------------\n')
|
2017-04-06 14:02:36 +05:00
|
|
|
f.write(' | BIENVENUE DANS L\'INTERFACE |\n')
|
2016-11-24 23:00:44 +05:00
|
|
|
f.write(' | ZCRACKS DE SALOME |\n')
|
2017-04-06 14:02:36 +05:00
|
|
|
f.write(' | VERSION BETA |\n')
|
2016-11-24 23:00:44 +05:00
|
|
|
f.write(' ------------------------------\n\n')
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
pid=getpid()
|
|
|
|
fenName='Zcracks message log'
|
|
|
|
proc = Popen(['xterm -T "%s" -e "tail -s 0.05 -f %s --pid=%d"' %(fenName,self.tmpFile,pid)], shell=True)
|
|
|
|
return()
|
|
|
|
|
|
|
|
def message(self, typ, message='', goOn=False):
|
|
|
|
fileName=self.tmpFile
|
|
|
|
f = open(fileName,'a')
|
|
|
|
if typ=='E':
|
|
|
|
f.write('ERROR: '+message+'\n')
|
|
|
|
#print 'ERROR: '+message
|
|
|
|
if not goOn:
|
|
|
|
exit()
|
|
|
|
|
|
|
|
elif typ in ['A','W']:
|
|
|
|
#print ARNING: '+message
|
|
|
|
f.write('WARNING: '+message+'\n')
|
|
|
|
|
|
|
|
elif typ in ['M','I']:
|
|
|
|
#print 'INFO: '+message
|
|
|
|
f.write(message+'\n')
|
|
|
|
|
|
|
|
f.close()
|