Skip to content

Commit

Permalink
Merge 879db59 into d4b8756
Browse files Browse the repository at this point in the history
  • Loading branch information
ollo69 committed Apr 14, 2022
2 parents d4b8756 + 879db59 commit e7524f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
9 changes: 6 additions & 3 deletions androidtv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def setup(
auth_timeout_s=DEFAULT_AUTH_TIMEOUT_S,
signer=None,
transport_timeout_s=DEFAULT_TRANSPORT_TIMEOUT_S,
log_errors=True,
):
"""Connect to a device and determine whether it's an Android TV or an Amazon Fire TV.
Expand All @@ -49,6 +50,8 @@ def setup(
The signer for the ADB keys, as loaded by :meth:`androidtv.adb_manager.adb_manager_sync.ADBPythonSync.load_adbkey`
transport_timeout_s : float
Transport timeout (in seconds)
log_errors: bool
Whether connection errors should be logged
Returns
-------
Expand All @@ -58,14 +61,14 @@ def setup(
"""
if device_class == "androidtv":
atv = AndroidTVSync(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, signer)
atv.adb_connect(auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
atv.adb_connect(log_errors=log_errors, auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
atv.get_device_properties()
atv.get_installed_apps()
return atv

if device_class == "firetv":
ftv = FireTVSync(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, signer)
ftv.adb_connect(auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
ftv.adb_connect(log_errors=log_errors, auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
ftv.get_device_properties()
ftv.get_installed_apps()
return ftv
Expand All @@ -76,7 +79,7 @@ def setup(
aftv = BaseTVSync(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, signer)

# establish the ADB connection
aftv.adb_connect(auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
aftv.adb_connect(log_errors=log_errors, auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)

# get device properties
aftv.device_properties = aftv.get_device_properties()
Expand Down
15 changes: 12 additions & 3 deletions androidtv/setup_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async def setup(
auth_timeout_s=DEFAULT_AUTH_TIMEOUT_S,
signer=None,
transport_timeout_s=DEFAULT_TRANSPORT_TIMEOUT_S,
log_errors=True,
):
"""Connect to a device and determine whether it's an Android TV or an Amazon Fire TV.
Expand All @@ -45,6 +46,8 @@ async def setup(
The signer for the ADB keys, as loaded by :meth:`androidtv.adb_manager.adb_manager_async.ADBPythonAsync.load_adbkey`
transport_timeout_s : float
Transport timeout (in seconds)
log_errors: bool
Whether connection errors should be logged
Returns
-------
Expand All @@ -54,14 +57,18 @@ async def setup(
"""
if device_class == "androidtv":
atv = AndroidTVAsync(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, signer)
await atv.adb_connect(auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
await atv.adb_connect(
log_errors=log_errors, auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s
)
await atv.get_device_properties()
await atv.get_installed_apps()
return atv

if device_class == "firetv":
ftv = FireTVAsync(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, signer)
await ftv.adb_connect(auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
await ftv.adb_connect(
log_errors=log_errors, auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s
)
await ftv.get_device_properties()
await ftv.get_installed_apps()
return ftv
Expand All @@ -72,7 +79,9 @@ async def setup(
aftv = BaseTVAsync(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, signer)

# establish the ADB connection
await aftv.adb_connect(auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
await aftv.adb_connect(
log_errors=log_errors, auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s
)

# get device properties
await aftv.get_device_properties()
Expand Down

0 comments on commit e7524f4

Please sign in to comment.