Skip to content

Commit

Permalink
Merge pull request mozilla#92 from callmekatootie/string_format_update
Browse files Browse the repository at this point in the history
Fix mozilla#63 - Replace % with string formats
  • Loading branch information
Michael Kelly committed Nov 6, 2012
2 parents 1c23655 + ec96060 commit d85b077
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions django_browserid/auth.py
Expand Up @@ -81,7 +81,7 @@ def authenticate(self, assertion=None, audience=None):
# log and bail. randomly selecting one seems really wrong.
users = self.filter_users_by_email(email=email)
if len(users) > 1:
log.warn('%d users with email address %s.' % (len(users), email))
log.warn('{0} users with email address {1}.'.format(len(users), email))
return None
if len(users) == 1:
return users[0]
Expand Down Expand Up @@ -125,6 +125,6 @@ def _load_module(self, path):
try:
create_user = getattr(mod, attr)
except AttributeError:
raise ImproperlyConfigured('Module "%s" does not define a "%s" '
'function.' % (module, attr))
raise ImproperlyConfigured('Module {0} does not define a {1} '
'function.'.format(module, attr))
return create_user
17 changes: 8 additions & 9 deletions django_browserid/base.py
Expand Up @@ -82,9 +82,9 @@ def get_audience(request):

req_url = "%s%s" % (req_proto, req_domain)
if site_url != "%s%s" % (req_proto, req_domain):
log.warning('Misconfigured SITE_URL? settings has [%s], but '
'actual request was [%s] BrowserID may fail on '
'audience' % (site_url, req_url))
log.warning('Misconfigured SITE_URL? settings has {0}, but '
'actual request was {1} BrowserID may fail on '
'audience'.format(site_url, req_url))
return site_url


Expand All @@ -106,8 +106,7 @@ def _verify_http_request(url, qs):
try:
rv = json.loads(r.content)
except ValueError:
log.debug('Failed to decode JSON. Resp: %s, Content: %s' %
(r.status_code, r.content))
log.debug('Failed to decode JSON. Resp: {0}, Content: {1}'.format(r.status_code, r.content))
return dict(status='failure')

return rv
Expand All @@ -118,7 +117,7 @@ def verify(assertion, audience):
verify_url = getattr(settings, 'BROWSERID_VERIFICATION_URL',
DEFAULT_VERIFICATION_URL)

log.info("Verification URL: %s" % verify_url)
log.info("Verification URL: {0}".format(verify_url))

result = _verify_http_request(verify_url, urllib.urlencode({
'assertion': assertion,
Expand All @@ -128,7 +127,7 @@ def verify(assertion, audience):
if result['status'] == OKAY_RESPONSE:
return result

log.error('BrowserID verification failure. Response: %r '
'Audience: %r' % (result, audience))
log.error("BID assert: %r" % assertion)
log.error('BrowserID verification failure. Response: {0} '
'Audience: {1}'.format(result, audience))
log.error("BID assert: {0}".format(assertion))
return False

0 comments on commit d85b077

Please sign in to comment.