extract_files.py fails because adb throws errors when called too quickly - patch included
Expected Behavior
Ideally adb shouldn't barf when called rapidly, but since it does, extract_files.py should work around it with a short delay.
Current Behavior
~/Projects/LineageOS/device/motorola/rtwo $ ./extract-files.py
Parsing device/motorola/rtwo/proprietary-firmware.txt
Parsing device/motorola/rtwo/proprietary-files-carriersettings.txt
Parsing device/motorola/rtwo/proprietary-files.txt
Parsing device/motorola/sm8550-common/proprietary-files.txt
Traceback (most recent call last):
File "/home/triffid/Projects/LineageOS/device/motorola/rtwo/./extract-files.py", line 61, in <module>
utils.run()
File "/home/triffid/Projects/LineageOS/tools/extract-utils/extract_utils/main.py", line 203, in run
with create_source(source_ctx, extract_ctx) as source:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "/home/triffid/Projects/LineageOS/tools/extract-utils/extract_utils/source.py", line 338, in create_source
yield AdbSource()
^^^^^^^^^^^
File "/home/triffid/Projects/LineageOS/tools/extract-utils/extract_utils/source.py", line 144, in __init__
self.__slot_suffix = self.__get_slot_suffix()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/triffid/Projects/LineageOS/tools/extract-utils/extract_utils/source.py", line 147, in __get_slot_suffix
return run_cmd(
^^^^^^^^
File "/home/triffid/Projects/LineageOS/tools/extract-utils/extract_utils/utils.py", line 126, in run_cmd
raise ValueError(s)
ValueError: Failed to run command "/usr/bin/adb shell getprop ro.boot.slot_suffix":
stdout:
stderr:
error: closed
~/Projects/LineageOS/device/motorola/rtwo [1] $ adb shell getprop ro.boot.slot_suffix
_b
I have android-tools-34.0.5 for Linux via Gentoo ebuild:
$ adb version
Android Debug Bridge version 1.0.41
Version 34.0.5-android-tools
Installed as /usr/bin/adb
Running on Linux 6.12.11-dorellan (x86_64)
Steps to Reproduce
Just have my phone plugged into USB3 and ran the script, and it reliably does this every single time
This works around whatever conniption ADB is having though:
diff --git a/extract_utils/utils.py b/extract_utils/utils.py
index 5def4c8..e83aaf3 100644
--- a/extract_utils/utils.py
+++ b/extract_utils/utils.py
@@ -9,6 +9,7 @@ import hashlib
import importlib.util
import os
import shutil
+import time
from contextlib import contextmanager
from enum import Enum
from functools import lru_cache
@@ -109,6 +110,7 @@ def executable_path(name: str) -> str:
def run_cmd(cmd: List[str], shell=False):
+ time.sleep(0.1)
cmd[0] = executable_path(cmd[0])
proc = run(
cmd,
Device information
/codename rtwo /version lineage-22.1 /date 2025-01-31 /kernel - /baseband - /mods
I have read read the directions.