From 71c377ccb981e6eeebf9f61a0a24f26d0f242190 Mon Sep 17 00:00:00 2001 From: xpamych Date: Sun, 14 May 2023 16:22:39 +0300 Subject: [PATCH] 1 --- hlna.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/hlna.py b/hlna.py index d191582..62cbc71 100755 --- a/hlna.py +++ b/hlna.py @@ -24,9 +24,11 @@ logging.basicConfig(stream=sys.stderr, level=logging.CRITICAL) class UnpackException(Exception): pass + class SignatureUnpackException(UnpackException): pass + class CorruptUnpackException(UnpackException): pass @@ -62,7 +64,7 @@ def path_server(): def hlna(): pass -def arkit(src, dst): +def unpack(src, dst): with open(src, 'rb') as f: sigver = struct.unpack('q', f.read(8))[0] unpacked_chunk = f.read(8) @@ -116,14 +118,14 @@ def arkit(src, dst): msg = f"Uncompressed chunk size is not the same as in the index: was {len(uncompressed_data)} but should be {uncompressed}." logging.critical(msg) raise CorruptUnpackException(msg) - else: - msg = f"Data types in the headers should be int's. Size Types: unpacked_chunk({type(size_unpacked_chunk)}), packed({type(size_packed)}), unpacked({type(size_unpacked)})" - logging.critical(msg) - raise CorruptUnpackException(msg) else: - msg = "The signature and format version is incorrect. Signature was {} should be 2653586369.".format(sigver) + msg = f"Data types in the headers should be int's. Size Types: unpacked_chunk({type(size_unpacked_chunk)}), packed({type(size_packed)}), unpacked({type(size_unpacked)})" logging.critical(msg) - raise SignatureUnpackException(msg) + raise CorruptUnpackException(msg) + else: + msg = "The signature and format version is incorrect. Signature was {} should be 2653586369.".format(sigver) + logging.critical(msg) + raise SignatureUnpackException(msg) #Write the extracted data to disk with open(dst, 'wb') as f: @@ -489,12 +491,12 @@ def modextract(id_mod, id_game_workshop): src = os.path.join(curdir, file) dst = os.path.join(curdir, name) uncompressed = os.path.join(curdir, file + ".uncompressed_size") - arkit.unpack(src, dst) + unpack(src, dst) #print("[+] Extracted " + file) os.remove(src) if os.path.isfile(uncompressed): os.remove(uncompressed) - except (arkit.UnpackException, arkit.SignatureUnpackException, arkit.CorruptUnpackException) as e: + except (UnpackException, SignatureUnpackException, CorruptUnpackException) as e: print("[x] Unpacking .z files failed, aborting mod install") return False