Skip to content

Commit 846ce71

Browse files
committed
1. remove python 2 support
2. add async client example to README 3. add test_async to docker-compose command
1 parent 9644c6b commit 846ce71

3 files changed

Lines changed: 34 additions & 3 deletions

File tree

README.rst

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This package supports most of the adb command line tool's functionality.
3030
Requirements
3131
============
3232

33-
Python 2.7+ / Python 3.6+
33+
Python 3.6+
3434

3535
Installation
3636
============
@@ -197,6 +197,38 @@ Enable debug logger
197197
198198
logging.getLogger("ppadb").setLevel(logging.DEBUG)
199199
200+
Async Client
201+
--------------------
202+
203+
.. code-block:: python
204+
205+
import asyncio
206+
import aiofiles
207+
from ppadb.client_async import ClientAsync as AdbClient
208+
209+
async def _save_screenshot(device):
210+
result = await device.screencap()
211+
file_name = f"{device.serial}.png"
212+
async with aiofiles.open(f"{file_name}", mode='wb') as f:
213+
await f.write(result)
214+
215+
return file_name
216+
217+
async def main():
218+
client = AdbClient(host="127.0.0.1", port=5037)
219+
devices = await client.devices()
220+
for device in devices:
221+
print(device.serial)
222+
223+
result = await asyncio.gather(*[_save_screenshot(device) for device in devices])
224+
print(result)
225+
226+
asyncio.run(main())
227+
228+
229+
230+
231+
200232
201233
How to run test cases
202234
======================

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
environment:
1111
- PYTHONPATH=/code
1212
- PYTHONUNBUFFERED=0
13-
command: sh -c "pip install -r requirements.txt;py.test test -s -v --junit-xml test_result.xml"
13+
command: sh -c "pip install -r requirements.txt;py.test test -s -v --junit-xml test_result.xml;pip install 'aiofiles>=0.4.0';py.test test_async -s -v --junit-xml test_result_async.xml"
1414

1515
emulator:
1616
image: swind/android-emulator:android_28

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
'Intended Audience :: Developers',
1717
'License :: OSI Approved :: MIT License',
1818
'Programming Language :: Python :: 3',
19-
'Programming Language :: Python :: 2.7',
2019
'Topic :: Software Development :: Testing',
2120
]
2221

0 commit comments

Comments
 (0)