How to use the androidtv.androidtv.androidtv_sync.AndroidTVSync function in androidtv

To help you get started, we’ve selected a few androidtv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JeffLIrion / python-androidtv / tests / test_androidtv_sync.py View on Github external
def test_state_detection_rules_validator(self):
        """Check that the ``state_detection_rules_validator`` function works correctly.

        """
        with patchers.patch_connect(True)['python'], patchers.patch_shell('')['python']:
            # Make sure that no error is raised when the state detection rules are valid
            AndroidTVSync('HOST', 5555, state_detection_rules=STATE_DETECTION_RULES1)
            AndroidTVSync('HOST', 5555, state_detection_rules=STATE_DETECTION_RULES2)
            AndroidTVSync('HOST', 5555, state_detection_rules=STATE_DETECTION_RULES3)
            AndroidTVSync('HOST', 5555, state_detection_rules=STATE_DETECTION_RULES4)
            AndroidTVSync('HOST', 5555, state_detection_rules=STATE_DETECTION_RULES5)
github JeffLIrion / python-androidtv / tests / test_setup_sync.py View on Github external
with self.assertRaises(ValueError):
            setup('HOST', 5555, device_class='INVALID')

        with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[self.PATCH_KEY], patchers.patch_shell(DEVICE_PROPERTIES_OUTPUT1)[self.PATCH_KEY]:
            ftv = setup('HOST', 5555)
            self.assertIsInstance(ftv, FireTVSync)
            self.assertDictEqual(ftv.device_properties, DEVICE_PROPERTIES_DICT1)

        with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[self.PATCH_KEY], patchers.patch_shell(DEVICE_PROPERTIES_OUTPUT2)[self.PATCH_KEY]:
            atv = setup('HOST', 5555)
            self.assertIsInstance(atv, AndroidTVSync)
            self.assertDictEqual(atv.device_properties, DEVICE_PROPERTIES_DICT2)

        with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[self.PATCH_KEY], patchers.patch_shell(DEVICE_PROPERTIES_OUTPUT1)[self.PATCH_KEY]:
            ftv = setup('HOST', 5555, device_class='androidtv')
            self.assertIsInstance(ftv, AndroidTVSync)
            self.assertDictEqual(ftv.device_properties, DEVICE_PROPERTIES_DICT1)

        with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[self.PATCH_KEY], patchers.patch_shell(DEVICE_PROPERTIES_OUTPUT2)[self.PATCH_KEY]:
            atv = setup('HOST', 5555, device_class='firetv')
            self.assertIsInstance(atv, FireTVSync)
            self.assertDictEqual(atv.device_properties, DEVICE_PROPERTIES_DICT2)
github JeffLIrion / python-androidtv / tests / test_setup_sync.py View on Github external
def test_setup(self):
        """Test that the ``setup`` function works correctly.
        """
        with self.assertRaises(ValueError):
            setup('HOST', 5555, device_class='INVALID')

        with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[self.PATCH_KEY], patchers.patch_shell(DEVICE_PROPERTIES_OUTPUT1)[self.PATCH_KEY]:
            ftv = setup('HOST', 5555)
            self.assertIsInstance(ftv, FireTVSync)
            self.assertDictEqual(ftv.device_properties, DEVICE_PROPERTIES_DICT1)

        with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[self.PATCH_KEY], patchers.patch_shell(DEVICE_PROPERTIES_OUTPUT2)[self.PATCH_KEY]:
            atv = setup('HOST', 5555)
            self.assertIsInstance(atv, AndroidTVSync)
            self.assertDictEqual(atv.device_properties, DEVICE_PROPERTIES_DICT2)

        with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[self.PATCH_KEY], patchers.patch_shell(DEVICE_PROPERTIES_OUTPUT1)[self.PATCH_KEY]:
            ftv = setup('HOST', 5555, device_class='androidtv')
            self.assertIsInstance(ftv, AndroidTVSync)
            self.assertDictEqual(ftv.device_properties, DEVICE_PROPERTIES_DICT1)

        with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[self.PATCH_KEY], patchers.patch_shell(DEVICE_PROPERTIES_OUTPUT2)[self.PATCH_KEY]:
            atv = setup('HOST', 5555, device_class='firetv')
            self.assertIsInstance(atv, FireTVSync)
            self.assertDictEqual(atv.device_properties, DEVICE_PROPERTIES_DICT2)
github JeffLIrion / python-androidtv / tests / test_androidtv_sync.py View on Github external
def setUp(self):
        with patchers.patch_connect(True)[self.PATCH_KEY], patchers.patch_shell('')[self.PATCH_KEY]:
            self.atv = AndroidTVSync('HOST', 5555, adb_server_ip='ADB_SERVER_IP')
            self.atv.adb_connect()
github JeffLIrion / python-androidtv / tests / test_androidtv_sync.py View on Github external
def setUp(self):
        with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[self.PATCH_KEY], patchers.patch_shell('')[self.PATCH_KEY]:
            self.atv = AndroidTVSync('HOST', 5555)
            self.atv.adb_connect()
github JeffLIrion / python-androidtv / androidtv / __init__.py View on Github external
A dictionary of rules for determining the state (see :class:`~androidtv.basetv.basetv.BaseTV`)
    device_class : str
        The type of device: ``'auto'`` (detect whether it is an Android TV or Fire TV device), ``'androidtv'``, or ``'firetv'```
    auth_timeout_s : float
        Authentication timeout (in seconds)
    signer : PythonRSASigner, None
        The signer for the ADB keys, as loaded by :meth:`androidtv.adb_manager.adb_manager_sync.ADBPythonSync.load_adbkey`

    Returns
    -------
    AndroidTVSync, FireTVSync
        The representation of the device

    """
    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()
        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()
        return ftv

    if device_class != 'auto':
        raise ValueError("`device_class` must be 'androidtv', 'firetv', or 'auto'.")

    aftv = BaseTVSync(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, signer)

    # establish the ADB connection
github JeffLIrion / python-androidtv / androidtv / __init__.py View on Github external
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)

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

    # Fire TV
    if aftv.device_properties.get('manufacturer') == 'Amazon':
        aftv.__class__ = FireTVSync

    # Android TV
    else:
        aftv.__class__ = AndroidTVSync

    return aftv