summaryrefslogtreecommitdiffstats
path: root/src/utils/image.py
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-05-27 16:26:48 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-05-30 17:22:23 +0200
commit914bd993fcb347a24d65e64ba838cb34f72ab14d (patch)
tree21ff8b3d62bac4b9a95cd51d254194ce450da3ce /src/utils/image.py
parent34007857f6b96eca02c510a8a4d8fce6d37fa8df (diff)
src: cleanup ogGetImageInfo
Rename ogGetImageInfo to get_image_info. Move code from ogOperations.py to obtain image data into get_image_info.
Diffstat (limited to 'src/utils/image.py')
-rw-r--r--src/utils/image.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/utils/image.py b/src/utils/image.py
index cdc79c9..a9ffb22 100644
--- a/src/utils/image.py
+++ b/src/utils/image.py
@@ -106,7 +106,7 @@ def run_lzop_partcloneinfo(image_path):
return p2_out
-def ogGetImageInfo(image_path):
+def get_image_info(image_path):
"""
Obtain filesystem and device size information of an OpenGnsys partition
image.
@@ -116,7 +116,7 @@ def ogGetImageInfo(image_path):
Returns an ImageInfo object.
- >>> image_info = ogGetImageInfo('/opt/opengnsys/images/foobar.img')
+ >>> image_info = get_image_info('/opt/opengnsys/images/foobar.img')
>>> image_info.filesystem
>>> 'NTFS'
>>> image_info.datasize
@@ -128,6 +128,15 @@ def ogGetImageInfo(image_path):
"""
partclone_output = run_lzop_partcloneinfo(image_path)
image_info = image_info_from_partclone(partclone_output)
+
+ try:
+ st = os.stat(image_path)
+ self.size = st.st_size
+ self.perms = st.st_mode & (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
+ self.mtime = int(st.st_mtime)
+ except:
+ logging.info(f'cannot retrieve stats from {image_path}')
+
return image_info