def getAuthorizedRoles(self, cu, serverName, remoteIp,
                           entitlementClass, entitlement):
        """
        Given an entitlement, return the list of roles that the
        credentials authorize.
        """
        cacheEntry = sha1helper.sha1String("%s%s%s" % (
            serverName, entitlementClass, entitlement))
        roleIds, timeout, autoRetry = \
                self.cache.get(cacheEntry, (None, None, None))
        if (timeout is not None) and time.time() < timeout:
            return roleIds
        elif (timeout is not None):
            del self.cache[cacheEntry]
            if autoRetry is not True:
                raise errors.EntitlementTimeout([entitlement])

        if self.entCheckUrl:
            if entitlementClass is not None:
                url = "%s?server=%s;class=%s;key=%s" \
                        % (self.entCheckUrl, urllib.quote(serverName),
                           urllib.quote(entitlementClass),
                           urllib.quote(entitlement))
            else:
                url = "%s?server=%s;key=%s" \
                        % (self.entCheckUrl, urllib.quote(serverName),
                           urllib.quote(entitlement))

            if remoteIp is not None:
                url += urllib.quote(remoteIp) % ';remote_ip=%s'

            try:
                f = urllib2.urlopen(url)
                xmlResponse = f.read()
            except Exception:
                return set()

            p = conarycfg.EntitlementParser()

            try:
                p.parse(xmlResponse)
            except:
                return set()

            if p['server'] != serverName:
                return set()

            entitlementClass = p['class']
            entitlement = p['key']
            entitlementRetry = p['retry']
            if p['timeout'] is None:
                entitlementTimeout = self.cacheTimeout
            else:
                entitlementTimeout = p['timeout']

            if entitlementTimeout is None:
                entitlementTimeout = -1

        # look up entitlements
        cu.execute("""
        SELECT UserGroups.userGroupId, UserGroups.accept_flags
        FROM Entitlements
        JOIN EntitlementAccessMap USING (entGroupId)
        JOIN UserGroups USING (userGroupId)
        WHERE entitlement=?
        """, entitlement)

        roleIds = dict((x[0], deps.ThawFlavor(x[1])) for x in cu)
        if self.entCheckUrl:
            # cacheEntry is still set from the cache check above
            self.cache[cacheEntry] = (roleIds,
                                      time.time() + entitlementTimeout,
                                      entitlementRetry)

        return roleIds
dataset/ETHPy150Open sassoftware/conary/conary/repository/netrepos/netauth.py/EntitlementAuthorization.getAuthorizedRoles/swapped operands of `%`