From f8d59ad69ef3e2b294ae387d467663339adf3189 Mon Sep 17 00:00:00 2001 From: Bernard Secher Date: Tue, 26 Mar 2019 16:45:34 +0100 Subject: [PATCH] last modif after tests --- .../salome_tester/salome_instance.py | 9 +++-- bin/runSalome.py | 34 ++++++++++++++++- bin/runSession.py | 12 +++++- src/NamingService/SALOME_NamingServicePy.py | 37 +++++++++++++++++++ 4 files changed, 86 insertions(+), 6 deletions(-) diff --git a/bin/appliskel/salome_tester/salome_instance.py b/bin/appliskel/salome_tester/salome_instance.py index 36c5aee8d..867fe8ed9 100755 --- a/bin/appliskel/salome_tester/salome_instance.py +++ b/bin/appliskel/salome_tester/salome_instance.py @@ -49,10 +49,13 @@ class SalomeInstance(object): salome_instance = SalomeInstance() salome_instance.__run(args=instance_args, with_gui=with_gui) - with open(port_log) as f: - salome_instance.port = int(f.readline()) + try: + with open(port_log) as f: + salome_instance.port = int(f.readline()) + os.remove(port_log) + except: + pass - os.remove(port_log) return salome_instance # diff --git a/bin/runSalome.py b/bin/runSalome.py index 11a17d24e..e51e08cb2 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -144,7 +144,15 @@ class CatalogServer(Server): def __init__(self,args): self.args=args self.initArgs() - self.SCMD1=['SALOME_ModuleCatalog_Server','-common'] + self.SCMD1=['SALOME_ModuleCatalog_Server'] + if 'launcher' in self.args: + pos = args['launcher'].find(":") + if pos != -1: + self.SCMD1+=['-ORBInitRef'] + machine = args['launcher'][0:pos] + port = args['launcher'][pos+1:] + self.SCMD1+=["NameService=corbaname::" + machine + ":" + port] + self.SCMD1+=['-common'] self.SCMD2=[] home_dir=os.getenv('HOME') if home_dir is not None: @@ -169,6 +177,13 @@ class SalomeDSServer(Server): self.args=args self.initArgs() self.CMD=['SALOMEDS_Server'] + if 'launcher' in self.args: + pos = args['launcher'].find(":") + if pos != -1: + self.CMD+=['-ORBInitRef'] + machine = args['launcher'][0:pos] + port = args['launcher'][pos+1:] + self.CMD+=["NameService=corbaname::" + machine + ":" + port] # --- @@ -193,6 +208,13 @@ class RegistryServer(Server): self.args=args self.initArgs() self.CMD=['SALOME_Registry_Server', '--salome_session','theSession'] + if 'launcher' in self.args: + pos = args['launcher'].find(":") + if pos != -1: + self.CMD+=['-ORBInitRef'] + machine = args['launcher'][0:pos] + port = args['launcher'][pos+1:] + self.CMD+=["NameService=corbaname::" + machine + ":" + port] # --- @@ -200,7 +222,15 @@ class ContainerCPPServer(Server): def __init__(self,args,with_gui=False): self.args=args self.initArgs() - self.CMD=['SALOME_Container','FactoryServer'] + self.CMD=['SALOME_Container'] + if 'launcher' in self.args: + pos = args['launcher'].find(":") + if pos != -1: + self.CMD+=['-ORBInitRef'] + machine = args['launcher'][0:pos] + port = args['launcher'][pos+1:] + self.CMD+=["NameService=corbaname::" + machine + ":" + port] + self.CMD+=['FactoryServer'] if not with_gui and self.args["valgrind_session"]: l = ["valgrind"] val = os.getenv("VALGRIND_OPTIONS") diff --git a/bin/runSession.py b/bin/runSession.py index 305fda70f..fde468001 100644 --- a/bin/runSession.py +++ b/bin/runSession.py @@ -118,6 +118,10 @@ User "myself" connects to remotemachine to run the script concatenate.py in help="[Remote mode] The user on the computer to connect to." ) + parser.add_option('-l', '--launcher', dest="launcher", default=None, + help="[Remote mode] The machine and the port to connect to." + ) + short_args, extra_args = getShortAndExtraArgs(args) try: (options, args) = parser.parse_args(short_args) @@ -127,6 +131,12 @@ User "myself" connects to remotemachine to run the script concatenate.py in port = options.port host = options.host + launcher = options.launcher + if launcher is not None: + pos = launcher.find(":") + if pos != -1: + host = launcher[0:pos] + port = launcher[pos+1:] # :GLITCH: this code defines specific environment variables (OMNIORB_CONFIG, NSPORT, # NSHOST) which are later used by other modules. Working, but not really "safe"... @@ -162,7 +172,7 @@ User "myself" connects to remotemachine to run the script concatenate.py in # determine running mode, that is either 'local' or 'remote' here = getShortHostName() mode = "local" - if host != here and host != "localhost" and host != "no_host": + if host != here and host != "localhost" and host != "no_host" and launcher is None: mode="remote" pass params = SessionParameters(mode, port, host, options.user, options.directory) diff --git a/src/NamingService/SALOME_NamingServicePy.py b/src/NamingService/SALOME_NamingServicePy.py index 342c93716..8fdde096b 100644 --- a/src/NamingService/SALOME_NamingServicePy.py +++ b/src/NamingService/SALOME_NamingServicePy.py @@ -190,6 +190,43 @@ class SALOME_NamingServicePy_i(object): self._obj = None return self._obj + #------------------------------------------------------------------------- + + def Resolve_Dir(self, Path): + """ ns.Resolve_Dir(pathname) -> dir + + find a CORBA object (ior) by its pathname + """ + #MESSAGE ( "SALOME_NamingServicePy_i::Resolve" ) + path_list = list(Path) + if path_list[0]=='/': + self._current_context = self._root_context + #delete first '/' before split + Path=Path[1:] + + result_resolve_path = Path.split('/') + _context_name=[] + for i in range(len(result_resolve_path)-1): + _context_name.append(CosNaming.NameComponent(result_resolve_path[i],"dir")) + _context_name.append(CosNaming.NameComponent(result_resolve_path[len(result_resolve_path)-1],"dir")) + print(_context_name) + return None + try: + self._obj = self._current_context.resolve(_context_name) + except CosNaming.NamingContext.NotFound as ex: + MESSAGE ( "Resolve : CosNaming.NamingContext.NotFound" ) + self._obj = None + except CosNaming.NamingContext.InvalidName as ex: + MESSAGE ( "Resolve : CosNaming.NamingContext.InvalidName" ) + self._obj = None + except CosNaming.NamingContext.CannotProceed as ex: + MESSAGE ( "Resolve : CosNaming.NamingContext.CannotProceed" ) + self._obj = None + except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): + MESSAGE ( "Resolve : CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE" ) + self._obj = None + return self._obj + #------------------------------------------------------------------------- -- 2.39.2