oepydevshell-internal: python3: encode/decode pty content
As /dev/pty opened in binary mode its content has to be decoded when reading from it and encoded when writing to it. (From OE-Core rev: 211870ddbce5c966b2882e97cb2efe29b72a62a4) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
e8feb1976a
commit
94fb1a57de
|
@ -47,7 +47,7 @@ try:
|
||||||
# Need cbreak/noecho whilst in select so we trigger on any keypress
|
# Need cbreak/noecho whilst in select so we trigger on any keypress
|
||||||
cbreaknoecho(sys.stdin.fileno())
|
cbreaknoecho(sys.stdin.fileno())
|
||||||
# Send our PID to the other end so they can kill us.
|
# Send our PID to the other end so they can kill us.
|
||||||
pty.write(str(os.getpid()) + "\n")
|
pty.write(str(os.getpid()).encode('utf-8') + b"\n")
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
writers = []
|
writers = []
|
||||||
|
@ -56,7 +56,7 @@ try:
|
||||||
(ready, _, _) = select.select([pty, sys.stdin], writers , [], 0)
|
(ready, _, _) = select.select([pty, sys.stdin], writers , [], 0)
|
||||||
try:
|
try:
|
||||||
if pty in ready:
|
if pty in ready:
|
||||||
i = i + pty.read()
|
i = i + pty.read().decode('utf-8')
|
||||||
if i:
|
if i:
|
||||||
# Write a page at a time to avoid overflowing output
|
# Write a page at a time to avoid overflowing output
|
||||||
# d.keys() is a good way to do that
|
# d.keys() is a good way to do that
|
||||||
|
@ -65,9 +65,9 @@ try:
|
||||||
i = i[4096:]
|
i = i[4096:]
|
||||||
if sys.stdin in ready:
|
if sys.stdin in ready:
|
||||||
echonocbreak(sys.stdin.fileno())
|
echonocbreak(sys.stdin.fileno())
|
||||||
o = input()
|
o = input().encode('utf-8')
|
||||||
cbreaknoecho(sys.stdin.fileno())
|
cbreaknoecho(sys.stdin.fileno())
|
||||||
pty.write(o + "\n")
|
pty.write(o + b"\n")
|
||||||
except (IOError, OSError) as e:
|
except (IOError, OSError) as e:
|
||||||
if e.errno == 11:
|
if e.errno == 11:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue