From 478c4447be20380c5b173f8e150d2373cf6d021b Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Wed, 14 Feb 2024 12:20:46 +0100 Subject: src: improve error check in image_create and image_restore cover more error cases where exceptions need to be raised. check return code in the invoked subprocess. restoreImageCustom has been intentionally left behind, it is unclear what this custom script returns on success and error. --- src/live/ogOperations.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/live/ogOperations.py') diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py index e19a788..b24a23c 100644 --- a/src/live/ogOperations.py +++ b/src/live/ogOperations.py @@ -441,7 +441,9 @@ class OgLiveOperations: logging.error('No filesystem detected. Aborting image creation.') raise ValueError('Target partition has no filesystem present') - cambiar_acceso(user=self._smb_user, pwd=self._smb_pass) + if change_access(user=self._smb_user, pwd=self._smb_pass) == -1: + logging.error('remount of /opt/opengnsys/images has failed') + raise AssertionError('remount of /opt/opengnsys/images has failed') if os.access(f'/opt/opengnsys/images', os.R_OK | os.W_OK) == False: logging.error('Cannot access /opt/opengnsys/images in read and write mode, check permissions') @@ -451,7 +453,9 @@ class OgLiveOperations: logging.info(f'image file {image_path} already exists, updating.') ogCopyEfiBootLoader(disk, partition) - ogReduceFs(disk, partition) + if ogReduceFs(disk, partition) == -1: + logging.error('Failed to shrink filesystem') + raise ValueError('Failed to shrink filesystem') cmd1 = shlex.split(f'partclone.{fstype} -I -C --clone -s {padev} -O -') cmd2 = shlex.split(f'lzop -1 -fo {image_path}') -- cgit v1.2.3-18-g5258