diff --git a/androidtv/__init__.py b/androidtv/__init__.py index b59b219d..64f60595 100644 --- a/androidtv/__init__.py +++ b/androidtv/__init__.py @@ -46,15 +46,15 @@ def setup(host, port=5555, adbkey='', adb_server_ip='', adb_server_port=5037, st 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) - atv.device_properties = atv.get_device_properties() - atv.installed_apps = atv.get_installed_apps() + 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) - ftv.device_properties = ftv.get_device_properties() - ftv.installed_apps = ftv.get_installed_apps() + ftv.get_device_properties() + ftv.get_installed_apps() return ftv if device_class != 'auto': @@ -69,7 +69,7 @@ def setup(host, port=5555, adbkey='', adb_server_ip='', adb_server_port=5037, st aftv.device_properties = aftv.get_device_properties() # get the installed apps - aftv.installed_apps = aftv.get_installed_apps() + aftv.get_installed_apps() # Fire TV if aftv.device_properties.get('manufacturer') == 'Amazon': diff --git a/androidtv/basetv/basetv.py b/androidtv/basetv/basetv.py index 2bca9526..59797c86 100644 --- a/androidtv/basetv/basetv.py +++ b/androidtv/basetv/basetv.py @@ -135,20 +135,20 @@ def _parse_device_properties(self, properties): properties : str, None The output of the ADB command that retrieves the device properties - Returns - ------- - dict - A dictionary with keys ``'wifimac'``, ``'ethmac'``, ``'serialno'``, ``'manufacturer'``, ``'model'``, and ``'sw_version'`` + This method fills in the ``device_properties`` attribute, which is a dictionary with keys + ``'wifimac'``, ``'ethmac'``, ``'serialno'``, ``'manufacturer'``, ``'model'``, and ``'sw_version'`` """ _LOGGER.debug("%s:%d `get_device_properties` response: %s", self.host, self.port, properties) if not properties: - return {} + self.device_properties = {} + return lines = properties.strip().splitlines() if len(lines) != 6: - return {} + self.device_properties = {} + return manufacturer, model, serialno, version, mac_wlan0_output, mac_eth0_output = lines @@ -172,12 +172,12 @@ def _parse_device_properties(self, properties): else: ethmac = None - return {'manufacturer': manufacturer, - 'model': model, - 'serialno': serialno, - 'sw_version': version, - 'wifimac': wifimac, - 'ethmac': ethmac} + self.device_properties = {'manufacturer': manufacturer, + 'model': model, + 'serialno': serialno, + 'sw_version': version, + 'wifimac': wifimac, + 'ethmac': ethmac} # ======================================================================= # # # @@ -395,7 +395,7 @@ def _get_hdmi_input(hdmi_response): return hdmi_response.strip() if hdmi_response and hdmi_response.strip() else None @staticmethod - def _installed_apps(installed_apps_response): + def _get_installed_apps(installed_apps_response): """Get the installed apps from the output of :py:const:`androidtv.constants.CMD_INSTALLED_APPS`. Parameters diff --git a/androidtv/basetv/basetv_async.py b/androidtv/basetv/basetv_async.py index 665101e5..a7e33013 100644 --- a/androidtv/basetv/basetv_async.py +++ b/androidtv/basetv/basetv_async.py @@ -198,7 +198,8 @@ async def get_device_properties(self): constants.CMD_MAC_WLAN0 + " && " + constants.CMD_MAC_ETH0) - return self._parse_device_properties(properties) + self._parse_device_properties(properties) + return self.device_properties # ======================================================================= # # # @@ -275,7 +276,8 @@ async def get_installed_apps(self): """ installed_apps_response = await self._adb.shell(constants.CMD_INSTALLED_APPS) - return self._installed_apps(installed_apps_response) + self.installed_apps = self._get_installed_apps(installed_apps_response) + return self.installed_apps async def is_volume_muted(self): """Whether or not the volume is muted. diff --git a/androidtv/basetv/basetv_sync.py b/androidtv/basetv/basetv_sync.py index c2c480b6..15a1803e 100644 --- a/androidtv/basetv/basetv_sync.py +++ b/androidtv/basetv/basetv_sync.py @@ -198,7 +198,8 @@ def get_device_properties(self): constants.CMD_MAC_WLAN0 + " && " + constants.CMD_MAC_ETH0) - return self._parse_device_properties(properties) + self._parse_device_properties(properties) + return self.device_properties # ======================================================================= # # # @@ -275,7 +276,8 @@ def get_installed_apps(self): """ installed_apps_response = self._adb.shell(constants.CMD_INSTALLED_APPS) - return self._installed_apps(installed_apps_response) + self.installed_apps = self._get_installed_apps(installed_apps_response) + return self.installed_apps def is_volume_muted(self): """Whether or not the volume is muted. diff --git a/androidtv/setup_async.py b/androidtv/setup_async.py index 3a4c036b..4dc26da6 100644 --- a/androidtv/setup_async.py +++ b/androidtv/setup_async.py @@ -42,15 +42,15 @@ async def setup(host, port=5555, adbkey='', adb_server_ip='', adb_server_port=50 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) - atv.device_properties = await atv.get_device_properties() - atv.installed_apps = await atv.get_installed_apps() + 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) - ftv.device_properties = await ftv.get_device_properties() - ftv.installed_apps = await ftv.get_installed_apps() + await ftv.get_device_properties() + await ftv.get_installed_apps() return ftv if device_class != 'auto': @@ -62,10 +62,10 @@ async def setup(host, port=5555, adbkey='', adb_server_ip='', adb_server_port=50 await aftv.adb_connect(auth_timeout_s=auth_timeout_s) # get device properties - aftv.device_properties = await aftv.get_device_properties() + await aftv.get_device_properties() # get the installed apps - aftv.installed_apps = await aftv.get_installed_apps() + await aftv.get_installed_apps() # Fire TV if aftv.device_properties.get('manufacturer') == 'Amazon': diff --git a/tests/test_basetv_async.py b/tests/test_basetv_async.py index c39c5bcd..2143f883 100644 --- a/tests/test_basetv_async.py +++ b/tests/test_basetv_async.py @@ -291,7 +291,7 @@ async def test_get_installed_apps(self): """ with async_patchers.patch_shell(None)[self.PATCH_KEY]: - with patch_calls(self.btv, self.btv._installed_apps) as patched: + with patch_calls(self.btv, self.btv._get_installed_apps) as patched: await self.btv.get_installed_apps() assert patched.called