summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2022-09-29 13:24:43 +0200
committerJose M. Guisado <jguisado@soleta.eu>2022-09-29 13:24:43 +0200
commit55c76c9d701b8a328dfd2bfb91f90d0a91c50d8f (patch)
tree46ed706bf9b83e9724c8a0181fa1755cdcb3d9e5 /src
parentf2515fcde9d6c0e6aa2069afe3bf5ceb6fc5022f (diff)
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)
Diffstat (limited to 'src')
-rw-r--r--src/utils/tiptorrent.py6
1 files changed, 2 insertions, 4 deletions
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)