Salome HOME
SALOME master
authorCEA Support SALOME <support-salome@cea.fr>
Tue, 7 Jul 2015 07:03:01 +0000 (09:03 +0200)
committerCEA Support SALOME <support-salome@cea.fr>
Tue, 7 Jul 2015 07:03:01 +0000 (09:03 +0200)
CMakeLists.txt
resources/about.png
resources/app_logo.png
resources/splash.png
src/resources/LightApp_msg_en.ts
src/resources/LightApp_msg_fr.ts
src/resources/LightApp_msg_ja.ts
src/salomeContext.py
src/salomeContextUtils.py

index a01b77b55f6ee8020ffe779390b68d47b37817d6..ab6fa02e5e31ec7ced8eaee1cfa9d67dfccdd3f4 100644 (file)
@@ -69,7 +69,12 @@ SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
 IF(EXISTS ${GUI_ROOT_DIR})
   LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
   FIND_PACKAGE(SalomeGUI REQUIRED)
-  FULL_GUI(TRUE) # check whether GUI builded in full mode and with CORBA
+  SALOME_GUI_WITH_CORBA() #remove this line if you don't need GUI module builded with CORBA
+  #remove unnecessary options from this list (see SALOME_GUI_MODE() macro description)
+  SALOME_GUI_MODE(SALOME_USE_SALOMEOBJECT SALOME_USE_OCCVIEWER SALOME_USE_VTKVIEWER SALOME_USE_PYCONSOLE
+                  OPTIONAL SALOME_USE_PLOT2DVIEWER SALOME_USE_GLVIEWER SALOME_USE_GRAPHICSVIEW 
+                  SALOME_USE_QXGRAPHVIEWER SALOME_USE_PVVIEWER SALOME_USE_PYVIEWER
+                  )
   ADD_DEFINITIONS(${GUI_DEFINITIONS})
   INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})
 ELSE(EXISTS ${GUI_ROOT_DIR})
index dfdc7e618906cfabcfa9ce8b4ab44b4ab688ec31..df7481dcaa29ed021a5e39caf623596a8a45ef62 100644 (file)
Binary files a/resources/about.png and b/resources/about.png differ
index df849dcac3c920eb47d324d859058a30fe33c240..33971d224ee0b70bd212c2e5eeea6129bcf228da 100644 (file)
Binary files a/resources/app_logo.png and b/resources/app_logo.png differ
index dfdc7e618906cfabcfa9ce8b4ab44b4ab688ec31..df7481dcaa29ed021a5e39caf623596a8a45ef62 100644 (file)
Binary files a/resources/splash.png and b/resources/splash.png differ
index a1510fe3066b16b4ffcdcbb1073b5af13775fe90..c0733e3dbec35fdd3332a4b96ed8aaef08c1d6a5 100644 (file)
@@ -17,7 +17,7 @@
     </message>
     <message>
         <source>APP_VERSION</source>
-        <translation>V7.6.0p2</translation>
+        <translation>Vmaster</translation>
     </message>
     <message>
         <source>ABOUT_LICENSE</source>
@@ -25,7 +25,7 @@
     </message>
     <message>
         <source>ABOUT_VERSION</source>
-        <translation>Version 7.6.0p2</translation>
+        <translation>Version master</translation>
     </message>
     <message>
         <source>ABOUT_TITLE</source>
index a7196d8bbec00f96038b060e94ed3324c22640de..3a9e74922ebc9e64649177c115437041c638fa9f 100644 (file)
@@ -17,7 +17,7 @@
     </message>
     <message>
         <source>APP_VERSION</source>
-        <translation>V7.6.0p2</translation>
+        <translation>Vmaster</translation>
     </message>
     <message>
         <source>ABOUT_LICENSE</source>
@@ -25,7 +25,7 @@
     </message>
     <message>
         <source>ABOUT_VERSION</source>
-        <translation>Version 7.6.0p2</translation>
+        <translation>Version master</translation>
     </message>
     <message>
         <source>ABOUT_TITLE</source>
index c112a33d335ea9d6c7669556209b93c595d2d1f6..7c4f98acde0ff795f159275a28d6b12f18b937b4 100644 (file)
@@ -17,7 +17,7 @@
     </message>
     <message>
       <source>APP_VERSION</source>
-      <translation>V7.6.0p2</translation>
+      <translation>Vmaster</translation>
     </message>
     <message>
       <source>ABOUT_LICENSE</source>
@@ -25,7 +25,7 @@
     </message>
     <message>
       <source>ABOUT_VERSION</source>
-      <translation>Version 7.6.0p2</translation>
+      <translation>Version master</translation>
     </message>
     <message>
       <source>ABOUT_TITLE</source>
index 384db9bf558e2db9f42d2ea796bf35e08cf80709..545e9297925ce39ced1960ed9736ebc1813463b5 100755 (executable)
@@ -33,8 +33,6 @@ import platform
 from salomeContextUtils import SalomeContextException
 
 def usage():
-  #exeName = os.path.splitext(os.path.basename(__file__))[0]
-
   msg = '''\
 Usage: salome [command] [options] [--config=<file,folder,...>]
 
@@ -51,14 +49,13 @@ Commands:
     test            Run SALOME tests.
     info            Display some information about SALOME
     help            Show this message
-    coffee          Yes! SALOME can also make coffee!!
 
 If no command is given, default to start.
 
 Command options:
 ================
     Use salome <command> --help to show help on command ; available for commands:
-    start, shell, test.
+    start, shell, connect, test, info.
 
 --config=<file,folder,...>
 ==========================
@@ -239,13 +236,16 @@ class SalomeContext:
   See usage for details on commands.
   """
   def _startSalome(self, args):
+    import os
+    import sys
     try:
-      import os
+      from setenv import add_path
       absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH')
-      import sys
       path = os.path.realpath(os.path.join(absoluteAppliPath, "bin", "salome"))
-      if not path in sys.path:
-        sys.path[:0] = [path]
+      add_path(path, "PYTHONPATH")
+      path = os.path.realpath(os.path.join(absoluteAppliPath, "bin", "salome", "appliskel"))
+      add_path(path, "PYTHONPATH")
+
     except:
       pass
 
@@ -330,7 +330,9 @@ class SalomeContext:
     sys.path[:0] = pythonpath
   #
 
-  def _runAppli(self, args=[]):
+  def _runAppli(self, args=None):
+    if args is None:
+      args = []
     # Initialize SALOME environment
     sys.argv = ['runSalome'] + args
     import setenv
@@ -360,7 +362,9 @@ class SalomeContext:
     return proc.communicate()
   #
 
-  def _runSession(self, args=[]):
+  def _runSession(self, args=None):
+    if args is None:
+      args = []
     sys.argv = ['runSession'] + args
     import runSession
     params, args = runSession.configureSession(args, exe="salome shell")
@@ -372,18 +376,21 @@ class SalomeContext:
     return runSession.runSession(params, args)
   #
 
-  def _runConsole(self, args=[]):
+  def _runConsole(self, args=None):
+    if args is None:
+      args = []
     # Initialize SALOME environment
-    sys.argv = ['runConsole'] + args
+    sys.argv = ['runConsole']
     import setenv
     setenv.main(True)
 
-    cmd = ["python", "-c", "import runConsole\nrunConsole.connect()" ]
-    proc = subprocess.Popen(cmd, shell=False, close_fds=True)
-    return proc.communicate()
+    import runConsole
+    return runConsole.connect(args)
   #
 
-  def _kill(self, args=[]):
+  def _kill(self, args=None):
+    if args is None:
+      args = []
     ports = args
     if not ports:
       print "Port number(s) not provided to command: salome kill <port(s)>"
@@ -420,7 +427,9 @@ class SalomeContext:
       pass
   #
 
-  def _runTests(self, args=[]):
+  def _runTests(self, args=None):
+    if args is None:
+      args = []
     sys.argv = ['runTests']
     import setenv
     setenv.main(True)
@@ -429,9 +438,35 @@ class SalomeContext:
     return runTests.runTests(args, exe="salome test")
   #
 
-  def _showInfo(self, unused=None):
-    print "Running with python", platform.python_version()
-    self._runAppli(["--version"])
+  def _showInfo(self, args=None):
+    if args is None:
+      args = []
+
+    usage = "Usage: salome info [options]"
+    epilog  = """\n
+Display some information about SALOME.\n
+Available options are:
+    -p,--ports        Show list of busy ports (running SALOME instances).
+    -v,--version      Show running SALOME version.
+    -h,--help         Show this message.
+"""
+    if not args:
+      args = ["--version"]
+
+    if "-h" in args or "--help" in args:
+      print usage + epilog
+      return
+
+    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]
+
+    if "-v" in args or "--version" in args:
+      print "Running with python", platform.python_version()
+      self._runAppli(["--version"])
   #
 
   def _usage(self, unused=None):
index 12cd3a6c7f732059dd7b6f88aecff52f98c1b7fc..de561cf072547f071d9a1e15c79fbf47d853f39f 100755 (executable)
@@ -61,18 +61,14 @@ def __getConfigFileNamesDefault():
   return __listDirectory(envdDir)
 #
 
-def getConfigFileNames(args, checkExistence=False):
-  # special case: configuration files are provided by user
-  # Search for command-line argument(s) --config=file1,file2,..., filen
-  # Search for command-line argument(s) --config=dir1,dir2,..., dirn
-  configOptionPrefix = "--config="
-  configArgs = [ str(x) for x in args if str(x).startswith(configOptionPrefix) ]
+def __getEnvironmentFileNames(args, optionPrefix, checkExistence):
+  # special case: extra configuration/environment files are provided by user
+  # Search for command-line argument(s) <optionPrefix>=file1,file2,..., filen
+  # Search for command-line argument(s) <optionPrefix>=dir1,dir2,..., dirn
+  configArgs = [ str(x) for x in args if str(x).startswith(optionPrefix) ]
 
-  if len(configArgs) == 0:
-    return __getConfigFileNamesDefault(), args, []
-
-  args = [ x for x in args if not x.startswith(configOptionPrefix) ]
-  allLists = [ x.replace(configOptionPrefix, '') for x in configArgs ]
+  args = [ x for x in args if not x.startswith(optionPrefix) ]
+  allLists = [ x.replace(optionPrefix, '') for x in configArgs ]
 
   configFileNames = []
   unexisting = []
@@ -91,6 +87,105 @@ def getConfigFileNames(args, checkExistence=False):
   return configFileNames, args, unexisting
 #
 
+def __validate_pair(ob):
+  try:
+    if not (len(ob) == 2):
+      #print "Unexpected result:", ob
+      raise ValueError
+  except:
+    return False
+  return True
+#
+def __get_environment_from_batch_command(env_cmd, initial=None):
+  """
+  Take a command (either a single command or list of arguments)
+  and return the environment created after running that command.
+  Note that if the command must be a batch file or .cmd file, or the
+  changes to the environment will not be captured.
+
+  If initial is supplied, it is used as the initial environment passed
+  to the child process.
+  """
+  #if not isinstance(env_cmd, (list, tuple)):
+  #    env_cmd = [env_cmd]
+  # construct the command that will alter the environment
+  #env_cmd = subprocess.list2cmdline(env_cmd)
+  # create a tag so we can tell in the output when the proc is done
+  tag = 'Done running command'
+  # construct a command to do accomplish this
+  cmd = '{env_cmd} && echo "{tag}"'.format(**vars())
+
+  # launch the process
+  proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=initial, shell=True)
+  # parse the output sent to stdout
+  lines = proc.stdout
+  # consume whatever output occurs until the tag is reached
+  #consume(itertools.takewhile(lambda l: tag not in l, lines))
+  # define a way to handle each KEY=VALUE line
+  handle_line = lambda l: l.rstrip().split('=',1)
+  # parse key/values into pairs
+  #pairs = map(handle_line, lines)
+  pairs = []
+  cpt = 0
+  while True:
+    line = lines.readline()
+    cpt = cpt+1
+    if tag in line or cpt > 1000:
+      break
+    if line:
+      pairs.append(line.rstrip().split('=',1))
+  # make sure the pairs are valid
+  valid_pairs = filter(__validate_pair, pairs)
+  # construct a dictionary of the pairs
+  result = dict(valid_pairs)
+  # let the process finish
+  proc.communicate()
+  return result
+#
+def __subtract(ref, dic):
+  result = {}
+  for key,val in ref.items():
+    if not dic.has_key(key):
+      result[key] = val
+    else:
+      # compare values types
+      if (type(dic[key]) != type(val)):
+        result[key] = val
+      else:
+        # compare values
+        if isinstance(val, basestring):
+          tolist1 = dic[key].split(os.pathsep)
+          tolist2 = val.split(os.pathsep)
+          diff = list(set(tolist2)-set(tolist1))
+          if diff:
+            result[key] = os.pathsep.join(diff)
+        else:
+          result[key] = val
+
+  return result
+#
+
+def getConfigFileNames(args, checkExistence=False):
+  configOptionPrefix = "--config="
+  configArgs = [ str(x) for x in args if str(x).startswith(configOptionPrefix) ]
+  if len(configArgs) == 0:
+    configFileNames, unexist1 = __getConfigFileNamesDefault(), []
+  else:
+    # get configuration filenames
+    configFileNames, args, unexist1 = __getEnvironmentFileNames(args, configOptionPrefix, checkExistence)
+
+  # get extra environment
+  extraEnvFileNames, args, unexist2 = __getEnvironmentFileNames(args, "--extra_env=", checkExistence)
+  before = __get_environment_from_batch_command("env")
+  after = {}
+  for filename in extraEnvFileNames:
+    after.update(__get_environment_from_batch_command(filename))
+    pass
+
+  extraEnv = __subtract(after,before)
+  return configFileNames, extraEnv, args, unexist1+unexist2
+#
+
 def __getScriptPath(scriptName, searchPathList):
   scriptName = os.path.expanduser(scriptName)
   if os.path.isabs(scriptName):
@@ -133,7 +228,9 @@ class ScriptAndArgsObjectEncoder(json.JSONEncoder):
       return json.JSONEncoder.default(self, obj)
 #
 
-def getShortAndExtraArgs(args=[]):
+def getShortAndExtraArgs(args=None):
+  if args is None:
+    args = []
   try:
     pos = args.index("--") # raise a ValueError if not found
     short_args = args[:pos]
@@ -147,7 +244,9 @@ def getShortAndExtraArgs(args=[]):
 #
 
 # Return an array of ScriptAndArgs objects
-def getScriptsAndArgs(args=[], searchPathList=None):
+def getScriptsAndArgs(args=None, searchPathList=None):
+  if args is None:
+    args = []
   short_args, extra_args = getShortAndExtraArgs(args)
   args = short_args