__acquire_lock(lock)
# read config
- config = {'busy_ports':[]}
+ config = {}
logger.debug("read configuration file")
try:
- with open(config_file, 'r') as f:
+ with open(config_file, 'rb') as f:
config = pickle.load(f)
except:
logger.info("Problem loading PortManager file: %s"%config_file)
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
+ raise RuntimeError(msg)
logger.debug("Port %s seems to be busy"%str(port))
- if not port in config["busy_ports"]:
- config["busy_ports"].append(port)
port = port + 1
logger.debug("found free port: %s"%str(port))
- config["busy_ports"].append(port)
+ config[appli_path].append(port)
# write config
- logger.debug("write busy_ports: %s"%str(config["busy_ports"]))
+ logger.debug("write config: %s"%str(config))
try:
- with open(config_file, 'w') as f:
+ with open(config_file, 'wb') as f:
pickle.dump(config, f)
except IOError:
pass
__acquire_lock(lock)
# read config
- config = {'busy_ports':[]}
+ config = {}
logger.debug("read configuration file")
try:
- with open(config_file, 'r') as f:
+ with open(config_file, 'rb') as f:
config = pickle.load(f)
except IOError: # empty file
pass
- logger.debug("load busy_ports: %s"%str(config["busy_ports"]))
+ logger.debug("load config: %s"%str(config))
+ appli_path = os.getenv("ABSOLUTE_APPLI_PATH", "unknown")
+ try:
+ config[appli_path]
+ except KeyError:
+ config[appli_path] = []
# remove port from list
- busy_ports = config["busy_ports"]
-
- if port in busy_ports:
- busy_ports.remove(port)
- config["busy_ports"] = busy_ports
+ ports_info = config[appli_path]
+ config[appli_path] = [x for x in ports_info if x != port]
# write config
- logger.debug("write busy_ports: %s"%str(config["busy_ports"]))
+ logger.debug("write config: %s"%str(config))
try:
- with open(config_file, 'w') as f:
+ with open(config_file, 'wb') as f:
pickle.dump(config, f)
except IOError:
pass
__acquire_lock(lock)
# read config
- config = {'busy_ports':[]}
+ config = {}
logger.debug("read configuration file")
try:
- with open(config_file, 'r') as f:
+ with open(config_file, 'rb') as f:
config = pickle.load(f)
except IOError: # empty file
pass
'car' : '_getCar',
}
- if not command in list(availableCommands.keys()):
- if not command in availableCommands.keys():
++ if command not in availableCommands:
command = "start"
options = args
try:
res = getattr(self, command)(options) # run appropriate method
return res or (None, None)
- except SystemExit, returncode:
+ except SystemExit as returncode:
if returncode != 0:
- self.getLogger().error("SystemExit %s in method %s.", returncode, command)
+ self.getLogger().warning("SystemExit %s in method %s.", returncode, command)
- sys.exit(returncode)
+ return returncode
- except StandardError:
++ except SalomeContextException as e:
++ self.getLogger().error(e)
++ return 1
+ except Exception:
self.getLogger().error("Unexpected error:")
import traceback
traceback.print_exc()
- sys.exit(1)
- except SalomeContextException as e:
- self.getLogger().error(e)
- sys.exit(1)
+ return 1
- except SalomeContextException, e:
- self.getLogger().error(e)
- return 1
#
def __setContextFromConfigFile(self, filename, reserved=None):
reserved = []
try:
unsetVars, configVars, reservedDict = parseConfigFile(filename, reserved)
- except SalomeContextException, e:
+ except SalomeContextException as e:
msg = "%s"%e
self.getLogger().error(msg)
- sys.exit(1)
+ return 1
# unset variables
for var in unsetVars:
if "-p" in args or "--ports" in args:
import PortManager
ports = PortManager.getBusyPorts()
- print("SALOME instances are running on ports:", ports)
- if ports:
- print("Last started instance on port %s"%ports[-1])
+ this_ports = ports['this']
+ other_ports = ports['other']
+ if this_ports or other_ports:
- print "SALOME instances are running on the following ports:"
++ print("SALOME instances are running on the following ports:")
+ if this_ports:
- print " This application:", this_ports
++ print(" This application:", this_ports)
+ else:
- print " No SALOME instances of this application"
++ print(" No SALOME instances of this application")
+ if other_ports:
- print " Other applications:", other_ports
++ print(" Other applications:", other_ports)
+ else:
- print " No SALOME instances of other applications"
++ print(" No SALOME instances of other applications")
+ else:
- print "No SALOME instances are running"
++ print("No SALOME instances are running")
if "-s" in args or "--softwares" in args:
if "-s" in args:
#
def _makeCoffee(self, unused=None):
- print " ("
- print " ) ("
- print " ___...(-------)-....___"
- print " .-\"\" ) ( \"\"-."
- print " .-\'``\'|-._ ) _.-|"
- print " / .--.| `\"\"---...........---\"\"` |"
- print " / / | |"
- print " | | | |"
- print " \\ \\ | |"
- print " `\\ `\\ | |"
- print " `\\ `| SALOME |"
- print " _/ /\\ 4 EVER /"
- print " (__/ \\ <3 /"
- print " _..---\"\"` \\ /`\"\"---.._"
- print " .-\' \\ / \'-."
- print " : `-.__ __.-\' :"
- print " : ) \"\"---...---\"\" ( :"
- print " \'._ `\"--...___...--\"` _.\'"
- print " \\\"\"--..__ __..--\"\"/"
- print " \'._ \"\"\"----.....______.....----\"\"\" _.\'"
- print " `\"\"--..,,_____ _____,,..--\"\"`"
- print " `\"\"\"----\"\"\"`"
- print ""
- print " SALOME is working for you; what else?"
- print ""
+ print(" (")
+ print(" ) (")
+ print(" ___...(-------)-....___")
+ print(" .-\"\" ) ( \"\"-.")
+ print(" .-\'``\'|-._ ) _.-|")
+ print(" / .--.| `\"\"---...........---\"\"` |")
+ print(" / / | |")
+ print(" | | | |")
+ print(" \\ \\ | |")
+ print(" `\\ `\\ | |")
+ print(" `\\ `| SALOME |")
+ print(" _/ /\\ 4 EVER /")
+ print(" (__/ \\ <3 /")
+ print(" _..---\"\"` \\ /`\"\"---.._")
+ print(" .-\' \\ / \'-.")
+ print(" : `-.__ __.-\' :")
+ print(" : ) \"\"---...---\"\" ( :")
+ print(" \'._ `\"--...___...--\"` _.\'")
+ print(" \\\"\"--..__ __..--\"\"/")
+ print(" \'._ \"\"\"----.....______.....----\"\"\" _.\'")
+ print(" `\"\"--..,,_____ _____,,..--\"\"`")
+ print(" `\"\"\"----\"\"\"`")
+ print("")
+ print(" SALOME is working for you; what else?")
+ print("")
- sys.exit(0)
#
def _getCar(self, unused=None):
- print " _____________"
- print " ..---:::::::-----------. ::::;;."
- print " .\'\"\"\"\"\"\" ;; \\ \":."
- print " .\'\' ; \\ \"\\__."
- print " .\' ;; ; \\\\\";"
- print " .\' ; _____; \\\\/"
- print " .\' :; ;\" \\ ___:\'."
- print " .\'--........................... : = ____:\" \\ \\"
- print " ..-\"\" \"\"\"\' o\"\"\" ; ; :"
- print " .--\"\" .----- ..----... _.- --. ..-\" ; ; ; ;"
- print " .\"\"_- \"--\"\"-----\'\"\" _-\" .-\"\" ; ; .-."
- print " .\' .\' SALOME .\" .\" ; ; /. |"
- print " /-./\' 4 EVER <3 .\" / _.. ; ; ;;;|"
- print " : ;-.______ / _________==. /_ \\ ; ; ;;;;"
- print " ; / | \"\"\"\"\"\"\"\"\"\"\".---.\"\"\"\"\"\"\" : /\" \". |; ; _; ;;;"
- print " /\"-/ | / / / / ;|; ;-\" | ;\';"
- print ":- : \"\"\"----______ / / ____. . .\"\'. ;; .-\"..T\" ."
- print "\'. \" ___ \"\": \'\"\"\"\"\"\"\"\"\"\"\"\"\"\" . ; ; ;; ;.\" .\" \'--\""
- print " \", __ \"\"\" \"\"---... :- - - - - - - - - \' \' ; ; ; ;;\" .\""
- print " /. ; \"\"\"---___ ; ; ; ;|.\"\""
- print " : \": \"\"\"----. .-------. ; ; ; ;:"
- print " \\ \'--__ \\ \\ \\ / | ; ;;"
- print " \'-.. \"\"\"\"---___ : .______..\\ __/..-\"\"| ; ; ;"
- print " \"\"--.. \"\"\"--\" m l s . \". . ;"
- print " \"\"------... ..--\"\" \" :"
- print " \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" \\ /"
- print " \"------\""
- print ""
- print " Drive your simulation properly with SALOME!"
- print ""
+ print(" _____________")
+ print(" ..---:::::::-----------. ::::;;.")
+ print(" .\'\"\"\"\"\"\" ;; \\ \":.")
+ print(" .\'\' ; \\ \"\\__.")
+ print(" .\' ;; ; \\\\\";")
+ print(" .\' ; _____; \\\\/")
+ print(" .\' :; ;\" \\ ___:\'.")
+ print(" .\'--........................... : = ____:\" \\ \\")
+ print(" ..-\"\" \"\"\"\' o\"\"\" ; ; :")
+ print(" .--\"\" .----- ..----... _.- --. ..-\" ; ; ; ;")
+ print(" .\"\"_- \"--\"\"-----\'\"\" _-\" .-\"\" ; ; .-.")
+ print(" .\' .\' SALOME .\" .\" ; ; /. |")
+ print(" /-./\' 4 EVER <3 .\" / _.. ; ; ;;;|")
+ print(" : ;-.______ / _________==. /_ \\ ; ; ;;;;")
+ print(" ; / | \"\"\"\"\"\"\"\"\"\"\".---.\"\"\"\"\"\"\" : /\" \". |; ; _; ;;;")
+ print(" /\"-/ | / / / / ;|; ;-\" | ;\';")
+ print(":- : \"\"\"----______ / / ____. . .\"\'. ;; .-\"..T\" .")
+ print("\'. \" ___ \"\": \'\"\"\"\"\"\"\"\"\"\"\"\"\"\" . ; ; ;; ;.\" .\" \'--\"")
+ print(" \", __ \"\"\" \"\"---... :- - - - - - - - - \' \' ; ; ; ;;\" .\"")
+ print(" /. ; \"\"\"---___ ; ; ; ;|.\"\"")
+ print(" : \": \"\"\"----. .-------. ; ; ; ;:")
+ print(" \\ \'--__ \\ \\ \\ / | ; ;;")
+ print(" \'-.. \"\"\"\"---___ : .______..\\ __/..-\"\"| ; ; ;")
+ print(" \"\"--.. \"\"\"--\" m l s . \". . ;")
+ print(" \"\"------... ..--\"\" \" :")
+ print(" \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" \\ /")
+ print(" \"------\"")
+ print("")
+ print(" Drive your simulation properly with SALOME!")
+ print("")
- sys.exit(0)
#
# Add the following two methods since logger is not pickable
if __name__ == "__main__":
if len(sys.argv) == 3:
- context = sys.argv[1]
- args = sys.argv[2]
-
- context = pickle.loads(context.encode())
- args = pickle.loads(args.encode())
- context = pickle.loads(sys.argv[1])
- args = pickle.loads(sys.argv[2])
++ context = pickle.loads(sys.argv[1].encode())
++ args = pickle.loads(sys.argv[2].encode())
- (out, err) = context._startSalome(args)
- if out:
- sys.stdout.write(out)
- if err:
- sys.stderr.write(err)
+ context._startSalome(args)
else:
usage()
#