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: dd999bfe34 ("utils: rewrite ogReduceFs")
more_events
Jose M. Guisado 2023-06-13 17:24:41 +02:00
parent 88668cb195
commit 926a73cf33
1 changed files with 1 additions and 1 deletions

View File

@ -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}')