File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ This package supports most of the adb command line tool's functionality.
3030Requirements
3131============
3232
33- Python 2.7+ / Python 3.6+
33+ Python 3.6+
3434
3535Installation
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======================
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments