Blame SOURCES/0002-Use-StringIO-as-a-buffer-instead-of-a-file.patch

a135b2
From 3db75315b7e436e57943efb132f7b331a7a7744c Mon Sep 17 00:00:00 2001
a135b2
From: Matt Coleman <matt@datto.com>
a135b2
Date: Thu, 7 Nov 2019 18:21:32 -0500
a135b2
Subject: [PATCH] Use StringIO as a buffer instead of a file
a135b2
a135b2
---
a135b2
 daemon/targetclid | 17 +++++++++--------
a135b2
 1 file changed, 9 insertions(+), 8 deletions(-)
a135b2
a135b2
diff --git a/daemon/targetclid b/daemon/targetclid
a135b2
index fb472dc..dfc22ce 100755
a135b2
--- a/daemon/targetclid
a135b2
+++ b/daemon/targetclid
a135b2
@@ -32,6 +32,7 @@ import struct
a135b2
 import fcntl
a135b2
 import signal
a135b2
 import errno
a135b2
+import io
a135b2
 
a135b2
 
a135b2
 err = sys.stderr
a135b2
@@ -153,7 +154,7 @@ class TargetCLI:
a135b2
                 connection.close()
a135b2
                 still_listen = False
a135b2
             else:
a135b2
-                self.con._stdout = self.con._stderr = f = open("/tmp/data.txt", "w")
a135b2
+                self.con._stdout = self.con._stderr = f = io.StringIO()
a135b2
                 try:
a135b2
                     # extract multiple commands delimited with '%'
a135b2
                     list_data = data.decode().split('%')
a135b2
@@ -165,14 +166,14 @@ class TargetCLI:
a135b2
                 # Restore
a135b2
                 self.con._stdout = self.con_stdout_
a135b2
                 self.con._stderr = self.con_stderr_
a135b2
-                f.close()
a135b2
 
a135b2
-                with open('/tmp/data.txt', 'r') as f:
a135b2
-                    output = f.read()
a135b2
-                    var = struct.pack('i', len(output))
a135b2
-                    connection.sendall(var) # length of string
a135b2
-                    if len(output):
a135b2
-                        connection.sendall(output.encode()) # actual string
a135b2
+                output = f.getvalue()
a135b2
+                var = struct.pack('i', len(output))
a135b2
+                connection.sendall(var) # length of string
a135b2
+                if len(output):
a135b2
+                    connection.sendall(output.encode()) # actual string
a135b2
+
a135b2
+                f.close()
a135b2
 
a135b2
 
a135b2
 def usage():
a135b2
-- 
a135b2
2.21.0
a135b2