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