Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Updated requests (bug 861420)
Browse files Browse the repository at this point in the history
  • Loading branch information
robhudson committed Apr 19, 2013
1 parent 06d5c13 commit 2bc6ad7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
2 changes: 0 additions & 2 deletions apps/amo/management/commands/install_landfill.py
Expand Up @@ -11,8 +11,6 @@
from django.conf import settings
from django.core.management.base import BaseCommand

import requests

from zadmin.models import Config


Expand Down
2 changes: 1 addition & 1 deletion apps/amo/monitors.py
Expand Up @@ -224,7 +224,7 @@ def signer():
msg = cert_err_msg % (location, resp.reason)
return msg, msg

cert_json = resp.json
cert_json = resp.json()
if not cert_json or not 'jwk' in cert_json:
msg = cert_err_msg % (location, 'Not valid JSON/JWK')
return msg, msg
Expand Down
10 changes: 5 additions & 5 deletions lib/es/management/commands/reindex.py
Expand Up @@ -86,7 +86,7 @@ def call_es(path, *args, **kw):
if res.status_code not in status:
error = CommandError('Call on %r failed.\n%s' % (path, res.content))
error.content = res.content
error.json = res.json
error.json = res.json()
raise error

return res
Expand Down Expand Up @@ -132,7 +132,7 @@ def run_aliases_actions(actions):
call_es('_aliases', post_data, method='POST')
except CommandError, e:
# XXX Did not find a better way to extract the info
error = e.json['error']
error = e.json()['error']
res = re.search('(Invalid alias name \[)(?P<index>.*?)(\])', error)
if res is None:
raise
Expand All @@ -159,7 +159,7 @@ def create_mapping(new_index, alias, num_replicas=DEFAULT_NUM_REPLICAS,
log('Create the mapping for index %r, alias: %r' % (new_index, alias))

if requests.head(url('/' + alias)).status_code == 200:
res = call_es('%s/_settings' % (alias)).json
res = call_es('%s/_settings' % (alias)).json()
idx_settings = res.get(alias, {}).get('settings', {})
else:
idx_settings = {}
Expand Down Expand Up @@ -290,7 +290,7 @@ def handle(self, *args, **kwargs):
unflag_database()

# Get list current aliases at /_aliases.
all_aliases = requests.get(url('/_aliases')).json
all_aliases = requests.get(url('/_aliases')).json()

# building the list of indexes
indexes = set([prefix + index for index in
Expand Down Expand Up @@ -373,6 +373,6 @@ def add_action(*elmt):
sys.stdout.write('\n')

# let's return the /_aliases values
aliases = call_es('_aliases').json
aliases = call_es('_aliases').json()
aliases = json.dumps(aliases, sort_keys=True, indent=4)
return _SUMMARY % (len(indexes), aliases)
8 changes: 4 additions & 4 deletions lib/es/tests/test_commands.py
Expand Up @@ -46,14 +46,14 @@ def setUp(self):
target.write(f.read() % data)

# any index created during the test will be deleted
self.indices = call_es('_status').json['indices'].keys()
self.indices = call_es('_status').json()['indices'].keys()

def tearDown(self):
for file_ in (self.target, self.target_pyc):
if os.path.exists(file_):
os.remove(file_)

current_indices = call_es('_status').json['indices'].keys()
current_indices = call_es('_status').json()['indices'].keys()
for index in current_indices:
if index not in self.indices:
call_es(index, method='DELETE')
Expand Down Expand Up @@ -112,7 +112,7 @@ def test_reindexation(self):
# right now, the DB should be composed of
# two indexes, and two aliases, let's check
# we have two aliases
aliases = call_es('_aliases').json
aliases = call_es('_aliases').json()
old_aliases = [(index, aliases['aliases'].keys()[0])
for index, aliases in aliases.items()
if len(aliases['aliases']) > 0 and
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_reindexation(self):
self.check_results({'sort': 'popularity'}, wanted)

# let's check the aliases as well, we should have 2
aliases = call_es('_aliases').json
aliases = call_es('_aliases').json()
new_aliases = [(index, aliases['aliases'].keys()[0])
for index, aliases in aliases.items()
if len(aliases['aliases']) > 0 and
Expand Down
2 changes: 1 addition & 1 deletion requirements/prod.txt
Expand Up @@ -74,7 +74,7 @@ raven==3.1.16
rdflib==3.0.0
recaptcha-client==1.0.5
receipts==0.2.6
requests==0.14.0
requests==1.2.0
schematic==0.2
signing_clients==0.1.3
slumber==0.5.3
Expand Down

0 comments on commit 2bc6ad7

Please sign in to comment.