From 38188baef629628d7c3a15b60c1f114a169cfb73 Mon Sep 17 00:00:00 2001 From: abd Date: Fri, 29 Jun 2007 12:48:01 +0000 Subject: [PATCH] Potring to Win32 Platform --- bin/killSalome.py | 27 +++++++++++++------------ bin/runSalome.py | 50 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 52 insertions(+), 25 deletions(-) diff --git a/bin/killSalome.py b/bin/killSalome.py index 9e65ae4ce..2f1388182 100755 --- a/bin/killSalome.py +++ b/bin/killSalome.py @@ -33,20 +33,21 @@ def killAllPorts(): killMyPort(mo.groups()[0]) pass - cmd = "pid=`ps -fea | grep '"+os.getenv('USER')+"' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'` ; echo $pid > /tmp/logs/"+os.getenv('USER')+"/_"+"Pid_ghs3d.log" - a = os.system(cmd) - try: - fpidomniNames=open('/tmp/logs/'+os.getenv('USER')+"/_"+"Pid_ghs3d.log") - prc = fpidomniNames.read() - fpidomniNames.close() - if prc != None : - for field in prc.split(" ") : - field = field.strip() - if field != None and len(field) != 0: - os.system('kill -9 '+field) - except: + if not sys.platform == 'win32': + cmd = "pid=`ps -fea | grep '"+os.getenv('USER')+"' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'` ; echo $pid > /tmp/logs/"+os.getenv('USER')+"/_"+"Pid_ghs3d.log" + a = os.system(cmd) + try: + fpidomniNames=open('/tmp/logs/'+os.getenv('USER')+"/_"+"Pid_ghs3d.log") + prc = fpidomniNames.read() + fpidomniNames.close() + if prc != None : + for field in prc.split(" ") : + field = field.strip() + if field != None and len(field) != 0: + os.system('kill -9 '+field) + except: + pass pass - pass if __name__ == "__main__": killAllPorts() diff --git a/bin/runSalome.py b/bin/runSalome.py index 69f974aff..27d2799af 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -702,24 +702,46 @@ def searchFreePort(args, save_config=1): limit=limit+10 while 1: import os - status = os.system("netstat -ltn | grep -E :%s > /dev/null 2>&1"%(NSPORT)) - if status: + import re + from os import getpid + from os import system + + if sys.platform == "win32": + tmp_file = os.getenv('TEMP'); + else: + tmp_file = '/tmp/' + tmp_file += 'hostname_%s'%(getpid()) + +# status = os.system("netstat -ltn | grep -E :%s > /dev/null 2>&1"%(NSPORT)) + + system( "netstat -a -n > %s" % tmp_file ); + + f = open( tmp_file, 'r' ); + lines = f.readlines(); + f.close(); + + pattern = "tcp.*:([0-9]+).*:.*listen"; + regObj = re.compile( pattern, re.IGNORECASE ); + + status = 1; + for item in lines: + m = regObj.search( item ) + if m and m.group(1) == NSPORT : + status = 0; + break; + + if status == 1: print "%s - OK"%(NSPORT) # - from os import getpid - if sys.platform == "win32": - tmp_file = os.getenv('TEMP'); - else: - tmp_file = '/tmp/' - tmp_file += 'hostname_%s'%(getpid()) - #tmp_file = '/tmp/hostname_%s'%(getpid()) - from os import system system('hostname > %s'%(tmp_file)) f = open(tmp_file) myhost = f.read() myhost = myhost[:-1] f.close() - system('rm -f %s'%(tmp_file)) + +# system('rm -f %s'%(tmp_file)) + os.remove( tmp_file ); + # home = os.environ['HOME'] appli=os.environ.get("APPLI") @@ -742,8 +764,12 @@ def searchFreePort(args, save_config=1): args['port'] = os.environ['NSPORT'] # if save_config: + import shutil from os import system - system('ln -sf %s %s/.omniORB_last.cfg'%(os.environ['OMNIORB_CONFIG'], home)) + +# system('ln -s -f %s %s/.omniORB_last.cfg'%(os.environ['OMNIORB_CONFIG'], home)) + shutil.copyfile( os.environ['OMNIORB_CONFIG'], "%s/.omniORB_last.cfg"%( home ) ); + pass # break -- 2.39.2