Skip to content

Commit 4ee2ec0

Browse files
author
Satheesh Rajendran
committed
Fixup python3: handle kickstart file read/write
Let's fix below errors by reading and writing with proper decode/encode. File "/home/bala/op-test-framework/common/OpTestInstallUtil.py", line 548, in do_GET self.wfile.write(ps) File "/usr/lib64/python3.6/socketserver.py", line 803, in write self._sock.sendall(b) TypeError: a bytes-like object is required, not 'str' --- File "/home/bala/op-test-framework/common/OpTestInstallUtil.py", line 527, in do_GET ps = d.format(REPO, PROXY, PASSWORD, DISK, DISK, DISK).encode() AttributeError: 'bytes' object has no attribute 'format' Reported-by: Balamuruhan S <[email protected]> Signed-off-by: Balamuruhan S <[email protected]> Signed-off-by: Satheesh Rajendran <[email protected]>
1 parent 7c3dadf commit 4ee2ec0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

common/OpTestInstallUtil.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,8 @@ def do_GET(self):
519519
f.close()
520520
return
521521
elif self.path == "/%s" % KS:
522-
f = open("%s/%s" % (BASE_PATH, KS), "r")
523-
d = f.read()
522+
f = open("%s/%s" % (BASE_PATH, KS), "rb")
523+
d = f.read().decode()
524524
if "hostos" in BASE_PATH:
525525
ps = d.format(REPO, PROXY, PASSWORD, DISK, DISK, DISK)
526526
elif "rhel" in BASE_PATH:
@@ -545,7 +545,7 @@ def do_GET(self):
545545
PROXY, PASSWORD, PASSWORD, user, PASSWORD, PASSWORD, DISK, packages)
546546
else:
547547
print("unknown distro")
548-
self.wfile.write(ps)
548+
self.wfile.write(ps.encode())
549549
return
550550
else:
551551
self.send_response(404)

0 commit comments

Comments
 (0)