Salome HOME
projects
/
modules
/
kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
EDF bug 17743, salome.sg regressions in DEV (missing getAllSelected method)
[modules/kernel.git]
/
bin
/
runSession.py
diff --git
a/bin/runSession.py
b/bin/runSession.py
index 0c5b568d4daf9c85648d94e881e67965d5fb16e0..c6676b8020708a55a737aae2ddb030d8a626cae1 100644
(file)
--- a/
bin/runSession.py
+++ b/
bin/runSession.py
@@
-1,5
+1,5
@@
# -*- coding: iso-8859-1 -*-
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-201
6
CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-201
7
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
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@
-29,7
+29,7
@@
import socket
import subprocess
import re
from salomeContextUtils import getScriptsAndArgs, formatScriptsAndArgs, getShortAndExtraArgs
import subprocess
import re
from salomeContextUtils import getScriptsAndArgs, formatScriptsAndArgs, getShortAndExtraArgs
-from salome_utils import getUserName
+from salome_utils import getUserName
, getShortHostName
# Use to display newlines (\n) in epilog
class MyParser(OptionParser):
# Use to display newlines (\n) in epilog
class MyParser(OptionParser):
@@
-123,7
+123,7
@@
User "myself" connects to remotemachine to run the script concatenate.py in
(options, args) = parser.parse_args(short_args)
except Exception as e:
print(e)
(options, args) = parser.parse_args(short_args)
except Exception as e:
print(e)
- return
+ return
None, []
port = options.port
host = options.host
port = options.port
host = options.host
@@
-152,15
+152,15
@@
User "myself" connects to remotemachine to run the script concatenate.py in
else:
if not host:
# only PORT is given
else:
if not host:
# only PORT is given
- host =
socket.gethostn
ame()
+ host =
getShortHostN
ame()
# both MACHINE and PORT are given
_writeConfigFile(port, host)
#
os.environ['NSPORT'] = port
os.environ['NSHOST'] = host
# both MACHINE and PORT are given
_writeConfigFile(port, host)
#
os.environ['NSPORT'] = port
os.environ['NSHOST'] = host
- # determine running mode, t
ah
t is either 'local' or 'remote'
- here =
socket.gethostn
ame()
+ # determine running mode, t
ha
t is either 'local' or 'remote'
+ here =
getShortHostN
ame()
mode = "local"
if host != here and host != "localhost" and host != "no_host":
mode="remote"
mode = "local"
if host != here and host != "localhost" and host != "no_host":
mode="remote"
@@
-193,6
+193,7
@@
def __runLocalSession(command):
for cmd in command:
single_cmd = cmd.strip().split(' ')
any_error = False
for cmd in command:
single_cmd = cmd.strip().split(' ')
any_error = False
+ error_code = 1
try:
proc = subprocess.Popen(single_cmd)
(stdoutdata, stderrdata) = proc.communicate() # Wait for process to terminate
try:
proc = subprocess.Popen(single_cmd)
(stdoutdata, stderrdata) = proc.communicate() # Wait for process to terminate
@@
-203,6
+204,7
@@
def __runLocalSession(command):
if proc.returncode != 0:
any_error = True
if proc.returncode != 0:
any_error = True
+ error_code = proc.returncode
except:
any_error = True
pass
except:
any_error = True
pass
@@
-213,9
+215,9
@@
def __runLocalSession(command):
sys.stdout.write("".join(outmsg))
if errmsg:
sys.stderr.write("".join(errmsg))
sys.stdout.write("".join(outmsg))
if errmsg:
sys.stderr.write("".join(errmsg))
- sys.exit(
1
)
+ sys.exit(
error_code
)
- return
("".join(outmsg), "".join(errmsg))
+ return
0
else:
absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH','')
if sys.platform == "win32":
else:
absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH','')
if sys.platform == "win32":
@@
-223,7
+225,8
@@
def __runLocalSession(command):
else:
cmd = ["/bin/bash", "--rcfile", absoluteAppliPath + "/.bashrc" ]
proc = subprocess.Popen(cmd, shell=False, close_fds=True)
else:
cmd = ["/bin/bash", "--rcfile", absoluteAppliPath + "/.bashrc" ]
proc = subprocess.Popen(cmd, shell=False, close_fds=True)
- return proc.communicate()
+ proc.communicate()
+ return proc.returncode
#
def __copyFiles(user, machine, script, infiles, outfiles):
#
def __copyFiles(user, machine, script, infiles, outfiles):
@@
-283,10
+286,10
@@
def __copyFiles(user, machine, script, infiles, outfiles):
def __runRemoteSession(sa_obj, params):
if not params.user:
print("ERROR: The user login on remote machine MUST be given.")
def __runRemoteSession(sa_obj, params):
if not params.user:
print("ERROR: The user login on remote machine MUST be given.")
- return
+ return
1
if not params.directory:
print("ERROR: The remote directory MUST be given.")
if not params.directory:
print("ERROR: The remote directory MUST be given.")
- return
+ return
1
# sa_obj.script may be 'python script.py' --> only process .py file
header = " ".join(sa_obj.script.split()[:-1])
# sa_obj.script may be 'python script.py' --> only process .py file
header = " ".join(sa_obj.script.split()[:-1])
@@
-318,6
+321,7
@@
def __runRemoteSession(sa_obj, params):
os.system(command)
os.remove(tmp_script)
os.system(command)
os.remove(tmp_script)
+ return 0
#
def runSession(params, args):
#
def runSession(params, args):
@@
-328,6
+332,10
@@
def runSession(params, args):
return __runLocalSession(command)
elif params.mode == "remote":
return __runLocalSession(command)
elif params.mode == "remote":
+ any_error = 0
for sa_obj in scriptArgs:
for sa_obj in scriptArgs:
- __runRemoteSession(sa_obj, params)
+ ok = __runRemoteSession(sa_obj, params)
+ if not ok:
+ any_error = 1
+ return any_error
#
#