From 40b568db5ed0ba760da8b14a00814db7d01a3944 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 14 Mar 2016 12:58:33 +0100 Subject: [PATCH] linux application receives a new attribute splitStderr defaults to False stdout and stderr are now merged by default in a single trace previous behaviour can be achieved by setting this new attribute to True --- nepi/resources/linux/application.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/nepi/resources/linux/application.py b/nepi/resources/linux/application.py index 94bd5e93..ba9bbc38 100644 --- a/nepi/resources/linux/application.py +++ b/nepi/resources/linux/application.py @@ -21,7 +21,7 @@ from nepi.execution.trace import Trace, TraceAttr from nepi.execution.resource import ResourceManager, clsinit_copy, \ ResourceState from nepi.resources.linux.node import LinuxNode -from nepi.util.sshfuncs import ProcStatus +from nepi.util.sshfuncs import ProcStatus, STDOUT from nepi.util.timefuncs import tnow, tdiffsec import os @@ -161,6 +161,10 @@ class LinuxApplication(ResourceManager): Attribute("tearDown", "Command to be executed just before releasing the resource", flags = Flags.Design)) + cls._register_attribute( + Attribute("splitStderr", + "requests stderr to be retrieved separately", + default = False)) @classmethod def _register_traces(cls): @@ -383,13 +387,20 @@ class LinuxApplication(ResourceManager): # in background ( but wait until the command has # finished to continue ) shfile = os.path.join(self.app_home, "{}.sh".format(prefix)) + # low-level spawn tools in both sshfuncs and execfuncs + # expect stderr=sshfuncs.STDOUT to mean std{out,err} are merged + stderr = "{}_stderr".format(prefix) \ + if self.get("splitStderr") \ + else STDOUT + print("{} : prefix = {}, command={}, stderr={}" + .format(self, prefix, command, stderr)) self.node.run_and_wait(command, self.run_home, shfile = shfile, overwrite = False, pidfile = "{}_pidfile".format(prefix), ecodefile = "{}_exitcode".format(prefix), stdout = "{}_stdout".format(prefix), - stderr = "{}_stderr".format(prefix)) + stderr = stderr) def upload_sources(self, sources = None, src_dir = None): if not sources: @@ -583,7 +594,11 @@ class LinuxApplication(ResourceManager): sudo = self.get("sudo") or False stdout = "stdout" - stderr = "stderr" + # low-level spawn tools in both sshfuncs and execfuncs + # expect stderr=sshfuncs.STDOUT to mean std{out,err} are merged + stderr = "stderr" \ + if self.get("splitStderr") \ + else STDOUT stdin = os.path.join(self.app_home, "stdin") if self.get("stdin") \ else None -- 2.43.0