How to use the catt.error.AppSelectionError function in catt

To help you get started, we’ve selected a few catt 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 skorokithakis / catt / catt / controllers.py View on Github external
app = next(a for a in APPS if id_or_name in [a.id, a.name])
    except StopIteration:
        if strict:
            raise AppSelectionError("App not found (strict is set)")
        else:
            return DEFAULT_APP

    if app.name == "default":
        return app

    if not cast_type:
        raise AppSelectionError("Cast type is needed for app selection")
    elif cast_type not in app.supported_device_types:
        msg = "The {} app is not available for this device".format(app.name.capitalize())
        if strict:
            raise AppSelectionError("{} (strict is set)".format(msg))
        elif show_warning:
            warning(msg)
        return DEFAULT_APP
    else:
        return app
github skorokithakis / catt / catt / controllers.py View on Github external
def get_app(id_or_name, cast_type=None, strict=False, show_warning=False):
    try:
        app = next(a for a in APPS if id_or_name in [a.id, a.name])
    except StopIteration:
        if strict:
            raise AppSelectionError("App not found (strict is set)")
        else:
            return DEFAULT_APP

    if app.name == "default":
        return app

    if not cast_type:
        raise AppSelectionError("Cast type is needed for app selection")
    elif cast_type not in app.supported_device_types:
        msg = "The {} app is not available for this device".format(app.name.capitalize())
        if strict:
            raise AppSelectionError("{} (strict is set)".format(msg))
        elif show_warning:
            warning(msg)
        return DEFAULT_APP
    else:
github skorokithakis / catt / catt / controllers.py View on Github external
def get_app(id_or_name, cast_type=None, strict=False, show_warning=False):
    try:
        app = next(a for a in APPS if id_or_name in [a.id, a.name])
    except StopIteration:
        if strict:
            raise AppSelectionError("App not found (strict is set)")
        else:
            return DEFAULT_APP

    if app.name == "default":
        return app

    if not cast_type:
        raise AppSelectionError("Cast type is needed for app selection")
    elif cast_type not in app.supported_device_types:
        msg = "The {} app is not available for this device".format(app.name.capitalize())
        if strict:
            raise AppSelectionError("{} (strict is set)".format(msg))
        elif show_warning:
            warning(msg)
        return DEFAULT_APP
    else:
        return app