def check_stats_permission(request, addon, for_contributions=False):
    # If public, non-contributions: everybody can view.
    if addon.public_stats and not for_contributions:
        return

    # Everything else requires an authenticated user.
    if not request.user.is_authenticated():
        raise PermissionDenied

    if not for_contributions:
        # Only authors and Stats Viewers allowed.
        if (addon.has_author(request.user) or
                acl.action_allowed(request, 'Stats', 'View')):
            return

    else:  # For contribution stats.
        # Only authors and Contribution Stats Viewers.
        if (addon.has_author(request.user) or
                acl.action_allowed(request, 'RevenueStats', 'View')):
            return

    raise PermissionDenied
Connect to the device.  If not connected within the specified timeout
dataset/ETHPy150Open mozilla/addons-server/src/olympia/stats/views.py/check_stats_permission--crossover with--dataset/ETHPy150Open adafruit/Adafruit_Python_BluefruitLE/Adafruit_BluefruitLE/bluez_dbus/device.py/BluezDevice.connect