summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/utils/legacy.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/utils/legacy.py b/src/utils/legacy.py
index 51d98f3..6e191fc 100644
--- a/src/utils/legacy.py
+++ b/src/utils/legacy.py
@@ -50,14 +50,13 @@ def fill_imageinfo(line, image_info):
image_info.datasize = device_size
-def process_output_partcloneinfo(output):
+def image_info_from_partclone(partclone_output):
"""
- Parses image information from partclone.info output.
-
- Returns an ImageInfo object.
+ Return an ImageInfo object from partclone.info output.
"""
image_info = ImageInfo()
- for n, line in enumerate(output.split('\n')):
+ for n, line in enumerate(partclone_output.split('\n')):
+ # Ignore first two lines of partclone.info output
if n < 2:
continue
if image_info.datasize and image_info.filesystem:
@@ -72,14 +71,14 @@ def process_output_partcloneinfo(output):
return image_info
-def process_image_partcloneinfo(filename):
+def run_lzop_partcloneinfo(image_path):
"""
- Decompress using lzop and executes partclone.info to
- fetch a partition image's information.
+ Run lzop to decompress an OpenGnsys partition image, feed
+ lzop output to a partclone.info subprocess.
- Returns partclone.info stdout and stderr.
+ Return the partclone.info subprocess output.
"""
- cmd1 = f'{shutil.which("lzop")} -dc {filename}'
+ cmd1 = f'{shutil.which("lzop")} -dc {image_path}'
cmd2 = f'{shutil.which("partclone.info")} -s -'
args1 = shlex.split(cmd1)
args2 = shlex.split(cmd2)
@@ -90,12 +89,12 @@ def process_image_partcloneinfo(filename):
p2_out, p2_err = p2.communicate()
if p2.returncode != 0:
- raise ValueError('Unable to process image {filename}')
+ raise ValueError('Unable to process image {image_path}')
return p2_out
-def ogGetImageInfo(filename):
+def ogGetImageInfo(image_path):
"""
Obtain filesystem and device size information of an OpenGnsys partition
image.
@@ -115,8 +114,8 @@ def ogGetImageInfo(filename):
>>> image_info.clonator
>>> 'PARTCLONE'
"""
- out = process_image_partcloneinfo(filename)
- image_info = process_output_partcloneinfo(out)
+ partclone_output = run_lzop_partcloneinfo(image_path)
+ image_info = image_info_from_partclone(partclone_output)
return image_info