python-adb | Python ADB + Fastboot implementation | Android library
kandi X-RAY | python-adb Summary
kandi X-RAY | python-adb Summary
Note: This is not an official Google project. It is maintained by ex-Google engineers. For a better maintained option, look at [adb_shell] This repository contains a pure-python implementation of the ADB and Fastboot protocols, using libusb1 for USB communications. This is a complete replacement and rearchitecture of the Android project’s [ADB and fastboot code] This code is mainly targeted to users that need to communicate with Android devices in an automated fashion, such as in automated testing. It does not have a daemon between the client and the device, and therefore does not support multiple simultaneous commands to the same device. It does support any number of devices and never communicates with a device that it wasn’t intended to, unlike the Android project’s ADB.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Push data to a file
- Flush the buffer
- Reads from the client
- Reads a single file sync packet
- Install an apk
- Run a shell command
- Create a streaming command
- Push file to device
- Run a command on the device
- Get a service connection
- Connect to the device
- Connects to the device
- Make a subparser for a method
- Parse a docstring
- List device files
- Close the device
- Read numbytes from the device
- Find and open a device
- Get the size of a file
- Bulk write data to the device
- Create a matcher for the specified interface
- Reboot the device
- List available devices
- Pull a file
- Start a USB interface
- Connect to the server
python-adb Key Features
python-adb Examples and Code Snippets
class mVars:
address='C:/Users/EA/Desktop/yixin/' # 使用到的文件所存放地址
ip = '10.224.133.140:5555' #ip 地址,详见adb模块中adb连接教程
boradOne = 67 #一个相邻落子点的像素间隔
borad = (65,480) #棋盘的初始像素点
COMMANDS
Special Commands
NOTES:
DIRECTORIES + LOCATIONS WORTH SEARCHING
USEFUL TOOLS AND REPOSITORIES
KNOWLEDGE AND RESOURCES
Community Discussions
Trending Discussions on python-adb
QUESTION
I am taking some screenshots via adb from my android device (OnePlus 5) to recognize with googles tesseract if there is a specified word inside the page.
Usually it takes 5-8 screenshots with a 1.5 second delay from each other. The first 2-4 screenshots can be opend but then it throws the error and can´t be opend with PIL, Paint.net or on the phone itself.
...ANSWER
Answered 2019-May-19 at 15:24What fixed the bug for me was to remove the pgrinder directory in this path: /sdcard/pgrinder/screen.png.
I thought it would generate the directory if it doesn´t exist but that wasn´t the case. I don´t no why it worked sometimes and sometimes not. But since I changed it, it worked every time.
QUESTION
Pretty self explanatory, as the title says, is there a way to connect to an ADB over TCP
enabled device on a network, using Google's Python-ADB library?
I saw something mentioned in the adb_commands.py file to do with a TCP connection, here is the comment:
...ANSWER
Answered 2018-Dec-17 at 14:20Yes, simply pass ip:port
to the serial
positional argument:
QUESTION
TLDR; How do I make a "single-file" asyncio.Queue()
and feed it my adb commands, have them executed in the order they're received (one-by-one), handle errors that may occur (disconnect/reconnect) during one of the tasks, and continue processing the rest of the queue after handling the error?
I'm working on a module that leverages the existing python-adb module to ultimately control my android tablet as a media device and incorporate it into my home automation setup.
Problem:
My module is built entirely around async
, while the python-adb
module is not. The python-adb
module also doesn't manage/throttle requests. And I very quickly found out that if multiple adb commands are requested too quickly the adb connection is overloaded, causing an error & requiring a reconnect whenever the disconnect occurred.
A friend of mine managed to implement a workaround/hack-y solution. Note: self._adb_lock
& self._adb_error
are initially set in the AndroidDevice
class's __init__
function.
ANSWER
Answered 2018-Nov-11 at 22:33You need to ensure that only a single task is using the adb
connection to execute a command at any given time. This means you need to either use synchronisation primitives to coordinate access, or use a queue to feed a single worker task commands to execute.
Next, because an adb
connection is entirely synchronous and, as with all I/O, relatively slow, I'd use a thread pool executor to run operations on a adb
connection off the asyncio loop, so that asyncio is free to run some other tasks that are not currently blocked on I/O. Otherwise, there is no point to putting .Shell()
commands in a async def
coroutine, you are not actually cooperating and making room for other tasks to be run.
Last but not least, if even with serialised access to the connection object you find that it can't take too many commands per time period, you would want to use some kind of rate limiting technique. I've created an asyncio leaky bucket algorithm implementation before that can take care of this, if so required.
Both a queue or a lock would ensure that commands are executed in first-come-first-serve order, but a queue would require some kind of deferred response mechanism to return command results. A queue would let you queue up related commands (you can add multiple entries using queue.put_nowait()
without yielding or you can allow grouped commands), without having to wait for a lock first.
Because you want to retry connections, I'd encapsulate the connection object in a asynchronous context manager, that can then also handle locking and executing commands with an executor:
QUESTION
I want to install Python-adb using pip V9.0.3.
When Im trying to install python-adb, but I always get the same error as you can see at the bottom.
I also tried it installing it per CMD with admin rights on pip/pip3.
What I already tried:
- CMD with/without admin rights
- pip/pip3 installation
- installed mingw for C++ errors
Im currently using Python3.6 on Windows 7 64Bit
Output:
...ANSWER
Answered 2018-Mar-25 at 22:03Apparently M2Crypto
(which is where your install process is failing) is kind of hard to install on Windows, but there are unofficial binaries available (though that is a dated question), and the package's own install instructions include a section on Windows installation.
More promisingly, there is a clone of the project here, which also has Windows instructions. But for that you'll need to have SWIG
installed too.
A third option is this pair (32-bit, 64-bit) of packages that are clones of M2Crypto
specifically made for Windows, but I'm not sure how up-to-date they are (the last commit was in 2014, so there might have been a lot of changes to the original project by now).
QUESTION
I am trying to connect two devices to my pc and run some commands on them using python and adb. when I run the command from the command prompt, it goes through fine, but when i put those in the python script, they give me errors. this is causing the errors all the time:
...ANSWER
Answered 2017-Mar-19 at 21:18First
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install python-adb
You can use python-adb like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page