live: log message improvements for image creation and restore

Provide more context information for debugging issues with image creation and
restore.
master
OpenGnSys Support Team 2024-02-14 16:12:28 +01:00
parent 478c4447be
commit 6b1f20faf3
1 changed files with 12 additions and 6 deletions

View File

@ -164,7 +164,13 @@ class OgLiveOperations:
tip_client_get(repo, name) tip_client_get(repo, name)
except: except:
self._restartBrowser(self._url) self._restartBrowser(self._url)
raise ValueError('Error before restoring image') if (not os.path.exists(image_path)):
raise ValueError(f'Image file {image_path} does not exist')
if (not tip_check_csum(repo, name)):
raise ValueError(f'checksum file {name}.full.sum is missing in repository {repo}')
raise ValueError(f'Unexpected error when restoring image file {image_path}')
self._restore_image(image_path, devpath) self._restore_image(image_path, devpath)
def _restore_image(self, image_path, devpath): def _restore_image(self, image_path, devpath):
@ -432,13 +438,13 @@ class OgLiveOperations:
if pa is None: if pa is None:
self._restartBrowser(self._url) self._restartBrowser(self._url)
logging.error('Target partition not found') logging.error(f'Target partition /dev/{diskname} not found')
raise ValueError('Target partition number not found') raise ValueError(f'Target partition /dev/{diskname} not found')
padev = cxt.partition_to_string(pa, fdisk.FDISK_FIELD_DEVICE) padev = cxt.partition_to_string(pa, fdisk.FDISK_FIELD_DEVICE)
fstype = cxt.partition_to_string(pa, fdisk.FDISK_FIELD_FSTYPE) fstype = cxt.partition_to_string(pa, fdisk.FDISK_FIELD_FSTYPE)
if not fstype: if not fstype:
logging.error('No filesystem detected. Aborting image creation.') logging.error(f'No filesystem detected in {padev}. Aborting image creation.')
raise ValueError('Target partition has no filesystem present') raise ValueError('Target partition has no filesystem present')
if change_access(user=self._smb_user, pwd=self._smb_pass) == -1: if change_access(user=self._smb_user, pwd=self._smb_pass) == -1:
@ -454,7 +460,7 @@ class OgLiveOperations:
ogCopyEfiBootLoader(disk, partition) ogCopyEfiBootLoader(disk, partition)
if ogReduceFs(disk, partition) == -1: if ogReduceFs(disk, partition) == -1:
logging.error('Failed to shrink filesystem') logging.error(f'Failed to shrink {fstype} filesystem in {padev}')
raise ValueError('Failed to shrink filesystem') raise ValueError('Failed to shrink filesystem')
cmd1 = shlex.split(f'partclone.{fstype} -I -C --clone -s {padev} -O -') cmd1 = shlex.split(f'partclone.{fstype} -I -C --clone -s {padev} -O -')
@ -469,7 +475,7 @@ class OgLiveOperations:
p2 = Popen(cmd2, stdin=p1.stdout) p2 = Popen(cmd2, stdin=p1.stdout)
p1.stdout.close() p1.stdout.close()
logging.info(f'Running image creation process, please do not shut down or reboot the client') logging.info(f'Creating image at {image_path} from {padev} using {fstype}, please do not shut down or reboot the client')
try: try:
retdata = p2.communicate() retdata = p2.communicate()