From 2c5ca50f569bd59333028fe4db3bfe2dee882802 Mon Sep 17 00:00:00 2001 From: rnv Date: Fri, 12 May 2017 10:52:55 +0300 Subject: [PATCH] Execute SALOME w/o network. --- bin/nameserver.py | 11 +++-------- bin/runSession.py | 6 +++--- bin/salome_utils.py | 6 +++++- src/Utils/Utils_Identity.cxx | 2 ++ 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/bin/nameserver.py b/bin/nameserver.py index f9d1a3a2c..5e6c772ac 100755 --- a/bin/nameserver.py +++ b/bin/nameserver.py @@ -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()) diff --git a/bin/runSession.py b/bin/runSession.py index c83ef01a1..e06150138 100644 --- a/bin/runSession.py +++ b/bin/runSession.py @@ -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" diff --git a/bin/salome_utils.py b/bin/salome_utils.py index 52a73fdd0..4f4936f97 100644 --- a/bin/salome_utils.py +++ b/bin/salome_utils.py @@ -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 # --- diff --git a/src/Utils/Utils_Identity.cxx b/src/Utils/Utils_Identity.cxx index f989b62f6..04c2290c5 100644 --- a/src/Utils/Utils_Identity.cxx +++ b/src/Utils/Utils_Identity.cxx @@ -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)); -- 2.39.2