Skip to content

Latest commit

 

History

History
79 lines (57 loc) · 1.72 KB

File metadata and controls

79 lines (57 loc) · 1.72 KB

pyadb_client

Python library to communicate with ADB devices. Built on top of Rust adb_client library.

pypi.org downloads

Installation

pip install pyadb_client

Examples

Use ADB server

from pyadb_client import PyADBServer

server = PyADBServer("127.0.0.1:5037")
for i, device in enumerate(server.devices()):
    print(i, device.identifier, device.state)

# Get only connected device
device = server.get_device()
print(device, device.identifier)

Connect and Disconnect with device id

from pyadb_client import PyADBServer

server = PyADBServer("127.0.0.1:5037")

# Connect to a device with device id
device = server.connect_device("192.168.1.100:5555")
print(f"Connected to {device.identifier}")

# Disconnect from a device with device id
server.disconnect_device("192.168.1.100:5555")

Push a file on device

from pyadb_client import PyADBUSBDevice

usb_device = PyADBUSBDevice.autodetect()
usb_device.push("file.txt", "/data/local/tmp/file.txt")

Local development

# Create Python virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install needed build dependencies
pip install maturin

# Build development package
maturin develop

# Build stub file (.pyi)
cargo run --bin stub_gen

# Build release Python package
maturin build --release -m pyadb_client/Cargo.toml