Comments (5)
Hi selster:
You can use adb devices
to list all attached android devices.
$ adb devices
List of devices attached
YC873P0G device
The YC873P0G
is the device number.
Thanks ~
from pure-python-adb.
Thank you!. But can I get it programmatically, rather than using the command prompt?
The following returns the device number using get_serial_no() (but after I supply the device number):
from adb.client import Client as AdbClient
client = AdbClient(host="127.0.0.1", port=5037)
device = client.device("ZY224VQLW6")
device_number = device.get_serial_no()
but I can't figure out to get the device number by doing:
devices = client.devices()
devices.(something goes here that will return the device number?). I am guessing you have impleted this?
Otherwise in a python script, I could get the device number like this
import subprocess
cmd = "adb devices"
subprocess.check_output(cmd) && and then parse the output to get the device number
from pure-python-adb.
It would be the equivalent of this: subprocess.check_output(cmd).decode('utf8').strip().replace("List of devices attached","").strip()[:-7]
from pure-python-adb.
on my windows 7 systems, shell gives me an error:
device.shell("asdf")
'/system/bin/sh: asdf: not found\n'
In the meantime, this seems to work:
from adb.client import Client as AdbClient
import os
os.chdir(r'C:\Users\se\Downloads\scrcpy-win64-v1.5\scrcpy-win64')
import subprocess
cmd = "adb devices"
device = subprocess.check_output(cmd).decode('utf8').strip().replace("List of devices attached","").strip()[:-7]
client = AdbClient(host="127.0.0.1", port=5037)
device = client.device(device)
device.push("c:\python36\scripts\d123.txt", "/sdcard/Download/d1234.txt")
cmd2 = "adb shell ls /sdcard/Download/d1234.txt"
file_status = subprocess.check_output(cmd2).decode("utf8").strip()
print("the file is here: -->> " + file_status)
from pure-python-adb.
Hi selster
You can use this to list all devices and get the serial number.
from adb.client import Client as AdbClient
client = AdbClient(host="127.0.0.1", port=5037)
devices = client.devices()
for device in devices:
print(device.serial)
from pure-python-adb.
Related Issues (20)
- Connection read() gives blank output incase device disconnects and reconnects again
- emulator issue
- Starting wpa_supplicant in background mode via shell doesn't work
- Can't access call log using the shell HOT 1
- How to connect the device with user & password in need?
- Error when pushing the folder with files to the device on Windows
- tar mulitple files sometimes one file missing
- There is no is_installed attribute in async mode
- Can i drag mouse ?
- failed to load module on raspbian os (pi4) HOT 11
- device.push with error FileNotFoundError("Cannot find {}".format(src)) HOT 3
- Maintainer / Contributions 👋🏼 HOT 8
- How can i start Pakcage
- st_mtime is not converted to int in async HOT 1
- Multiple Devices Error HOT 4
- keyword of the install method has a syntax error
- python-adb freezes when connecting to bluestacks app player HOT 2
- How can I code these adb commands HOT 2
- Start shell command a la subprocess.Popen
- Make error handling more uniform HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pure-python-adb.