Пример #1
0
def get_screen_log():
    """Get display information using kano-settings display functions.

    Returns:
        dict: An aggregate of display characteristics
    """

    try:
        from kano_settings.system.display import get_edid, get_edid_name, get_status, \
            list_supported_modes, get_optimal_resolution_mode, override_models

        edid = get_edid()
        model = get_edid_name(use_cached=False)

        override_models(edid, model)

        status = get_status()
        supported = list_supported_modes(use_cached=False)
        optimal = get_optimal_resolution_mode(edid, supported)

        log_data = {
            'model': model,
            'status': status,
            'edid': edid,
            'supported': supported,
            'optimal': optimal,
        }
        log = json.dumps(log_data, sort_keys=True, indent=4)
    except:
        return traceback.format_exc()

    return log
Пример #2
0
def get_screen_log():
    """Get display information using kano-settings display functions.

    Returns:
        dict: An aggregate of display characteristics
    """

    try:
        from kano_settings.system.display import get_edid, get_edid_name, get_status, \
            list_supported_modes, get_optimal_resolution_mode, override_models

        edid = get_edid()
        model = get_edid_name(use_cached=False)

        override_models(edid, model)

        status = get_status()
        supported = list_supported_modes(use_cached=False)
        optimal = get_optimal_resolution_mode(edid, supported)

        log_data = {
            'model': model,
            'status': status,
            'edid': edid,
            'supported': supported,
            'optimal': optimal,
        }
        log = json.dumps(log_data, sort_keys=True, indent=4)
    except:
        return traceback.format_exc()

    return log
Пример #3
0
    def test_override_models(self, edid):
        """
        Tests that the override_models function sets all the options in the EDID.

        Args:
            edid - parameterised fixture containing raw, rpi_dumps, expected test data
        """

        from kano_settings.system import display

        # As the function changes the dict inplace, make a copy to be safe.
        overriden_expected_edid = edid['expected']['edid'].copy()
        display.override_models(overriden_expected_edid, edid['expected']['model'])

        if edid['expected']['model'] in display.EDID_OVERRIDES:
            # Check that the EDID now contains all the (key, value) pairs in the dict
            # that was used to change the values. The EDID is allowed to have more pairs,
            # but the ones matching by key must match in values.
            assert(
                overriden_expected_edid.viewitems() >=
                display.EDID_OVERRIDES[edid['expected']['model']].viewitems()
            )
        else:
            # Check that the EDID was not changed by the function when there are
            # no options to override.
            assert(overriden_expected_edid == edid['expected']['edid'])
Пример #4
0
    def test_override_models(self, edid):
        """
        Tests that the override_models function sets all the options in the EDID.

        Args:
            edid - parameterised fixture containing raw, rpi_dumps, expected test data
        """

        from kano_settings.system import display

        # As the function changes the dict inplace, make a copy to be safe.
        overriden_expected_edid = edid['expected']['edid'].copy()
        display.override_models(overriden_expected_edid,
                                edid['expected']['model'])

        if edid['expected']['model'] in display.EDID_OVERRIDES:
            # Check that the EDID now contains all the (key, value) pairs in the dict
            # that was used to change the values. The EDID is allowed to have more pairs,
            # but the ones matching by key must match in values.
            assert (
                overriden_expected_edid.viewitems() >=
                display.EDID_OVERRIDES[edid['expected']['model']].viewitems())
        else:
            # Check that the EDID was not changed by the function when there are
            # no options to override.
            assert (overriden_expected_edid == edid['expected']['edid'])
Пример #5
0
    def test_get_optimal_resolution_mode(self, monkeypatch, edid):
        """
        Tests that the get_optimal_resolution_mode function returns the expected values.

        Args:
            monkeypatch - pytest fixture which gives mocking functionality
            edid - parameterised fixture containing raw, rpi_dumps, expected test data
        """

        # As the function changes the dict inplace, make a copy to be safe.
        overriden_expected_edid = edid['expected']['edid'].copy()
        display.override_models(overriden_expected_edid,
                                edid['expected']['model'])

        rv = display.get_optimal_resolution_mode(
            overriden_expected_edid,
            edid['expected']['cea_modes'] + edid['expected']['dmt_modes'])
        assert (rv == edid['expected']['optimal_mode'])
Пример #6
0
    def test_get_optimal_resolution_mode(self, monkeypatch, edid):
        """
        Tests that the get_optimal_resolution_mode function returns the expected values.

        Args:
            monkeypatch - pytest fixture which gives mocking functionality
            edid - parameterised fixture containing raw, rpi_dumps, expected test data
        """

        from kano_settings.system import display

        # As the function changes the dict inplace, make a copy to be safe.
        overriden_expected_edid = edid['expected']['edid'].copy()
        display.override_models(overriden_expected_edid, edid['expected']['model'])

        rv = display.get_optimal_resolution_mode(
            overriden_expected_edid,
            edid['expected']['cea_modes'] + edid['expected']['dmt_modes']
        )
        assert(rv == edid['expected']['optimal_mode'])