]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Merge remote-tracking branch 'origin/V8_3_BR' into ngr/python3_dev
authorGilles DAVID <gilles-g.david@edf.fr>
Tue, 18 Apr 2017 13:21:29 +0000 (15:21 +0200)
committerGilles DAVID <gilles-g.david@edf.fr>
Tue, 18 Apr 2017 13:21:29 +0000 (15:21 +0200)
Conflicts:
bin/appliskel/salome_starter.py
bin/appliskel/salome_tester/salome_test_driver.py
bin/appliskel/salome_tester/salome_test_driver_gui.py
bin/salomeContext.py

1  2 
bin/PortManager.py
bin/appliskel/salome_starter.py
bin/appliskel/salome_tester/salome_test_driver.py
bin/appliskel/salome_tester/salome_test_driver_gui.py
bin/killSalomeWithPort.py
bin/runConsole.py
bin/runTests.py
bin/salomeContext.py
bin/salomeContextUtils.py.in

index c23c28d51348342dd9b38adde8e334781b448ebd,ced2ad296a56f28f7c2f388c0e63bb196362eaea..f838a2ddf080c03a7d9185f8c625c0121970aa86
@@@ -132,10 -142,10 +142,10 @@@ def getPort(preferedPort=None)
      __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
@@@ -189,27 -201,29 +201,29 @@@ def releasePort(port)
      __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
@@@ -231,10 -244,10 +244,10 @@@ def getBusyPorts()
      __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
index 97f355e6bb3717aee25285aef382ec67cf42990a,795803d408da1eae96165d06d999acdb554565a8..737b4c15d1a837bdeca62fa4d9da9634499ee4a4
@@@ -53,8 -53,8 +53,8 @@@ def initialize(launcherPath, launcherFi
    appliPath = __detectAppliPath(launcherPath, launcherFile)
  
    if appliPath is None:
 -    print "ERROR: Unable to find application folder"
 +    print("ERROR: Unable to find application folder")
-     sys.exit(0)
+     sys.exit(1)
  
    appliPath = os.path.relpath(appliPath, homePath)
    absoluteAppliPath = os.path.join(homePath, appliPath)
index e4dbcd157c70f281e3ebf7ecebd8c7489411584e,7b119d1765804d61475874548adc55737d26d484..7eae0869328a59c4b922d126de8564353c08b988
@@@ -67,8 -53,8 +67,8 @@@ if __name__ == "__main__"
    # Add explicit call to python executable if a Python script is passed as
    # first argument
    if not args:
 -    print "Invalid arguments for salome_test_driver.py. No command defined."
 +    print("Invalid arguments for salome_test_driver.py. No command defined.")
-     exit(1)
+     sys.exit(1)
    _, ext = os.path.splitext(args[0])
    if ext == ".py":
      test_and_args = [sys.executable] + args
      import traceback
      traceback.print_exc()
      pass
-   salome_instance.stop()
+   try:
+     salome_instance.stop()
+   except:
+     pass
    if sys.platform == 'win32':
      timer.cancel()
 -  print "Exit test with status code:", res
 +  print("Exit test with status code:", res)
-   exit(res)
+   sys.exit(res)
  #
index c6d8566515fb9ccdcb544393165e255b0ad3dd6b,7ef53d33f7b3ee45baf77ac2a1b4d8c4daf019ec..92a19d6b3bfe0b34a9953d0bc1136ec528f4670a
@@@ -41,8 -41,8 +41,8 @@@ if __name__ == "__main__"
    # Add explicit call to python executable if a Python script is passed as
    # first argument
    if not args:
 -    print "Invalid arguments for salome_test_driver_gui.py. No command defined."
 +    print("Invalid arguments for salome_test_driver_gui.py. No command defined.")
-     exit(1)
+     sys.exit(1)
    _, ext = os.path.splitext(args[0])
    test_and_args = args
  
      import traceback
      traceback.print_exc()
      pass
-   salome_instance.stop()
+   try:
+     salome_instance.stop()
+   except:
+     pass
    if sys.platform == 'win32':
      timer.cancel()
 -#  print "Exit test with status code:", res
 +#  print("Exit test with status code:", res)
- #  exit(res)
+ #  sys.exit(res)
  #
Simple merge
Simple merge
diff --cc bin/runTests.py
Simple merge
index e23aef7d6941f9d0f8d76f748c23c1c38c8261ba,2e63384f26fc032e2fb6ee6ffb3fe2687f0c588f..4f31c584f726445e600e30b5d9b599fd1ade3f15
@@@ -224,7 -222,7 +224,7 @@@ class SalomeContext
        '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:
@@@ -473,9 -471,20 +473,20 @@@ Available options are
      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()
  #
Simple merge