Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
Fix runscope session mount
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Vetter committed Nov 4, 2013
1 parent 7871f91 commit 13dde4c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions oscar_mws/api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Basic interface to Amazon MWS
# Based on http://code.google.com/p/amazon-mws-python
# This API client for Amazon's MWS is based on the python-amazon-mws package
# available here: https://github.com/czpython/python-amazon-mws
import hmac
import urllib
import base64
Expand All @@ -20,7 +20,6 @@
except ImportError:
from xml.parsers.expat import ExpatError as XMLError

from requests import request
from requests.sessions import Session
from requests.exceptions import HTTPError

Expand Down Expand Up @@ -148,7 +147,8 @@ def __init__(self, access_key, secret_key, account_id,
self.session = Session()

bucket_key = getattr(settings, 'RUNSCOPE_BUCKET_KEY', None)
if settings.DEBUG and bucket_key:
if bucket_key:
logger.info("Redirecting API calls for MWS to runscope")
self.configure_runscope(bucket_key)

def configure_runscope(self, bucket_key):
Expand All @@ -166,13 +166,13 @@ def configure_runscope(self, bucket_key):
"installed? Try running pip install requests-runscope."
)
else:
logger.debug(
logger.info(
'Mounting runscope proxy adapter for bucket {}'.format(
bucket_key
)
)
self.session.mount('http://', RunscopeAdapter(bucket_key))
self.session.mount('https://', RunscopeAdapter(bucket_key))
self.session.mount('http://', RunscopeAdapter(bucket_key))

def _get_quote_params(self, params):
quoted_params = []
Expand Down Expand Up @@ -220,8 +220,8 @@ def make_request(self, extra_data, method="GET", **kwargs):
# params dict as params to request, request will repeat that step
# because it will need to convert the dict to a url parsed string,
# so why do it twice if i can just pass the full url :).
response = request(method, url, data=kwargs.get('body', ''),
headers=headers)
response = self.session.request(
method, url, data=kwargs.get('body', ''), headers=headers)
response.raise_for_status()
# When retrieving data from the response object, be aware that
# response.content returns the content in bytes while response.text
Expand Down

0 comments on commit 13dde4c

Please sign in to comment.