]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Merge branch 'rnv/local_execution'
authorrnv <rnv@opencascade.com>
Mon, 15 May 2017 09:00:01 +0000 (12:00 +0300)
committerrnv <rnv@opencascade.com>
Mon, 15 May 2017 09:00:01 +0000 (12:00 +0300)
bin/nameserver.py
bin/runSession.py
bin/salome_utils.py
src/Utils/Utils_Identity.cxx

index f9d1a3a2c6609fc6dfd643360a2aabef71aaa409..5e6c772acd41fd2b3f5b8ed08eaa23d53623c377 100755 (executable)
@@ -25,7 +25,7 @@
 import os, sys, re, socket
 #import commands
 from server import Server
-from Utils_Identity import getShortHostName
+from salome_utils import getShortHostName
 from launchConfigureParser import verbose
 
 # -----------------------------------------------------------------------------
@@ -46,13 +46,8 @@ class NamingServer(Server):
         except:
             pass
 
-        if verbose(): print "Name Service... ",
-        #hname=os.environ["HOST"] #commands.getoutput("hostname")
-        if sys.platform == "win32":
-          hname = getShortHostName();
-        else:
-          hname = socket.gethostname();
-        #print "hname=",hname
+        if verbose(): print "Name Service... "
+        hname = getShortHostName()
 
         with open(os.environ["OMNIORB_CONFIG"]) as f:
           ss = re.findall("NameService=corbaname::" + hname + ":\d+", f.read())
index c83ef01a1d4c7e3e3b18dd984d45e5338b90cb62..e06150138c4652ae3a0dc196398279837bf2aa55 100644 (file)
@@ -29,7 +29,7 @@ import socket
 import subprocess
 import re
 from salomeContextUtils import getScriptsAndArgs, formatScriptsAndArgs, getShortAndExtraArgs
-from salome_utils import getUserName
+from salome_utils import getUserName, getShortHostName
 
 # Use to display newlines (\n) in epilog
 class MyParser(OptionParser):
@@ -152,7 +152,7 @@ User "myself" connects to remotemachine to run the script concatenate.py in
   else:
     if not host:
       # only PORT is given
-      host = socket.gethostname()
+      host = getShortHostName()
     # both MACHINE and PORT are given
     _writeConfigFile(port, host)
   #
@@ -160,7 +160,7 @@ User "myself" connects to remotemachine to run the script concatenate.py in
   os.environ['NSHOST'] = host
 
   # determine running mode, taht is either 'local' or 'remote'
-  here = socket.gethostname()
+  here = getShortHostName()
   mode = "local"
   if host != here and host != "localhost" and host != "no_host":
     mode="remote"
index 52a73fdd058bbe114b4c2c150bd3f72b1914455e..4f4936f97cf96b99315d7783f9959ebe43a35fc5 100644 (file)
@@ -148,7 +148,6 @@ def getHostName():
     3. if fails, try HOST environment variable
     4. if fails, return 'unknown' as default host name
     """
-    import os
     try:
         import socket
         host = socket.gethostname()
@@ -158,6 +157,11 @@ def getHostName():
     if not host: host = os.getenv("HOSTNAME")
     if not host: host = os.getenv("HOST")
     if not host: host = "unknown"           # 'unknown' is default host name
+    try:
+        socket.gethostbyname(host)
+    except:
+        host = "localhost"
+    pass
     return host
 
 # ---
index f989b62f650a6bccaf8cf1953d8060c821593413..04c2290c50b02a1ff4c0abf737869abdf7a52308 100644 (file)
@@ -71,6 +71,8 @@ const char* get_adip( void )
 #endif
 
         const hostent* pour_adip=gethostbyname(hostid.nodename);
+       if(pour_adip  == NULL)
+         pour_adip=gethostbyname("localhost");
         ASSERT(pour_adip!=NULL);
         const in_addr ip_addr=*(struct in_addr*)(pour_adip->h_addr) ;
         return duplicate(inet_ntoa(ip_addr));