]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Potring to Win32 Platform
authorabd <abd@opencascade.com>
Fri, 29 Jun 2007 12:48:01 +0000 (12:48 +0000)
committerabd <abd@opencascade.com>
Fri, 29 Jun 2007 12:48:01 +0000 (12:48 +0000)
bin/killSalome.py
bin/runSalome.py

index 9e65ae4cebbe62db53211068127eda70ec3e09de..2f1388182f522ed10621b47b36a38173a3d5359e 100755 (executable)
@@ -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()
index 69f974aff69b9de766694a7b01ac6c6cf9237e8d..27d2799afa2b78f833ccec7b5556547953f831da 100755 (executable)
@@ -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