Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue authored Jul 19, 2024
1 parent 8179564 commit 68d6c4f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions adbutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,23 @@ def list(self, extended=False) -> typing.List[AdbDeviceInfo]:
"""
infos = []
with self.make_connection() as c:
ext, sep = ("-l", None) if extended else ("", "\t")
c.send_command("host:devices" + ext)
if extended:
c.send_command("host:devices-l")

Check warning on line 44 in adbutils/__init__.py

View check run for this annotation

Codecov / codecov/patch

adbutils/__init__.py#L44

Added line #L44 was not covered by tests
else:
c.send_command("host:devices")

Check warning on line 46 in adbutils/__init__.py

View check run for this annotation

Codecov / codecov/patch

adbutils/__init__.py#L46

Added line #L46 was not covered by tests
c.check_okay()
output = c.read_string_block()
for line in output.splitlines():
parts = line.strip().split(sep)
if not extended and len(parts) != 2:
continue
parts = line.split()
tags = {}

Check warning on line 51 in adbutils/__init__.py

View check run for this annotation

Codecov / codecov/patch

adbutils/__init__.py#L50-L51

Added lines #L50 - L51 were not covered by tests
if len(parts) > 2:
if extended:
if len(parts) <= 2:
continue
tags['device_version'] = parts[2]

Check warning on line 55 in adbutils/__init__.py

View check run for this annotation

Codecov / codecov/patch

adbutils/__init__.py#L54-L55

Added lines #L54 - L55 were not covered by tests
tags = {**tags, **{kv[0]: kv[1] for kv in list(map(lambda tag: tag.split(":"), parts[3:]))}}
tags = {**tags, **{kv[0]: kv[1] for kv in list(map(lambda tag: tag.split(":"), parts[3:]))}}
else:
if len(parts) != 2:
continue
infos.append(AdbDeviceInfo(serial=parts[0], state=parts[1], tags=tags))

Check warning on line 60 in adbutils/__init__.py

View check run for this annotation

Codecov / codecov/patch

adbutils/__init__.py#L59-L60

Added lines #L59 - L60 were not covered by tests
return infos

Expand Down

0 comments on commit 68d6c4f

Please sign in to comment.