]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
discard changes related to PortManager (development moved to branch agr_portmanager_b...
authoraguerre <aguerre>
Fri, 4 Oct 2013 16:02:47 +0000 (16:02 +0000)
committeraguerre <aguerre>
Fri, 4 Oct 2013 16:02:47 +0000 (16:02 +0000)
bin/CMakeLists.txt
bin/appliskel/tests/CMakeLists.txt
bin/killSalomeWithPort.py
bin/launchConfigureParser.py
bin/searchFreePort.py
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx

index 07ef256a4123270d0ff4525fc8b0d8a5ba700086..a562f96f8fe3032c9568e09478c6ea9af8d00f58 100755 (executable)
@@ -43,7 +43,6 @@ SET(SCRIPTS
   orbmodule.py
   ORBConfigFile.py
   parseConfigFile.py
-  PortManager.py
   runSalome
   runSalome.py
   runSession.py
@@ -58,7 +57,6 @@ SET(SCRIPTS
   setenv.py
   showNS.py
   shutdownSalome.py
-  Singleton.py
   virtual_salome.py
   waitContainers.py
   waitNS.py
index 41af658e259e108d301ceb462ad5a53e83de5764..2e50e0ea9eaa4ce7e09fb20b128ba7b151dccd29 100644 (file)
@@ -17,5 +17,5 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-ADD_SUBDIRECTORY(concurrentSession)
+#ADD_SUBDIRECTORY(concurrentSession)
 ADD_SUBDIRECTORY(launcher)
index 2e2bf65c874c9410b6950e3b008bf315a5a84698..84774cef326c011c1713c1d34f3e1a1c2c56c27b 100755 (executable)
@@ -141,9 +141,6 @@ def shutdownMyPort(port, cleanup=True):
     """
     if not port: return
 
-    from PortManager import releasePort
-    releasePort(port)
-
     from salome_utils import generateFileName
 
     # set OMNIORB_CONFIG variable to the proper file
@@ -189,9 +186,6 @@ def killMyPort(port):
     Parameters:
     - port - port number
     """
-    import PortManager
-    PortManager.releasePort(port)
-
     from salome_utils import getShortHostName, getHostName
 
     # try to shutdown session nomally
index 7937325cd980116168b0189e33dfa57aace8e983..d89e2d1df708716bdb69e7845adc234b567e0eac 100755 (executable)
@@ -881,8 +881,6 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam
         from searchFreePort import searchFreePort
         searchFreePort({})
         print "port:%s"%(os.environ['NSPORT'])
-        import PortManager
-        PortManager.releasePort(os.environ['NSPORT'])
         sys.exit(0)
         pass
 
index bda4863c023384154cd89ec259697d4b4eb93498..07540095d5289eda6b396edc0a7e87ae36ff661c 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-import os
-import sys
-
-def __setup_config(nsport, args, save_config):
-  #
-  from salome_utils import generateFileName, getHostName
-  hostname = getHostName()
-  #
-  omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
-  kwargs={}
-  if omniorbUserPath is not None:
-    kwargs["with_username"]=True
-  #
-  from ORBConfigFile import writeORBConfigFile
-  omniorb_config, giopsize = writeORBConfigFile(omniorbUserPath, hostname, nsport, kwargs)
-  args['port'] = os.environ['NSPORT']
-  #
-  if save_config:
-    last_running_config = generateFileName(omniorbUserPath, prefix="omniORB",
-                                           suffix="last",
-                                           extension="cfg",
-                                           hidden=True,
-                                           **kwargs)
-    #os.environ['LAST_RUNNING_CONFIG'] = last_running_config
-    try:
-      if sys.platform == "win32":
-        import shutil
-        shutil.copyfile(omniorb_config, last_running_config)
-      else:
-        try:
-          if os.access(last_running_config, os.F_OK):
-            os.remove(last_running_config)
-        except OSError:
-          pass
-        os.symlink(omniorb_config, last_running_config)
-        pass
-      pass
-    except:
-      pass
-  #
-#
-
 def searchFreePort(args={}, save_config=1, use_port=None):
   """
   Search free port for SALOME session.
   Returns first found free port number.
   """
+  import sys, os, re, shutil
+
+  # :NOTE: Under windows:
+  #        netstat options -l and -t are unavailable
+  #        grep command is unavailable
+
+  from subprocess import Popen, PIPE
+  (stdout, stderr) = Popen(['netstat','-an'], stdout=PIPE).communicate()
+  import StringIO
+  buf = StringIO.StringIO(stdout)
+  ports = buf.readlines()
+
+  #
+  def portIsUsed(port, data):
+    regObj = re.compile( ".*tcp.*:([0-9]+).*:.*listen", re.IGNORECASE );
+    for item in data:
+      try:
+        p = int(regObj.match(item).group(1))
+        if p == port: return True
+        pass
+      except:
+        pass
+      pass
+    return False
+  #
 
-  from PortManager import getPort
-  port = getPort(use_port)
+  def setup_config(nsport):
+      #
+      from salome_utils import generateFileName, getHostName
+      hostname = getHostName()
+      #
+      omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
+      kwargs={}
+      if omniorbUserPath is not None:
+        kwargs["with_username"]=True
+      #
+      from ORBConfigFile import writeORBConfigFile
+      omniorb_config, giopsize = writeORBConfigFile(omniorbUserPath, hostname, nsport, kwargs)
+      args['port'] = os.environ['NSPORT']
+      #
+      if save_config:
+        last_running_config = generateFileName(omniorbUserPath, prefix="omniORB",
+                                               suffix="last",
+                                               extension="cfg",
+                                               hidden=True,
+                                               **kwargs)
+        os.environ['LAST_RUNNING_CONFIG'] = last_running_config
+        try:
+          if sys.platform == "win32":
+            import shutil
+            shutil.copyfile(omniorb_config, last_running_config)
+          else:
+            try:
+              if os.access(last_running_config, os.F_OK):
+                os.remove(last_running_config)
+            except OSError:
+              pass
+            os.symlink(omniorb_config, last_running_config)
+            pass
+          pass
+        except:
+          pass
+      #
 
   if use_port:
     print "Check if port can be used: %d" % use_port,
-    if port == use_port and port != -1:
+    if not portIsUsed(use_port, ports):
       print "- OK"
-      __setup_config(use_port, args, save_config)
+      setup_config(use_port)
       return
     else:
       print "- KO: port is busy"
-      pass
+    pass
   #
+
   print "Searching for a free port for naming service:",
-  if port == -1: # try again
-    port = getPort(use_port)
+  #
 
-  if port != -1:
-    print "%s - OK"%(port)
-    __setup_config(port, args, save_config)
-  else:
-    print "Unable to obtain port"
-#
+  NSPORT=2810
+  limit=NSPORT+100
+  #
+
+  while 1:
+    if not portIsUsed(NSPORT, ports):
+      print "%s - OK"%(NSPORT)
+      setup_config(NSPORT)
+      break
+    print "%s"%(NSPORT),
+    if NSPORT == limit:
+      msg  = "\n"
+      msg += "Can't find a free port to launch omniNames\n"
+      msg += "Try to kill the running servers and then launch SALOME again.\n"
+      raise RuntimeError, msg
+    NSPORT=NSPORT+1
+    pass
+  #
+
+  return
index 80da816713c77a57a18d7704ff86d766da57b40f..3d525ae185babb7386bc11e437c07e4b0a3a077b 100644 (file)
@@ -620,16 +620,6 @@ void SALOME_LifeCycleCORBA::killOmniNames()
     MESSAGE(cmd);
     system( cmd.c_str() );
   }
-
-  // shutdown portmanager
-  if ( !portNumber.empty() )
-  {
-    std::string cmd = ("from PortManager import releasePort; ");
-    cmd += std::string("releasePort(") + portNumber + "); ";
-    cmd  = std::string("python -c \"") + cmd +"\" > /dev/null 2> /dev/null";
-    MESSAGE(cmd);
-    system( cmd.c_str() );
-  }
 }
 
 //=============================================================================