refs #1101 improve ogGetImageInfo() a bit

code-review
Natalia Serrano 2024-11-12 12:02:25 +01:00
parent 38cb5ab986
commit e8f7996470
1 changed files with 16 additions and 5 deletions

View File

@ -214,6 +214,7 @@ def ogGetImageInfo (imgfile):
os.environ['LC_ALL'] = 'C'
partclone_info = subprocess.run (['partclone.info', filehead], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True).stdout
#partclone_info = subprocess.run (['cat', '/tmp/foo-partclone'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True).stdout
## sacado de un email de alberto garcía uma.es
#Partclone v0.3.13 http://partclone.org
#Unknown mode
#File system: NTFS
@ -254,22 +255,34 @@ def ogGetImageInfo (imgfile):
if False == imgdetect and not os.path.exists ('/dev/loop2'):
filehead_contents = Path (filehead).read_bytes()
ntfscloneinfo = ''
if b'ntfsclone-image' in filehead_contents:
print (f'shelling out "cat {filenead} | ntfsclone --restore --overwrite /dev/loop2 - 2>&1"')
ntfscloneinfo = subprocess.run (f'cat {filenead} | ntfsclone --restore --overwrite /dev/loop2 - 2>&1', shell=True, capture_output=True, text=True).stdout
#ntfscloneinfo = subprocess.run (['cat', '/tmp/foo-ntfsclone'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True).stdout
## sacado de claude 3 haiku
#ntfsclone v2023.4.0 (libntfs-3g)
#NTFS volume version: 3.1
#Cluster size: 4096 bytes
#Image volume size: 104857600 bytes (105 MB)
#Space in use: 52428800 bytes (52 MB)
#Reading and restoring NTFS...
#100.00 percent completed
#Syncing ...
#Successfully cloned image to device '/dev/loop2'.
else:
ntfscloneinfo = ''
if 'ntfsclone' in ntfscloneinfo:
tools = 'NTFSCLONE'
m = re.search (r'__TODO__ *: *(\S+)', ntfscloneinfo) ## TODO
size = 42 #float (m.group(1))/1000 if m else 0 ## TODO
m = re.search (r'Image volume size *: *(\S+)', ntfscloneinfo)
size = float (m.group(1))/1000 if m else 0
fs = 'NTFS'
imgdetect = True
if False == imgdetect:
partimageinfo = subprocess.run (['partimage', '-B', 'gui=no', 'imginfo', filehead], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True).stdout
#partimageinfo = subprocess.run (['cat', '/tmp/foo-partimage'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True).stdout
## sacado de un email de alberto garcía uma.es
#Volume number:.........0
#Volume size:...........1,27 MiB
#Compression level: ....0 -> ninguno
@ -285,9 +298,7 @@ def ogGetImageInfo (imgfile):
#Compatible Version:....0.6.1
#Encryption algorithm:..0 -> ninguno
#MBR saved count:.......0
print (f'partimageinfo bef ({partimageinfo})')
partimageinfo = re.sub (r':\s*\.+', ' : ', partimageinfo)
print (f'partimageinfo aft ({partimageinfo})')
if 'Partition' in partimageinfo:
tools = 'PARTIMAGE'
m = re.search (r'Filesystem *: *(\S+)', partimageinfo)