diff options
Diffstat (limited to 'src/utils/legacy.py')
-rw-r--r-- | src/utils/legacy.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/utils/legacy.py b/src/utils/legacy.py index e740450..cdc79c9 100644 --- a/src/utils/legacy.py +++ b/src/utils/legacy.py @@ -16,6 +16,7 @@ import shutil from subprocess import PIPE, DEVNULL, STDOUT, CalledProcessError from src.utils.fs import umount +from src.log import OgError class ImageInfo: @@ -75,9 +76,9 @@ def image_info_from_partclone(partclone_output): fill_imageinfo(line, image_info) if not image_info.datasize: - raise ValueError("Missing device size from partclone.info output") + raise OgError("Missing device size from partclone.info output") elif not image_info.filesystem: - raise ValueError("Missing filesystem from partclone.info output") + raise OgError("Missing filesystem from partclone.info output") return image_info @@ -100,7 +101,7 @@ def run_lzop_partcloneinfo(image_path): p2_out, p2_err = p2.communicate() if p2.returncode != 0: - raise ValueError(f'Unable to process image {image_path}') + raise OgError(f'Unable to process image {image_path}') return p2_out @@ -174,7 +175,7 @@ def ogChangeRepo(ip, smb_user='opengnsys', smb_pass='og'): try: ipaddr = ipaddress.ip_address(ip) except ValueError as e: - raise ValueError(f'Invalid IP address {ip} received') + raise OgError(f'Invalid IP address {ip} received') from e mounted = False with open('/etc/mtab') as f: @@ -209,7 +210,7 @@ def restoreImageCustom(repo_ip, image_name, disk, partition, method): """ """ if not shutil.which('restoreImageCustom'): - raise OSError('restoreImageCustom not found') + raise OgError('restoreImageCustom not found') cmd = f'restoreImageCustom {repo_ip} {image_name} {disk} {partition} {method}' with open('/tmp/command.log', 'wb', 0) as logfile: @@ -220,7 +221,7 @@ def restoreImageCustom(repo_ip, image_name, disk, partition, method): shell=True, check=True) except OSError as e: - raise OSError(f'Error processing restoreImageCustom: {e}') from e + raise OgError(f'Error processing restoreImageCustom: {e}') from e return proc.returncode @@ -240,6 +241,6 @@ def configureOs(disk, partition): check=True) out = proc.stdout except OSError as e: - raise OSError(f'Error processing configureOsCustom: {e}') from e + raise OgError(f'Error processing configureOsCustom: {e}') from e return out |