]> rtime.felk.cvut.cz Git - linux-conf-perf.git/commitdiff
Ignore decode error from subprocess
authorKarel Kočí <cynerd@email.cz>
Mon, 21 Sep 2015 17:49:51 +0000 (19:49 +0200)
committerKarel Kočí <cynerd@email.cz>
Mon, 21 Sep 2015 17:49:51 +0000 (19:49 +0200)
scripts/utils.py

index f6a4720e2f15d25b152ff7d8a411ff89f106547a..ac7f6a3b99747ffbf2dc67fb8036cd8d4f81435b 100644 (file)
@@ -79,12 +79,16 @@ def callsubprocess(process_name, process, show_output = True,
                f.write('::' + time.strftime("%y-%m-%d-%H-%M-%S-%f") + '::\n')
                for linen in sprc.stdout:
                        timerout.output()
-                       line = linen.decode(sys.getdefaultencoding())
-                       f.write(line)
-                       if show_output:
-                               print(line, end="")
-                       if return_output:
-                               rtn.append(line.rstrip())
+                       try:
+                               line = linen.decode(sys.getdefaultencoding())
+                               f.write(line)
+                               if show_output:
+                                       print(line, end="")
+                               if return_output:
+                                       rtn.append(line.rstrip())
+                       except UnicodeDecodeError:
+                               if return_output:
+                                       rtn.append('DecodeError')
        if timerout.exit():
                raise exceptions.ProcessTimeout(process_name, rtn)
        rtncode = sprc.wait()