X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=bin%2Fappliskel%2Fkill_remote_containers.py;h=39bb933976f004645b663e86d822f26d67274840;hb=3f048e2513c4a1053a84a98ebd708921c831fa23;hp=82f750e462fff199ebe79c60fd1b0039be7c59fe;hpb=9a965a48d4bc1a6cd1f73229a91e77b10bffa881;p=modules%2Fkernel.git diff --git a/bin/appliskel/kill_remote_containers.py b/bin/appliskel/kill_remote_containers.py index 82f750e46..39bb93397 100755 --- a/bin/appliskel/kill_remote_containers.py +++ b/bin/appliskel/kill_remote_containers.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -25,13 +25,14 @@ """ """ import sys,os,shutil,glob,socket -import optparse +import argparse +from salome_utils import getUserName import getAppliPath appli_local=os.path.realpath(os.path.dirname(__file__)) APPLI=getAppliPath.relpath(appli_local,os.path.realpath(os.getenv('HOME'))) -usage="""usage: %prog [options] +usage="""%(prog)s [options] This procedure kill all containers that have been launched in a SALOME session on remote machines. A SALOME session is identified by a machine name and a port number. @@ -90,7 +91,7 @@ class Resource: def get_user(self): userName= self.node.get("userName") if not userName: - userName=os.getenv('USER') + userName=getUserName() return userName def get_host(self): @@ -109,15 +110,14 @@ class Resource: return appliPath def main(): - parser = optparse.OptionParser(usage=usage) - parser.add_option('-p','--port', dest="port", - help="The SALOME session port (default NSPORT or 2810)") + parser = argparse.ArgumentParser(usage=usage) + parser.add_argument('-p','--port', dest="port", + help="The SALOME session port (default NSPORT or 2810)") - - options, args = parser.parse_args() + args = parser.parse_args() if not os.path.exists(catalog_file): - print "ERROR: the catalog file %s is mandatory" % catalog_file_base + print("ERROR: the catalog file %s is mandatory" % catalog_file) sys.exit(1) #Parse CatalogResource.xml @@ -141,13 +141,14 @@ def main(): if resource.get_host() in local_names:continue command=resource.get_rsh() +" -l "+resource.get_user()+" "+resource.get_host() command=command+ " " + os.path.join(resource.get_appliPath(),"runRemote.sh") - if options.port: - port=options.port + if args.port: + port=args.port else: port=os.getenv("NSPORT") or "2810" command=command+ " " + get_hostname() + " " + port +" killSalomeWithPort.py " + port - print command - os.system(command) + print(command) + return subprocess.call(command, shell=True) + if __name__ == '__main__': main()