回复: [PATCH 1/2] nfstest: python3: fix rexec error while calling self.process.stdin.write

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



And CC Jorge Mora. I can not found other mailing list about nfstest so I guess it's linux-nfs.
Sorry if those patches bother you nfs folks.

--
Su

________________________________________
发件人: Su, Yue/苏 越
发送时间: 2021年8月6日 10:47
收件人: linux-nfs@xxxxxxxxxxxxxxx
主题:  [PATCH 1/2] nfstest: python3: fix rexec error while calling self.process.stdin.write

While running nfstest_delegation of nfstest in v3.0:

  $ ./nfstest_delegation --nfsversion=4.2 -e /nfsroot \
      --server 192.168.220.184 --client 192.168.220.107
  Traceback (most recent call last):
    File "./nfstest_delegation", line 1666, in <module>
      x = DelegTest(usage=USAGE, testnames=TESTNAMES, testgroups=TESTGROUPS, sid=SCRIPT_ID)
    File "./nfstest_delegation", line 363, in __init__
      self.create_rexec(client_name)
    File "/root/nfstest/nfstest/test_util.py", line 1370, in create_rexec
      self.rexecobj = Rexec(servername, **kwds)
    File "/root/nfstest/nfstest/rexec.py", line 295, in __init__
      self.process.stdin.write(server_code)
  TypeError: a bytes-like object is required, not 'str'

In python3, self.process.stdin.write() only accepts a bytes-like
object not 'str'.
Fix it by calling server_code.encode() and self.process.stdin.flush().

Signed-off-by: Su Yue <suy.fnst@xxxxxxxxxxx>
---
 nfstest/rexec.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/nfstest/rexec.py b/nfstest/rexec.py
index fa941b6..51586c5 100644
--- a/nfstest/rexec.py
+++ b/nfstest/rexec.py
@@ -292,7 +292,8 @@ class Rexec(BaseObj):
                 self.process = Popen(" ".join(cmdlist), shell=True, stdin=PIPE)

             # Send the server code to be executed via standard input
-            self.process.stdin.write(server_code)
+            self.process.stdin.write(server_code.encode())
+            self.process.stdin.flush()

         # Connect to remote server
         etime = time.time() + 5.0
--
2.30.1 (Apple Git-130)




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux