Skip to content

Commit

Permalink
Merge pull request #20 from MagnusS/fix-utf8
Browse files Browse the repository at this point in the history
Replace utf-8 errors when decoding stdout
  • Loading branch information
MagnusS authored Apr 18, 2019
2 parents 9f52d08 + 27eb78b commit 4b89ee8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions vmrunner/vmrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def read_until_EOT(self):
def readline(self):
if self._proc.poll():
raise Exception("Process completed")
return self._proc.stdout.readline().decode("utf-8")
return self._proc.stdout.readline().decode("utf-8", errors="replace")


def writeline(self, line):
Expand Down Expand Up @@ -662,7 +662,7 @@ def read_until_EOT(self):
chars = ""

while (not self._proc.poll()):
char = self._proc.stdout.read(1).decode("utf-8")
char = self._proc.stdout.read(1).decode("utf-8", errors="replace")
if char == chr(4):
return chars
chars += char
Expand All @@ -673,7 +673,7 @@ def read_until_EOT(self):
def readline(self):
if self._proc.poll():
raise Exception("Process completed")
return self._proc.stdout.readline().decode("utf-8")
return self._proc.stdout.readline().decode("utf-8", errors="replace")


def writeline(self, line):
Expand Down Expand Up @@ -947,7 +947,7 @@ def boot(self, timeout = 60, multiboot = True, debug = False, kernel_args = "boo
try:
line = self._hyper.readline()
except Exception as e:
print(color.WARNING("Exception thrown while waiting for vm output"))
print(color.WARNING("Exception thrown while waiting for vm output: %s" % e))
break

if line and self.find_exit_status(line) == None:
Expand Down

0 comments on commit 4b89ee8

Please sign in to comment.