allow to use local apks

This commit is contained in:
Jean-Marie Mineau 2025-09-05 10:33:10 +02:00
parent c66927898f
commit 1309d7ea24
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2

View file

@ -203,9 +203,17 @@ if __name__ == "__main__":
parser.add_argument( parser.add_argument(
"--task", help="[debug] Name of the task to perform", type=str, action="store" "--task", help="[debug] Name of the task to perform", type=str, action="store"
) )
parser.add_argument( app_group = parser.add_mutually_exclusive_group()
app_group.add_argument(
"--sha", help="[debug] sha to make the --task on", type=str, action="store" "--sha", help="[debug] sha to make the --task on", type=str, action="store"
) )
app_group.add_argument(
"--apk-path",
help="[debug] apk to make the --task on",
type=Path,
action="store",
)
group = parser.add_mutually_exclusive_group(required=True) group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("--docker", action="store_true") group.add_argument("--docker", action="store_true")
group.add_argument("--singularity", action="store_true") group.add_argument("--singularity", action="store_true")
@ -303,20 +311,26 @@ if __name__ == "__main__":
raise Exception("Debug mode must be used with BOTH --task and --sha") raise Exception("Debug mode must be used with BOTH --task and --sha")
task = args.task task = args.task
# sha = str(args.sha).upper() # TMP patch # sha = str(args.sha).upper() # TMP patch
sha = str(args.sha) # sha = str(args.sha)
if len(sha) != 64: if args.sha is not None and len(args.sha) != 64:
# raise Exception("invalid --sha value") # raise Exception("invalid --sha value")
print("invalid --sha value, exception disabled for tests") print("invalid --sha value, exception disabled for tests")
apk_blob = get_apk_from_androzoo( if args.sha is not None:
sha256=sha, apk_blob = get_apk_from_androzoo(
apikey=androzoo_apikey, sha256=args.sha,
base_url=androzoo_base_url, apikey=androzoo_apikey,
reraise=False, base_url=androzoo_base_url,
local_cache=androzoo_local_cache, reraise=False,
) local_cache=androzoo_local_cache,
if apk_blob is None: )
print(f"Unable to obtain apk for sha={sha}") sha = args.sha
if apk_blob is None:
print(f"Unable to obtain apk for sha={sha}")
else: else:
with args.apk_path.open("rb") as fp:
apk_blob = fp.read()
sha = args.apk_path.name.removesuffix(".apk") # no a sha, but good enough
if apk_blob is not None:
# do_one_job(sha256: str, tool_name: str, base_dir: str, apk_blob, container_mode, container_image, keep_tmp_dir=False): # do_one_job(sha256: str, tool_name: str, base_dir: str, apk_blob, container_mode, container_image, keep_tmp_dir=False):
res = do_one_job( res = do_one_job(
sha256=sha, sha256=sha,