Antoni Segura Puimedon has uploaded a new change for review.

Change subject: Do not raise an Exception processing stdout/err
......................................................................

Do not raise an Exception processing stdout/err

Some commands can output characters that are not decodable by
codecs.utf_8_decode. One example is nmcli (used by ovirt-host-deploy
plugin, that has a bug (reported and confirmed) retrieving the
vendor string with certain realteks and prints to stdout
non-utf-8-decodable strings.

In any case, I think that it is a good idea not to explode because
of undecodability. Maybe instead of pass we could do some treatment
of the bytes or log it.

Change-Id: I121d975083f02957aad927305d2cd9157c77b3ea
Signed-off-by: Antoni S. Puimedon <[email protected]>
---
M src/otopi/plugin.py
1 file changed, 14 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/otopi refs/changes/77/13277/1

diff --git a/src/otopi/plugin.py b/src/otopi/plugin.py
index d1a5c17..3920928 100644
--- a/src/otopi/plugin.py
+++ b/src/otopi/plugin.py
@@ -403,8 +403,19 @@
             *eargs,
             **kwargs
         )
-        stdout = stdout.decode('utf-8').splitlines()
-        stderr = stderr.decode('utf-8').splitlines()
+        _stdout = []
+        for line in stdout:
+            try:
+                _stdout.append(line.decode('utf-8'))
+            except UnicodeDecodeError:
+                pass
+
+        _stderr = []
+        for line in stderr:
+            try:
+                _stderr.append(line.decode('utf-8'))
+            except UnicodeDecodeError:
+                pass
         self.logger.debug(
             'execute-output: %s stdout:\n%s\n',
             args,
@@ -421,7 +432,7 @@
                     command=args[0],
                 )
             )
-        return (rc, stdout, stderr)
+        return (rc, _stdout, _stderr)
 
 
 # vim: expandtab tabstop=4 shiftwidth=4


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

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

Reply via email to