# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2014 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
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
from optparse import OptionParser
from NSparam import getNSparams
import socket
+import subprocess
# Use to display newlines (\n) in epilog
class MyParser(OptionParser):
os.environ['OMNIORB_CONFIG'] = filename
#
+
+# command looks like a Bash command-line:
+# script1.py [args] ; script2.py [args] ; ...
+def runSession(command):
+ if command:
+ sep = ";"
+ if sys.platform == "win32":
+ sep= "&"
+ command = command.split(sep)
+ outmsg = []
+ errmsg = []
+ for cmd in command:
+ save_cmd = cmd
+ cmd = cmd.strip().split(' ')
+ #proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ proc = subprocess.Popen(cmd)
+ (stdoutdata, stderrdata) = proc.communicate()
+ if stdoutdata:
+ outmsg.append(stdoutdata)
+ if stderrdata:
+ errmsg.append(stderrdata)
+
+ if proc.returncode != 0:
+ errmsg.append("Error raised when executing command: %s\n"%save_cmd)
+ if outmsg:
+ sys.stdout.write("".join(outmsg))
+ if errmsg:
+ sys.stderr.write("".join(errmsg))
+ sys.exit(proc.returncode)
+
+ return ("".join(outmsg), "".join(errmsg))
+ else:
+ absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH','')
+ cmd = ["/bin/bash", "--rcfile", absoluteAppliPath + "/.bashrc" ]
+ proc = subprocess.Popen(cmd, shell=False, close_fds=True)
+ return proc.communicate()
+#