more internal state log, less info log
This commit is contained in:
parent
84ddfc718c
commit
734c8b7fe7
1 changed files with 31 additions and 11 deletions
|
|
@ -262,9 +262,9 @@ def worker(emu: str, apklist: queue.Queue[str], out_folder: Path, script: Path):
|
||||||
if (folder / "TIMEOUT").exists():
|
if (folder / "TIMEOUT").exists():
|
||||||
has_error = True
|
has_error = True
|
||||||
if has_error:
|
if has_error:
|
||||||
print(
|
# print(
|
||||||
f"Previous result for {apk=} found but with error of timeout, remove old result and rerun it"
|
# f"Previous result for {apk=} found but with error of timeout, remove old result and rerun it"
|
||||||
)
|
# )
|
||||||
shutil.rmtree(str(folder))
|
shutil.rmtree(str(folder))
|
||||||
else:
|
else:
|
||||||
# We already have a valid result, mark task done and skip xp
|
# We already have a valid result, mark task done and skip xp
|
||||||
|
|
@ -280,7 +280,7 @@ def worker(emu: str, apklist: queue.Queue[str], out_folder: Path, script: Path):
|
||||||
(folder / "analysis.err").open("w") as fp_anly_stderr,
|
(folder / "analysis.err").open("w") as fp_anly_stderr,
|
||||||
):
|
):
|
||||||
|
|
||||||
print(f"START ANALYSIS: {apk=}, emulator-{console_port}")
|
# print(f"START ANALYSIS: {apk=}, emulator-{console_port}")
|
||||||
|
|
||||||
# Reset the emulator and make sure it is runing
|
# Reset the emulator and make sure it is runing
|
||||||
i = 0
|
i = 0
|
||||||
|
|
@ -291,14 +291,16 @@ def worker(emu: str, apklist: queue.Queue[str], out_folder: Path, script: Path):
|
||||||
f"Warning: tried to start emulator-{console_port} (avd {emu}) for the {i}th time without success"
|
f"Warning: tried to start emulator-{console_port} (avd {emu}) for the {i}th time without success"
|
||||||
)
|
)
|
||||||
proc_emu = restore_emu(emu, proc_emu)
|
proc_emu = restore_emu(emu, proc_emu)
|
||||||
adb_run(
|
try:
|
||||||
f"emulator-{console_port}",
|
adb_run(
|
||||||
["wait-for-device"],
|
f"emulator-{console_port}", ["wait-for-device"], timeout=30
|
||||||
)
|
)
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
print(f"Wait for device emulator-{console_port} timedout")
|
||||||
j = 0
|
j = 0
|
||||||
while not started:
|
while not started:
|
||||||
started = f"emulator-{console_port}\tdevice" in subprocess.run(
|
started = f"emulator-{console_port}\tdevice" in subprocess.run(
|
||||||
[ADB, "devices"], stdout=subprocess.PIPE
|
[ADB, "devices"], stdout=subprocess.PIPE, timeout=30
|
||||||
).stdout.decode("utf-8")
|
).stdout.decode("utf-8")
|
||||||
if not started:
|
if not started:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
@ -311,7 +313,7 @@ def worker(emu: str, apklist: queue.Queue[str], out_folder: Path, script: Path):
|
||||||
j += 1
|
j += 1
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
print(f"emulator-{console_port} running")
|
# print(f"emulator-{console_port} running")
|
||||||
fp_anly_stdout.write(
|
fp_anly_stdout.write(
|
||||||
f"START ANALYSIS: {apk=}, emulator-{console_port}\n"
|
f"START ANALYSIS: {apk=}, emulator-{console_port}\n"
|
||||||
)
|
)
|
||||||
|
|
@ -320,6 +322,7 @@ def worker(emu: str, apklist: queue.Queue[str], out_folder: Path, script: Path):
|
||||||
[ADB, "devices"],
|
[ADB, "devices"],
|
||||||
stdout=fp_anly_stdout,
|
stdout=fp_anly_stdout,
|
||||||
stderr=fp_anly_stderr,
|
stderr=fp_anly_stderr,
|
||||||
|
timeout=30,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Run script
|
# Run script
|
||||||
|
|
@ -337,7 +340,7 @@ def worker(emu: str, apklist: queue.Queue[str], out_folder: Path, script: Path):
|
||||||
stderr=fp_anly_stderr,
|
stderr=fp_anly_stderr,
|
||||||
timeout=TIMEOUT,
|
timeout=TIMEOUT,
|
||||||
)
|
)
|
||||||
print(f"FINISHED ANALYSIS: {apk=}, emulator-{console_port}")
|
# print(f"FINISHED ANALYSIS: {apk=}, emulator-{console_port}")
|
||||||
# If timeout:
|
# If timeout:
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
with (folder / "TIMEOUT").open("w") as fp:
|
with (folder / "TIMEOUT").open("w") as fp:
|
||||||
|
|
@ -348,6 +351,23 @@ def worker(emu: str, apklist: queue.Queue[str], out_folder: Path, script: Path):
|
||||||
fp.write(f"Used emulator {emu}: emulator-{console_port}")
|
fp.write(f"Used emulator {emu}: emulator-{console_port}")
|
||||||
apklist.task_done()
|
apklist.task_done()
|
||||||
marked_done = True
|
marked_done = True
|
||||||
|
nb_emu_running = sum(
|
||||||
|
1
|
||||||
|
for _ in filter(
|
||||||
|
lambda s: "emulator-" in s,
|
||||||
|
subprocess.run(
|
||||||
|
[ADB, "devices"],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
)
|
||||||
|
.stdout.decode()
|
||||||
|
.split("\n"),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
f"[{datetime.datetime.now()}][{emu}(emulator-{console_port})] end loop, \
|
||||||
|
{len(list(threading.enumerate()))} threads running, \
|
||||||
|
{nb_emu_running} emulators running"
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = f"[{datetime.datetime.now()}] worker for {emu} (emulator-{console_port}) terminated after {e}"
|
msg = f"[{datetime.datetime.now()}] worker for {emu} (emulator-{console_port}) terminated after {e}"
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue