File: __init__.py

package info (click to toggle)
python-pure-python-adb 0.3.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,500 kB
  • sloc: python: 2,597; makefile: 8; sh: 1
file content (28 lines) | stat: -rw-r--r-- 678 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from ppadb.device_async import DeviceAsync


class HostAsync:
    CONNECT_RESULT_PATTERN = "(connected to|already connected)"

    OFFLINE = "offline"
    DEVICE = "device"
    BOOTLOADER = "bootloader"

    async def _execute_cmd(self, cmd):
        async with await self.create_connection() as conn:
            await conn.send(cmd)
            return await conn.receive()

    async def devices(self):
        cmd = "host:devices"
        result = await self._execute_cmd(cmd)

        devices = []

        for line in result.split('\n'):
            if not line:
                break

            devices.append(DeviceAsync(self, line.split()[0]))

        return devices