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
last modif after tests
[modules/kernel.git]
/
bin
/
runSession.py
diff --git
a/bin/runSession.py
b/bin/runSession.py
index 761e5d023ed24e32805a47f4f7d04da6b224eee0..fde468001a926bcf7b8934023b0fe55f67104107 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
7
CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-201
9
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
@@
-118,15
+118,25
@@
User "myself" connects to remotemachine to run the script concatenate.py in
help="[Remote mode] The user on the computer to connect to."
)
help="[Remote mode] The user on the computer to connect to."
)
+ parser.add_option('-l', '--launcher', dest="launcher", default=None,
+ help="[Remote mode] The machine and the port to connect to."
+ )
+
short_args, extra_args = getShortAndExtraArgs(args)
try:
(options, args) = parser.parse_args(short_args)
short_args, extra_args = getShortAndExtraArgs(args)
try:
(options, args) = parser.parse_args(short_args)
- except Exception
,
e:
- print
e
+ except Exception
as
e:
+ print
(e)
return None, []
port = options.port
host = options.host
return None, []
port = options.port
host = options.host
+ launcher = options.launcher
+ if launcher is not None:
+ pos = launcher.find(":")
+ if pos != -1:
+ host = launcher[0:pos]
+ port = launcher[pos+1:]
# :GLITCH: this code defines specific environment variables (OMNIORB_CONFIG, NSPORT,
# NSHOST) which are later used by other modules. Working, but not really "safe"...
# :GLITCH: this code defines specific environment variables (OMNIORB_CONFIG, NSPORT,
# NSHOST) which are later used by other modules. Working, but not really "safe"...
@@
-159,10
+169,10
@@
User "myself" connects to remotemachine to run the script concatenate.py in
os.environ['NSPORT'] = port
os.environ['NSHOST'] = host
os.environ['NSPORT'] = port
os.environ['NSHOST'] = host
- # determine running mode, t
ah
t is either 'local' or 'remote'
+ # determine running mode, t
ha
t is either 'local' or 'remote'
here = getShortHostName()
mode = "local"
here = getShortHostName()
mode = "local"
- if host != here and host != "localhost" and host != "no_host":
+ if host != here and host != "localhost" and host != "no_host"
and launcher is None
:
mode="remote"
pass
params = SessionParameters(mode, port, host, options.user, options.directory)
mode="remote"
pass
params = SessionParameters(mode, port, host, options.user, options.directory)
@@
-193,6
+203,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
+214,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,7
+225,7
@@
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 0
else:
return 0
else:
@@
-250,7
+262,7
@@
def __copyFiles(user, machine, script, infiles, outfiles):
# copy the infile to the remote server
cmd = "scp %s %s@%s:%s" % (infile, user, machine, tmp_file)
# copy the infile to the remote server
cmd = "scp %s %s@%s:%s" % (infile, user, machine, tmp_file)
- print
"[ SCP ]", cmd
+ print
("[ SCP ]", cmd)
os.system(cmd)
list_infiles.append(tmp_file)
os.system(cmd)
list_infiles.append(tmp_file)
@@
-274,7
+286,7
@@
def __copyFiles(user, machine, script, infiles, outfiles):
# copy the salome script on the remote server
cmd = "scp %s %s@%s:%s" % (tmp_script, user, machine, tmp_script)
# copy the salome script on the remote server
cmd = "scp %s %s@%s:%s" % (tmp_script, user, machine, tmp_script)
- print
"[ SCP ]", cmd
+ print
("[ SCP ]", cmd)
os.system(cmd)
return list_infiles, list_outfiles, tmp_script
os.system(cmd)
return list_infiles, list_outfiles, tmp_script
@@
-283,10
+295,10
@@
def __copyFiles(user, machine, script, infiles, outfiles):
# sa_obj is a ScriptAndArgs object (from salomeContextUtils)
def __runRemoteSession(sa_obj, params):
if not params.user:
# sa_obj is a ScriptAndArgs object (from salomeContextUtils)
def __runRemoteSession(sa_obj, params):
if not params.user:
- print
"ERROR: The user login on remote machine MUST be given."
+ print
("ERROR: The user login on remote machine MUST be given.")
return 1
if not params.directory:
return 1
if not params.directory:
- print
"ERROR: The remote directory MUST be given."
+ print
("ERROR: The remote directory MUST be given.")
return 1
# sa_obj.script may be 'python script.py' --> only process .py file
return 1
# sa_obj.script may be 'python script.py' --> only process .py file
@@
-300,7
+312,7
@@
def __runRemoteSession(sa_obj, params):
if params.port:
command = command + "-p %s "%params.port
command = command + " %s %s args:%s"%(header, tmp_script, ",".join(tmp_in))
if params.port:
command = command + "-p %s "%params.port
command = command + " %s %s args:%s"%(header, tmp_script, ",".join(tmp_in))
- print
'[ SSH ] ' + command
+ print
('[ SSH ] ' + command)
os.system(command)
# Get remote files and clean
os.system(command)
# Get remote files and clean
@@
-310,12
+322,12
@@
def __runRemoteSession(sa_obj, params):
for outfile in (sa_obj.out or []):
remote_outfile = tmp_out.pop(0)
command = "scp %s@%s:%s %s" %(params.user, params.machine, remote_outfile, outfile)
for outfile in (sa_obj.out or []):
remote_outfile = tmp_out.pop(0)
command = "scp %s@%s:%s %s" %(params.user, params.machine, remote_outfile, outfile)
- print
"[ SCP ] " + command
+ print
("[ SCP ] " + command)
os.system(command)
# clean temporary files
command = "ssh %s@%s \\rm -f %s" % (params.user, params.machine, " ".join(temp_files))
os.system(command)
# clean temporary files
command = "ssh %s@%s \\rm -f %s" % (params.user, params.machine, " ".join(temp_files))
- print
'[ SSH ] ' + command
+ print
('[ SSH ] ' + command)
os.system(command)
os.remove(tmp_script)
os.system(command)
os.remove(tmp_script)