Alon Bar-Lev has uploaded a new change for review.

Change subject: core: support suppress log of stream content
......................................................................

core: support suppress log of stream content

Change-Id: I8aeaaa866642678da141e6e2112ebd3b18dfa708
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M src/otopi/plugin.py
1 file changed, 22 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/otopi refs/changes/15/16015/1

diff --git a/src/otopi/plugin.py b/src/otopi/plugin.py
index ec1e7da..76f3975 100644
--- a/src/otopi/plugin.py
+++ b/src/otopi/plugin.py
@@ -391,12 +391,21 @@
 
         return (rc, stdout, stderr)
 
-    def execute(self, args, raiseOnError=True, stdin=None, *eargs, **kwargs):
+    def execute(
+        self,
+        args,
+        raiseOnError=True,
+        logStreams=True,
+        stdin=None,
+        *eargs,
+        **kwargs
+    ):
         """Execute system command.
 
         Keyword arguments:
         args -- a list of command arguments.
         raiseOnError -- raise exception if an error.
+        logStreams -- log streams' content.
         stdin -- a list of lines.
         eargs -- extra args to subprocess.Popen.
         kwargs - extra kwargs to subprocess.Popen.
@@ -406,7 +415,7 @@
 
         stdour, stderr are list of lines.
         """
-        if stdin is not None:
+        if logStreams and stdin is not None:
             self.logger.debug(
                 'execute-input: %s stdin:\n%s\n',
                 args,
@@ -424,16 +433,17 @@
         # warning: python-2.6 does not have kwargs for decode
         stdout = stdout.decode('utf-8', 'replace').splitlines()
         stderr = stderr.decode('utf-8', 'replace').splitlines()
-        self.logger.debug(
-            'execute-output: %s stdout:\n%s\n',
-            args,
-            '\n'.join(stdout)
-        )
-        self.logger.debug(
-            'execute-output: %s stderr:\n%s\n',
-            args,
-            '\n'.join(stderr)
-        )
+        if logStreams:
+            self.logger.debug(
+                'execute-output: %s stdout:\n%s\n',
+                args,
+                '\n'.join(stdout)
+            )
+            self.logger.debug(
+                'execute-output: %s stderr:\n%s\n',
+                args,
+                '\n'.join(stderr)
+            )
         if rc != 0 and raiseOnError:
             raise RuntimeError(
                 _("Command '{command}' failed to execute").format(


-- 
To view, visit http://gerrit.ovirt.org/16015
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8aeaaa866642678da141e6e2112ebd3b18dfa708
Gerrit-PatchSet: 1
Gerrit-Project: otopi
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to