summaryrefslogtreecommitdiffstats
path: root/scripts/oepydevshell-internal.py
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-07-05 01:08:15 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-08 09:57:24 +0100
commit94fb1a57de022b5c35de53aeed0a1a089af26248 (patch)
tree770f2ae296c6eb23b474827689e3f4a00c4bbc73 /scripts/oepydevshell-internal.py
parente8feb1976a04d0a0850fc316cfff390d0569ec4a (diff)
downloadpoky-94fb1a57de022b5c35de53aeed0a1a089af26248.tar.gz
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>
Diffstat (limited to 'scripts/oepydevshell-internal.py')
-rwxr-xr-xscripts/oepydevshell-internal.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/scripts/oepydevshell-internal.py b/scripts/oepydevshell-internal.py
index 31a75ac29f..a22bec3365 100755
--- a/scripts/oepydevshell-internal.py
+++ b/scripts/oepydevshell-internal.py
@@ -47,7 +47,7 @@ try:
47 # Need cbreak/noecho whilst in select so we trigger on any keypress 47 # Need cbreak/noecho whilst in select so we trigger on any keypress
48 cbreaknoecho(sys.stdin.fileno()) 48 cbreaknoecho(sys.stdin.fileno())
49 # Send our PID to the other end so they can kill us. 49 # Send our PID to the other end so they can kill us.
50 pty.write(str(os.getpid()) + "\n") 50 pty.write(str(os.getpid()).encode('utf-8') + b"\n")
51 while True: 51 while True:
52 try: 52 try:
53 writers = [] 53 writers = []
@@ -56,7 +56,7 @@ try:
56 (ready, _, _) = select.select([pty, sys.stdin], writers , [], 0) 56 (ready, _, _) = select.select([pty, sys.stdin], writers , [], 0)
57 try: 57 try:
58 if pty in ready: 58 if pty in ready:
59 i = i + pty.read() 59 i = i + pty.read().decode('utf-8')
60 if i: 60 if i:
61 # Write a page at a time to avoid overflowing output 61 # Write a page at a time to avoid overflowing output
62 # d.keys() is a good way to do that 62 # d.keys() is a good way to do that
@@ -65,9 +65,9 @@ try:
65 i = i[4096:] 65 i = i[4096:]
66 if sys.stdin in ready: 66 if sys.stdin in ready:
67 echonocbreak(sys.stdin.fileno()) 67 echonocbreak(sys.stdin.fileno())
68 o = input() 68 o = input().encode('utf-8')
69 cbreaknoecho(sys.stdin.fileno()) 69 cbreaknoecho(sys.stdin.fileno())
70 pty.write(o + "\n") 70 pty.write(o + b"\n")
71 except (IOError, OSError) as e: 71 except (IOError, OSError) as e:
72 if e.errno == 11: 72 if e.errno == 11:
73 continue 73 continue