1
This commit is contained in:
parent
9c861b2e13
commit
71c377ccb9
20
hlna.py
20
hlna.py
@ -24,9 +24,11 @@ logging.basicConfig(stream=sys.stderr, level=logging.CRITICAL)
|
|||||||
class UnpackException(Exception):
|
class UnpackException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SignatureUnpackException(UnpackException):
|
class SignatureUnpackException(UnpackException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CorruptUnpackException(UnpackException):
|
class CorruptUnpackException(UnpackException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -62,7 +64,7 @@ def path_server():
|
|||||||
def hlna():
|
def hlna():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def arkit(src, dst):
|
def unpack(src, dst):
|
||||||
with open(src, 'rb') as f:
|
with open(src, 'rb') as f:
|
||||||
sigver = struct.unpack('q', f.read(8))[0]
|
sigver = struct.unpack('q', f.read(8))[0]
|
||||||
unpacked_chunk = f.read(8)
|
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}."
|
msg = f"Uncompressed chunk size is not the same as in the index: was {len(uncompressed_data)} but should be {uncompressed}."
|
||||||
logging.critical(msg)
|
logging.critical(msg)
|
||||||
raise CorruptUnpackException(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:
|
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)
|
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
|
#Write the extracted data to disk
|
||||||
with open(dst, 'wb') as f:
|
with open(dst, 'wb') as f:
|
||||||
@ -489,12 +491,12 @@ def modextract(id_mod, id_game_workshop):
|
|||||||
src = os.path.join(curdir, file)
|
src = os.path.join(curdir, file)
|
||||||
dst = os.path.join(curdir, name)
|
dst = os.path.join(curdir, name)
|
||||||
uncompressed = os.path.join(curdir, file + ".uncompressed_size")
|
uncompressed = os.path.join(curdir, file + ".uncompressed_size")
|
||||||
arkit.unpack(src, dst)
|
unpack(src, dst)
|
||||||
#print("[+] Extracted " + file)
|
#print("[+] Extracted " + file)
|
||||||
os.remove(src)
|
os.remove(src)
|
||||||
if os.path.isfile(uncompressed):
|
if os.path.isfile(uncompressed):
|
||||||
os.remove(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")
|
print("[x] Unpacking .z files failed, aborting mod install")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user