From 926a73cf33896ae62f8255a8f2aca2e0d9a54038 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Tue, 13 Jun 2023 17:24:41 +0200 Subject: fs: fix subprocess input inside _extend_resize2fs The subprocess module expects bytes-like object for "input" parameter by default. Passing a string object result in the following error: (2023-06-13 14:44:43) ogClient: [ERROR] - Exception when running "image create" subprocess (2023-06-13 14:44:43) ogClient: [ERROR] - Unexpected error Traceback (most recent call last): File "/opt/opengnsys/ogClient/src/live/ogOperations.py", line 465, in image_create ogExtendFs(disk, partition) File "/opt/opengnsys/ogClient/src/utils/fs.py", line 124, in ogExtendFs _extend_ntfsresize(partdev) File "/opt/opengnsys/ogClient/src/utils/fs.py", line 250, in _extend_ntfsresize proc = subprocess.run(cmd, input='y') File "/usr/lib/python3.8/subprocess.py", line 495, in run stdout, stderr = process.communicate(input, timeout=timeout) File "/usr/lib/python3.8/subprocess.py", line 1013, in communicate self._stdin_write(input) File "/usr/lib/python3.8/subprocess.py", line 962, in _stdin_write self.stdin.write(input) TypeError: a bytes-like object is required, not 'str' Fixes: dd999bfe34e7 ("utils: rewrite ogReduceFs") --- src/utils/fs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/utils/fs.py b/src/utils/fs.py index 4d54586..57e6674 100644 --- a/src/utils/fs.py +++ b/src/utils/fs.py @@ -250,6 +250,6 @@ def _extend_resize2fs(partdev): def _extend_ntfsresize(partdev): cmd = shlex.split(f'ntfsresize -f {partdev}') - proc = subprocess.run(cmd, input='y') + proc = subprocess.run(cmd, input=b'y') if proc.returncode != 0: raise RuntimeError(f'Error growing ntfs filesystem at {partdev}') -- cgit v1.2.3-18-g5258