{"library":"pure-python-adb","title":"Pure Python ADB Client","description":"pure-python-adb provides a pure Python implementation of the Android Debug Bridge (ADB) client protocol. It allows Python applications to interact with ADB servers and connected Android devices programmatically, enabling tasks like shell commands, file transfers, and application management. The current version is 0.3.0.dev0, indicating active development with potential for API changes. Release cadence is irregular, as typical for a development branch.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pure-python-adb","pip install pure-python-adb[rsa]","pip install pure-python-adb[cryptodome]"],"cli":null},"imports":["from ppadb.client import Client as AdbClient","from ppadb.device.device import Device"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from ppadb.client import Client as AdbClient\nimport os\n\n# Ensure ADB server is running on 127.0.0.1:5037\n# (e.g., run 'adb start-server' in your terminal)\n\nhost = os.environ.get('ADB_HOST', '127.0.0.1')\nport = int(os.environ.get('ADB_PORT', 5037))\n\ntry:\n    # Connect to the ADB server\n    client = AdbClient(host=host, port=port)\n\n    # List connected devices\n    devices = client.devices()\n\n    if devices:\n        device = devices[0]\n        print(f\"Connected to device: {device.serial}\")\n\n        # Execute a shell command\n        result = device.shell(\"echo Hello from Android\")\n        print(f\"Shell command output: {result.strip()}\")\n\n        # Example: Push a file (create a dummy file first)\n        with open('test_file.txt', 'w') as f:\n            f.write('This is a test file.\\n')\n        device.push('test_file.txt', '/sdcard/test_file.txt')\n        print(\"Pushed test_file.txt to /sdcard/\")\n\n        # Example: Pull a file\n        device.pull('/sdcard/test_file.txt', 'downloaded_test_file.txt')\n        print(\"Pulled test_file.txt to downloaded_test_file.txt\")\n\n        os.remove('test_file.txt')\n        os.remove('downloaded_test_file.txt')\n\n    else:\n        print(\"No ADB devices found. Make sure a device is connected and authorized.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure the ADB server is running (e.g., 'adb start-server') and accessible.\")","lang":"python","description":"This quickstart connects to the ADB server, lists connected devices, and performs basic operations like executing shell commands, pushing, and pulling files. Ensure an ADB server is running and a device is connected and authorized for it to work correctly.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}