mirror of
https://github.com/clearml/wexpect-venv
synced 2025-01-31 10:57:07 +00:00
[FIX] remove bytes encoding: use str everywhere; [STS] cmd.py passes
This commit is contained in:
parent
42d508c916
commit
8b7042abd4
28
wexpect.py
28
wexpect.py
@ -1413,10 +1413,11 @@ class spawn_unix (object):
|
|||||||
if timeout < 0 and timeout is not None:
|
if timeout < 0 and timeout is not None:
|
||||||
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."""
|
||||||
@ -2874,7 +2862,7 @@ def join_args(args):
|
|||||||
commandline = []
|
commandline = []
|
||||||
for arg in args:
|
for arg in args:
|
||||||
if re.search('[\^!$%&()[\]{}=;\'+,`~\s]', arg):
|
if re.search('[\^!$%&()[\]{}=;\'+,`~\s]', arg):
|
||||||
arg = '"%s"' % arg
|
arg = '"%s"' % arg
|
||||||
commandline.append(arg)
|
commandline.append(arg)
|
||||||
return ' '.join(commandline)
|
return ' '.join(commandline)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user