various cosmetic
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 15 Mar 2016 14:46:06 +0000 (15:46 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 15 Mar 2016 14:46:06 +0000 (15:46 +0100)
nepi/resources/linux/application.py
nepi/util/sshfuncs.py

index 0a0ed05..4874a0e 100644 (file)
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+import os
+import subprocess
+import logging
+
 from nepi.execution.attribute import Attribute, Flags, Types
 from nepi.execution.trace import Trace, TraceAttr
 from nepi.execution.resource import ResourceManager, clsinit_copy, \
@@ -24,8 +28,9 @@ from nepi.resources.linux.node import LinuxNode
 from nepi.util.sshfuncs import ProcStatus, STDOUT
 from nepi.util.timefuncs import tnow, tdiffsec
 
-import os
-import subprocess
+# to debug, just use
+# logging.getLogger('application').setLevel(logging.DEBUG)
+logger = logging.getLogger("application")
 
 # TODO: Resolve wildcards in commands!!
 # TODO: When a failure occurs during deployment, scp and ssh processes are left running behind!!
@@ -248,6 +253,7 @@ class LinuxApplication(ResourceManager):
         self.info("Retrieving '{}' trace {} ".format(name, attr))
 
         path = self.trace_filepath(name)
+        logger.debug("trace: path= {}".format(path))
         
         command = "(test -f {} && echo 'success') || echo 'error'".format(path)
         (out, err), proc = self.node.execute(command)
index 1b4d389..fa7df4b 100644 (file)
@@ -38,13 +38,15 @@ from six import PY2
 
 _re_inet = re.compile("\d+:\s+(?P<name>[a-z0-9_-]+)\s+inet6?\s+(?P<inet>[a-f0-9.:/]+)\s+(brd\s+[0-9.]+)?.*scope\s+global.*") 
 
+# to debug, just use
+# logging.getLogger('sshfuncs').setLevel(logging.DEBUG)
 logger = logging.getLogger("sshfuncs")
 
 def log(msg, level = logging.DEBUG, out = None, err = None):
     if out:
-        msg += " - OUT: {} ".format(out)
+        msg += " - OUT is {} long".format(len(out))
     if err:
-        msg += " - ERROR: {} ".format(err)
+        msg += " - ERR is {} long".format(len(err))
     logger.log(level, msg)
 
 if hasattr(os, "devnull"):
@@ -307,16 +309,14 @@ def rexec(command, host, user,
 
     args.append(command)
 
-    log_msg = " rexec - host {} - command {} ".format(host, " ".join(map(str, args)))
+    log_msg = " rexec - host {} - command {} ".format(host, pretty_args(args))
 
     stdout = stderr = stdin = subprocess.PIPE
     if forward_x11:
         stdout = stderr = stdin = None
 
     return _retry_rexec(args, log_msg, 
-                        stderr = stderr,
-                        stdin = stdin,
-                        stdout = stdout,
+                        stdin = stdin, stdout = stdout, stderr = stderr,
                         env = env, 
                         retry = retry, 
                         tmp_known_hosts = tmp_known_hosts,
@@ -407,7 +407,7 @@ def rcopy(source, dest,
     else:
         args.append(dest)
 
-    log_msg = " rcopy - host {} - command {} ".format(host, " ".join(map(str, args)))
+    log_msg = " rcopy - host {} - command {} ".format(host, pretty_args(args))
     
     return _retry_rexec(args, log_msg, env = None, retry = retry, 
                         tmp_known_hosts = tmp_known_hosts,
@@ -854,6 +854,7 @@ def _communicate(proc, input, timeout=None, err_on_timeout=True):
                 proc.stdout.close()
                 read_set.remove(proc.stdout)
             stdout.append(data)
+            log("have read {} bytes from stdout".format(len(stdout)))
 
         # likewise
         if proc.stderr in rlist:
@@ -862,6 +863,7 @@ def _communicate(proc, input, timeout=None, err_on_timeout=True):
                 proc.stderr.close()
                 read_set.remove(proc.stderr)
             stderr.append(data)
+            log("have read {} bytes from stderr".format(len(stdout)))
 
     # All data exchanged.  Translate lists into strings.
     if stdout is not None: