From 55c76c9d701b8a328dfd2bfb91f90d0a91c50d8f Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Thu, 29 Sep 2022 13:24:43 +0200 Subject: tiptorrent: improve raised exceptions for tip_client_get Raise exception when tiptorrent-client subprocess runs normally but exits with non-zero code. (For example, if download file allocation failed) --- src/utils/tiptorrent.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/utils') diff --git a/src/utils/tiptorrent.py b/src/utils/tiptorrent.py index 62feb43..25a3ab8 100644 --- a/src/utils/tiptorrent.py +++ b/src/utils/tiptorrent.py @@ -61,9 +61,6 @@ def tip_check_csum(tip_addr, image_name): def tip_client_get(tip_addr, image_name): """ - tiptorrent-client wrapper - - TODO: Check if CACHE partition is present """ logging.info(f'Fetching image {image_name} from tiptorrent server at {tip_addr}') cmd = f'tiptorrent-client {tip_addr} {image_name}.img' @@ -76,12 +73,13 @@ def tip_client_get(tip_addr, image_name): proc.communicate() except: logging.error('Exception when running tiptorrent client GET subprocess') - raise ValueError('Error: Incorrect command value') + raise ValueError('Unexpected error running tiptorrent subprocess') finally: logfile.close() if proc.returncode != 0: logging.error(f'Error fetching image {image_name} via tiptorrent') + raise ValueError('Tiptorrent download failed') else: logging.info('tiptorrent transfer completed, writing checksum') tip_write_csum(image_name) -- cgit v1.2.3-18-g5258