From 3bc04840925e9af10be20e6659710146b5194c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=81=E6=99=9F?= Date: Wed, 14 Aug 2024 09:35:27 +0000 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=BE=93=E5=85=A5=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8ISO=E6=A0=BC=E5=BC=8F=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/isocheck.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/utils/isocheck.py b/src/utils/isocheck.py index 2571c34..f829481 100644 --- a/src/utils/isocheck.py +++ b/src/utils/isocheck.py @@ -13,6 +13,7 @@ # ********************************************************************************** """ import os +import pycdlib ERROR_INFO={ 1001:"The ISO path does not exist. Please check if the entered ISO path is correct.", @@ -30,8 +31,25 @@ class IsoCheck(object): return True def check_format(self): - pass - + try: + iso = pycdlib.PyCdlib() + iso.open(self.path) + os_dirs = [ + 'repodata', + ] + found_dirs = set() + for dirpath, dirnames, filenames in iso.walk(iso_path='/'): + dirname = dirpath.strip('/').lower() + if dirname in os_dirs: + found_dirs.add(dirname) + else: + continue + iso.close() + return True if found_dirs == set(os_dirs) else False + except Exception as e: + print("Error checking ISO: {}".format(str(e))) + return False + @classmethod def check(cls,iso_path): obj = cls(iso_path) -- Gitee