Skip to content

Commit 043bbb5

Browse files
authored
Add log_errors parameter in setup (#318)
1 parent d4b8756 commit 043bbb5

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

androidtv/__init__.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def setup(
2424
auth_timeout_s=DEFAULT_AUTH_TIMEOUT_S,
2525
signer=None,
2626
transport_timeout_s=DEFAULT_TRANSPORT_TIMEOUT_S,
27+
log_errors=True,
2728
):
2829
"""Connect to a device and determine whether it's an Android TV or an Amazon Fire TV.
2930
@@ -49,6 +50,8 @@ def setup(
4950
The signer for the ADB keys, as loaded by :meth:`androidtv.adb_manager.adb_manager_sync.ADBPythonSync.load_adbkey`
5051
transport_timeout_s : float
5152
Transport timeout (in seconds)
53+
log_errors: bool
54+
Whether connection errors should be logged
5255
5356
Returns
5457
-------
@@ -58,14 +61,14 @@ def setup(
5861
"""
5962
if device_class == "androidtv":
6063
atv = AndroidTVSync(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, signer)
61-
atv.adb_connect(auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
64+
atv.adb_connect(log_errors=log_errors, auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
6265
atv.get_device_properties()
6366
atv.get_installed_apps()
6467
return atv
6568

6669
if device_class == "firetv":
6770
ftv = FireTVSync(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, signer)
68-
ftv.adb_connect(auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
71+
ftv.adb_connect(log_errors=log_errors, auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
6972
ftv.get_device_properties()
7073
ftv.get_installed_apps()
7174
return ftv
@@ -76,7 +79,7 @@ def setup(
7679
aftv = BaseTVSync(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, signer)
7780

7881
# establish the ADB connection
79-
aftv.adb_connect(auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
82+
aftv.adb_connect(log_errors=log_errors, auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
8083

8184
# get device properties
8285
aftv.device_properties = aftv.get_device_properties()

androidtv/setup_async.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ async def setup(
2020
auth_timeout_s=DEFAULT_AUTH_TIMEOUT_S,
2121
signer=None,
2222
transport_timeout_s=DEFAULT_TRANSPORT_TIMEOUT_S,
23+
log_errors=True,
2324
):
2425
"""Connect to a device and determine whether it's an Android TV or an Amazon Fire TV.
2526
@@ -45,6 +46,8 @@ async def setup(
4546
The signer for the ADB keys, as loaded by :meth:`androidtv.adb_manager.adb_manager_async.ADBPythonAsync.load_adbkey`
4647
transport_timeout_s : float
4748
Transport timeout (in seconds)
49+
log_errors: bool
50+
Whether connection errors should be logged
4851
4952
Returns
5053
-------
@@ -54,14 +57,18 @@ async def setup(
5457
"""
5558
if device_class == "androidtv":
5659
atv = AndroidTVAsync(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, signer)
57-
await atv.adb_connect(auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
60+
await atv.adb_connect(
61+
log_errors=log_errors, auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s
62+
)
5863
await atv.get_device_properties()
5964
await atv.get_installed_apps()
6065
return atv
6166

6267
if device_class == "firetv":
6368
ftv = FireTVAsync(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, signer)
64-
await ftv.adb_connect(auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
69+
await ftv.adb_connect(
70+
log_errors=log_errors, auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s
71+
)
6572
await ftv.get_device_properties()
6673
await ftv.get_installed_apps()
6774
return ftv
@@ -72,7 +79,9 @@ async def setup(
7279
aftv = BaseTVAsync(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, signer)
7380

7481
# establish the ADB connection
75-
await aftv.adb_connect(auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s)
82+
await aftv.adb_connect(
83+
log_errors=log_errors, auth_timeout_s=auth_timeout_s, transport_timeout_s=transport_timeout_s
84+
)
7685

7786
# get device properties
7887
await aftv.get_device_properties()

0 commit comments

Comments
 (0)