From: Kefu Chai Date: Fri, 1 May 2020 08:52:41 +0000 (+0800) Subject: qa/tasks/qemu: open file in text mode X-Git-Tag: v15.2.4~42^2~95 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4b2ec7930c9fe1e14a7ca8fbb794a5c34508c8a5;p=ceph.git qa/tasks/qemu: open file in text mode in python3, if a file is opened in 'rb' mode, we will have bytes when reading from it, as a result, we have following failure like: ``` Traceback (most recent call last): File "/home/teuthworker/src/git.ceph.com_git_teuthology_master/teuthology/contextutil.py", line 32, in nested vars.append(enter()) File "/usr/lib/python3.6/contextlib.py", line 81, in __enter__ return next(self.gen) File "/home/teuthworker/src/github.com_tchaikov_ceph_nautilus-py3/qa/tasks/qemu.py", line 124, in generate_iso test_setup = ''.join(f.readlines()) TypeError: sequence item 0: expected str instance, bytes found ``` Signed-off-by: Kefu Chai (cherry picked from commit 0b21c597d438fcba43629d0795b2d4ff6112c9cf) --- diff --git a/qa/tasks/qemu.py b/qa/tasks/qemu.py index 0b77ff5d310f..d85eff38945d 100644 --- a/qa/tasks/qemu.py +++ b/qa/tasks/qemu.py @@ -122,7 +122,7 @@ def generate_iso(ctx, config): userdata_path = os.path.join(testdir, 'qemu', 'userdata.' + client) metadata_path = os.path.join(testdir, 'qemu', 'metadata.' + client) - with open(os.path.join(src_dir, 'userdata_setup.yaml'), 'rb') as f: + with open(os.path.join(src_dir, 'userdata_setup.yaml')) as f: test_setup = ''.join(f.readlines()) # configuring the commands to setup the nfs mount mnt_dir = "/export/{client}".format(client=client) @@ -130,7 +130,7 @@ def generate_iso(ctx, config): mnt_dir=mnt_dir ) - with open(os.path.join(src_dir, 'userdata_teardown.yaml'), 'rb') as f: + with open(os.path.join(src_dir, 'userdata_teardown.yaml')) as f: test_teardown = ''.join(f.readlines()) user_data = test_setup