Skip to content

Commit

Permalink
add magic
Browse files Browse the repository at this point in the history
  • Loading branch information
nazunalika committed Nov 15, 2024
1 parent a4d6899 commit f268502
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions iso/empanadas/empanadas/util/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import productmd.treeinfo
import productmd.composeinfo
import pycdlib
import magic
import empanadas
import kobo.shortcuts
from empanadas.common import Color
Expand Down Expand Up @@ -1342,6 +1343,19 @@ def is_image(k):

return False

@staticmethod
def get_magic(m):
"""
Gets magic data of a given file
"""
try:
meta = magic.detect_from_filename(m)
except ValueError as exc:
print(exc)
return False

return meta

@staticmethod
def get_vol_id(i):
"""
Expand All @@ -1353,6 +1367,14 @@ def get_vol_id(i):
except pycdlib.pycdlibexception.PyCdlibInvalidISO as exc:
print(exc)
return False
# This is for s390x. a temporary hack
except pycdlib.pycdlibexception.PyCdlibInvalidInput as exc:
print(exc)
print('Trying magic instead')
magic_data = Idents.get_magic(i)
if magic_data.mime_type == 'application/x-iso9660-image':
volume_id = magic_data.name.split("'")[1]
return volume_id

pvd = iso.pvd
volume_id = pvd.volume_identifier.decode('UTF-8').strip()
Expand Down

0 comments on commit f268502

Please sign in to comment.