[FIX] remove bytes encoding: use str everywhere; [STS] cmd.py passes

This commit is contained in:
Benedek Racz 2019-05-02 15:37:04 +02:00
parent 42d508c916
commit 8b7042abd4

View File

@ -1414,9 +1414,10 @@ class spawn_unix (object):
raise TIMEOUT ('Timeout exceeded in expect_any().')
# Still have time left, so read more data
c = self.read_nonblocking(self.maxread, timeout)
# c = c.decode("utf-8")
freshlen = len(c)
time.sleep (0.0001)
incoming = incoming + c
incoming += c
if timeout is not None:
timeout = end_time - time.time()
except EOF as e:
@ -1785,19 +1786,9 @@ class spawn_windows (spawn_unix, object):
This is a wrapper around Wtty.read(). """
if self.closed:
raise ValueError ('I/O operation on closed file in read_nonblocking().')
if timeout == -1:
timeout = self.timeout
@ -2228,11 +2219,8 @@ class Wtty:
strlist.append(c)
s = ''.join(strlist)
try:
return s.encode(str(self.codepage), 'replace')
except LookupError:
return s.encode(getattr(sys.stdout, 'encoding', None) or
sys.getdefaultencoding(), 'replace')
return s
def readConsoleToCursor(self):
"""Reads from the current read position to the current cursor
@ -2317,6 +2305,7 @@ class Wtty:
return s
def read_nonblocking(self, timeout, size):
"""Reads data from the console if available, otherwise
waits timeout seconds, and writes the string 'None'
@ -2348,8 +2337,6 @@ class Wtty:
end = time.clock()
timeout -= end - start
except Exception as e:
log(e)
log('End Of File (EOF) in Wtty.read_nonblocking().')
@ -2359,6 +2346,7 @@ class Wtty:
self.switchBack()
return s
def refreshConsole(self):
"""Clears the console after pausing the child and
reading all the data currently on the console."""