Catalog PyPI
PACKAGE EXPLORERView in registry

adbshellexecuter

PyPI

A class to execute ADB (Android Debug Bridge) commands on multiple operating systems.

adbandroid
Versions collected1
Direct dependencies2From release 0.12
Last observed20 Oct, 19:13 UTC

README

Version 0.12 documentation

A class to execute ADB (Android Debug Bridge) commands on multiple operating systems.

Tested against Windows 10/Android/Linux / Python 3.11 / Anaconda

pip install adbshellexecuter


A class to execute ADB (Android Debug Bridge) commands on multiple operating systems.

This class provides methods to run ADB commands with and without capturing stdout and stderr,
as well as creating non-blocking subprocesses. It handles different operating system environments
such as Windows, Linux, macOS, and Android, providing a unified interface for ADB command execution.
Òn Android, the "adb shell" part is completely ignored, instead a subshell (sh) is used to execute commands

Args:
    adb_path (str): The path to the adb executable.
    device_serial (str): The serial number of the device.
    standard_kwargs_windows (tuple): Standard kwargs for Windows.
    standard_kwargs_linux (tuple): Standard kwargs for Linux.
    standard_kwargs_darwin (tuple): Standard kwargs for macOS.
    standard_kwargs_android (tuple): Standard kwargs for Android.
# Example usage
import shutil
from adbshellexecuter import UniversalADBExecutor
device_serial = "127.0.0.1:5645"
adb_path = shutil.which("adb")

adbshell = UniversalADBExecutor(
    adb_path=adb_path,
    device_serial=device_serial,
    standard_kwargs_windows=(
        ("env", os.environ),
        ("shell", False),
        ("startupinfo", startupinfo),
        (
            "creationflags",
            creationflags,
        ),
        ("start_new_session", True),
    ),
    standard_kwargs_linux=(
        ("env", os.environ),
        ("shell", True),
    ),
    standard_kwargs_darwin=(
        ("env", os.environ),
        ("shell", True),
    ),
    standard_kwargs_android=(
        ("env", os.environ),
        ("shell", True),
    ),
)

adbshell.non_shell_adb_commands_without_s_serial(
    [
        "connect",
        device_serial,
    ],
)

p1 = adbshell.shell_without_capturing_stdout_and_stderr(
    "mkdir -p '/sdcard/testfiles'", cwd="c:\\windows"
)
p2 = adbshell.shell_with_capturing_import_stdout_and_stderr("ls /sdcard", check=True)
p3 = adbshell.non_shell_adb_commands_with_s_serial(
    r'push "C:\writetext.txt" /sdcard/testfiles'
)

nonblock = adbshell.create_non_blocking_proc(
    debug=True, ignore_exceptions=False, bufsize=1
)
nonblock.extra_data_to_print_stderr = "stderr: "
nonblock.extra_data_to_print_stdout = "stdout: "
nonblock.stdinwrite("ls")
nonblock.stdinwrite("ls /sdcard/testfiles")
print(nonblock.stdout_results)
nonblock.stdinwrite("ls /sdcardbbbbbbbb/testfiles")
print(nonblock.stderr_results)
nonblock.stdinwrite("su")
commandok = nonblock.stdinwrite("ls /system")
print(f"{commandok=}")
print(nonblock.stderr_results)
commandok = nonblock.stdinwrite("ls /system")
nonblock.print_stdout = False
nonblock.print_stderr = False
print(nonblock.stderr_results)
nonblock.kill()
commandok2 = nonblock.stdinwrite("ls /system")

p4 = adbshell.shell_without_capturing_stdout_and_stderr(
    command="while true;do ls;sleep 1;done",
    debug=True,
    ignore_exceptions=True,
    timeout=10,
)

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1210 Sept 20242

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
hansalemaos/adbshellexecuter

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:13 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:afdf38ba160d2115363a7010977a7f0b5b5f4088d414df436777b96004d1d9bc