miscell cleanup and prettyfication in collector and application
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Mon, 14 Mar 2016 17:23:49 +0000 (18:23 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Mon, 14 Mar 2016 17:23:49 +0000 (18:23 +0100)
nepi/resources/all/collector.py
nepi/resources/linux/application.py

index 4729e01..18bcf3a 100644 (file)
@@ -20,7 +20,6 @@ from nepi.execution.attribute import Attribute, Flags, Types
 from nepi.execution.trace import Trace, TraceAttr
 from nepi.execution.resource import ResourceManager, clsinit_copy, \
         ResourceState, ResourceAction
-from nepi.util.sshfuncs import ProcStatus
 
 import os
 import tempfile
@@ -46,21 +45,18 @@ class Collector(ResourceManager):
 
     @classmethod
     def _register_attributes(cls):
-        trace_name = Attribute("traceName", 
-                "Name of the trace to be collected", 
-                flags = Flags.Design)
-
-        sub_dir = Attribute("subDir", 
-                "Sub directory to collect traces into", 
-                flags = Flags.Design)
-
-        rename = Attribute("rename", 
-                "Name to give to the collected trace file", 
-                flags = Flags.Design)
-
-        cls._register_attribute(trace_name)
-        cls._register_attribute(sub_dir)
-        cls._register_attribute(rename)
+        cls._register_attribute(
+            Attribute("traceName", 
+                      "Name of the trace to be collected", 
+                      flags = Flags.Design))
+        cls._register_attribute(
+            Attribute("subDir", 
+                      "Sub directory to collect traces into", 
+                      flags = Flags.Design))
+        cls._register_attribute(
+            Attribute("rename", 
+                      "Name to give to the collected trace file", 
+                      flags = Flags.Design))
 
     def __init__(self, ec, guid):
         super(Collector, self).__init__(ec, guid)
@@ -85,8 +81,8 @@ class Collector(ResourceManager):
         if subdir:
             self._store_path = os.path.join(self.store_path, subdir)
         
-        msg = "Creating local directory at %s to store %s traces " % (
-                self.store_path, trace_name)
+        msg = "Creating local directory at {} to store {} traces "\
+              .format(self.store_path, trace_name)
         self.info(msg)
 
         try:
@@ -106,24 +102,25 @@ class Collector(ResourceManager):
         trace_name = self.get("traceName")
         rename = self.get("rename") or trace_name
 
-        msg = "Collecting '%s' traces to local directory %s" % (
-            trace_name, self.store_path)
+        msg = "Collecting '{}' traces to local directory {}"\
+              .format(trace_name, self.store_path)
         self.info(msg)
 
         rms = self.get_connected()
         for rm in rms:
-            fpath = os.path.join(self.store_path, "%d.%s" % (rm.guid, 
-                 rename))
+            fpath = os.path.join(self.store_path, "{}.{}"\
+                                 .format(rm.guid, rename))
 
             try:
                 result = self.ec.trace(rm.guid, trace_name)
+                print("collector.do_release ..")
                 with open(fpath, "w") as f:
                     f.write(result)
             except:
                 import traceback
                 err = traceback.format_exc()
-                msg = "Couldn't retrieve trace %s for %d at %s " % (trace_name, 
-                        rm.guid, fpath)
+                msg = "Couldn't retrieve trace {} for {} at {} "\
+                    .format(trace_name, rm.guid, fpath)
                 self.error(msg, out = "", err = err)
                 continue
 
index ba9bbc3..0a0ed05 100644 (file)
@@ -168,11 +168,10 @@ class LinuxApplication(ResourceManager):
 
     @classmethod
     def _register_traces(cls):
-        stdout = Trace("stdout", "Standard output stream", enabled = True)
-        stderr = Trace("stderr", "Standard error stream", enabled = True)
-
-        cls._register_trace(stdout)
-        cls._register_trace(stderr)
+        cls._register_trace(
+            Trace("stdout", "Standard output stream", enabled = True))
+        cls._register_trace(
+            Trace("stderr", "Standard error stream", enabled = True))
 
     def __init__(self, ec, guid):
         super(LinuxApplication, self).__init__(ec, guid)