Skip to content

Commit

Permalink
feat[archive]check reader result
Browse files Browse the repository at this point in the history
  • Loading branch information
serfend committed Aug 5, 2023
1 parent 3e56b87 commit 1ba00b7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pydumpck/py_common_dump/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from PyInstaller.utils.cliutils.archive_viewer import ArchiveViewer

import sys
from PyInstaller.archive.readers import CArchiveReader, ZlibArchiveReader
from PyInstaller.archive.readers import CArchiveReader, ZlibArchiveReader,ArchiveReadError
from sgtpyutils.logger import logger


Expand All @@ -22,7 +22,15 @@ def get_archive(filename: str):
recursive_mode=False,
brief_mode=True)
arch = None
arch = viewer._open_toplevel_archive(filename)
msg = f'fail while extract archive file:{filename}.'
try:
arch = viewer._open_toplevel_archive(filename)
except ArchiveReadError as ex:
logger.error(f'{msg}make sure your file is a valid archive-python file instead of orgin-exe or others.{ex}')
sys.exit(-10010)
except Exception as ex:
logger.error(f'{msg}{ex}')
sys.exit(-10011)
return arch
archive_name = os.path.basename(viewer.filename)
viewer.stack.append((archive_name, arch))
Expand Down

0 comments on commit 1ba00b7

Please sign in to comment.