Salome HOME
Merge Python 3 porting.
[modules/kernel.git] / bin / runSession.py
index e06150138c4652ae3a0dc196398279837bf2aa55..2f670b1def00560285ab32dd299cf5407f3779a1 100644 (file)
@@ -121,8 +121,8 @@ User "myself" connects to remotemachine to run the script concatenate.py in
   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
 
   port = options.port
@@ -249,7 +249,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)
-    print "[  SCP  ]", cmd
+    print("[  SCP  ]", cmd)
     os.system(cmd)
 
     list_infiles.append(tmp_file)
@@ -273,7 +273,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)
-  print "[  SCP  ]", cmd
+  print("[  SCP  ]", cmd)
   os.system(cmd)
 
   return list_infiles, list_outfiles, tmp_script
@@ -282,10 +282,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:
-    print "ERROR: The user login on remote machine MUST be given."
+    print("ERROR: The user login on remote machine MUST be given.")
     return
   if not params.directory:
-    print "ERROR: The remote directory MUST be given."
+    print("ERROR: The remote directory MUST be given.")
     return
 
   # sa_obj.script may be 'python script.py' --> only process .py file
@@ -299,7 +299,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))
-  print '[  SSH   ] ' + command
+  print('[  SSH   ] ' + command)
   os.system(command)
 
   # Get remote files and clean
@@ -309,12 +309,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)
-    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))
-  print '[  SSH   ] ' + command
+  print('[  SSH   ] ' + command)
   os.system(command)
   os.remove(tmp_script)