Files
rk35xx-android14/system/apex/tools/apexer_wrapper_utils.py
T
hmz007 36ed224bac Rockchip Anroid14_SDK 20240628-rkr5 (2556df1a)
Signed-off-by: hmz007 <hmz007@gmail.com>
Change-Id: Ib87fdbe7a0be7dc961af3500fe9ea4589a127f9f
2024-10-29 18:12:02 +08:00

27 lines
663 B
Python

#!/usr/bin/env python3
import hashlib
import subprocess
def RunCommand(cmd: list[str]) -> None:
"""Construct a command line from parts and run it."""
try:
res = subprocess.run(
cmd,
check=True,
stdout=subprocess.PIPE,
universal_newlines=True,
stderr=subprocess.PIPE)
except subprocess.CalledProcessError as err:
print(err.stderr)
print(err.output)
raise err
def GetDigest(file_path: str) -> str:
"""Get sha512 digest of a file """
digester = hashlib.sha512()
with open(file_path, 'rb') as f:
bytes_to_digest = f.read()
digester.update(bytes_to_digest)
return digester.hexdigest()