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)
more_events
Jose M. Guisado 2022-09-29 13:24:43 +02:00
parent f2515fcde9
commit 55c76c9d70
1 changed files with 2 additions and 4 deletions

View File

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