Salome HOME
New params in config_appli to handle environment modules
[modules/kernel.git] / bin / runSession.py
index cbc556e83083d39e4ef4412d8075bb698133ca01..c83ef01a1d4c7e3e3b18dd984d45e5338b90cb62 100644 (file)
@@ -1,5 +1,5 @@
 #  -*- coding: iso-8859-1 -*-
-# 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
@@ -29,6 +29,7 @@ import socket
 import subprocess
 import re
 from salomeContextUtils import getScriptsAndArgs, formatScriptsAndArgs, getShortAndExtraArgs
+from salome_utils import getUserName
 
 # Use to display newlines (\n) in epilog
 class MyParser(OptionParser):
@@ -55,7 +56,9 @@ class SessionParameters:
   #
 #
 
-def configureSession(args=[], exe=None):
+def configureSession(args=None, exe=None):
+  if args is None:
+    args = []
   if exe:
       usage = "Usage: %s [options] [command] [-- <extra>]"%exe
   else:
@@ -132,7 +135,7 @@ User "myself" connects to remotemachine to run the script concatenate.py in
       # neither MACHINE nor PORT are given
       # --- set omniORB configuration to current session if any
       omniorbUserPath = os.environ['OMNIORB_USER_PATH']
-      fileOmniConfig = omniorbUserPath + '/.omniORB_' + os.environ['USER'] + '_last.cfg'
+      fileOmniConfig = omniorbUserPath + '/.omniORB_' + getUserName() + '_last.cfg'
       if os.path.isfile(fileOmniConfig):
         os.environ['OMNIORB_CONFIG'] = fileOmniConfig
         # --- set environment variables for port and hostname of NamingService
@@ -169,7 +172,7 @@ User "myself" connects to remotemachine to run the script concatenate.py in
 # --- set the OMNIORB_CONFIG file and environment relative to this run of SALOME
 def _writeConfigFile(port, host):
   path = os.environ['OMNIORB_USER_PATH']
-  kwargs = {'with_username' : os.environ['USER']}
+  kwargs = {'with_username' : getUserName()}
 
   from ORBConfigFile import writeORBConfigFile
   [ filename, msgSize ] = writeORBConfigFile(path, host, port, kwargs)
@@ -215,7 +218,10 @@ def __runLocalSession(command):
     return ("".join(outmsg), "".join(errmsg))
   else:
     absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH','')
-    cmd = ["/bin/bash",  "--rcfile", absoluteAppliPath + "/.bashrc" ]
+    if sys.platform == "win32":
+      cmd = ["cmd", "/K", "set PROMPT=[SALOME] $P$G"]
+    else:
+      cmd = ["/bin/bash",  "--rcfile", absoluteAppliPath + "/.bashrc" ]
     proc = subprocess.Popen(cmd, shell=False, close_fds=True)
     return proc.communicate()
 #