summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdaemon/targetclid15
1 files changed, 9 insertions, 6 deletions
diff --git a/daemon/targetclid b/daemon/targetclid
index d4c6562..5df6ca2 100755
--- a/daemon/targetclid
+++ b/daemon/targetclid
@@ -32,9 +32,13 @@ import struct
import fcntl
import signal
import errno
-import io
+if sys.version_info < (3, 0):
+ from io import BytesIO as StringIO
+else:
+ from io import StringIO
+
err = sys.stderr
class TargetCLI:
@@ -154,24 +158,23 @@ class TargetCLI:
connection.close()
still_listen = False
else:
- self.con._stdout = self.con._stderr = f = io.BytesIO()
+ self.con._stdout = self.con._stderr = f = StringIO()
try:
# extract multiple commands delimited with '%'
list_data = data.decode().split('%')
for cmd in list_data:
self.shell.run_cmdline(cmd)
except Exception as e:
- print(str(e), file=f) # push error to stream
+ print(str(e).encode(), file=f) # push error to stream
# Restore
self.con._stdout = self.con_stdout_
self.con._stderr = self.con_stderr_
-
- output = f.getvalue()
+ output = f.getvalue().encode()
var = struct.pack('i', len(output))
connection.sendall(var) # length of string
if len(output):
- connection.sendall(output.encode()) # actual string
+ connection.sendall(output) # actual string
f.close()