import time
from retry.api import retry_call
import re
+from requests.exceptions import RequestException
+from ssl import SSLError
def _cw_exchange_sum(self, *args):
return sum([arg for arg in args if isinstance(arg, (float, int, decimal.Decimal))])
self.session._parent = self
def request_wrap(self, *args, **kwargs):
- r = self.origin_request(*args, **kwargs)
- self._parent._market.report.log_http_request(args[0],
- args[1], kwargs["data"], kwargs["headers"], r)
- return r
+ kwargs["headers"]["X-market-id"] = str(self._parent._market.market_id)
+ kwargs["headers"]["X-user-id"] = str(self._parent._market.user_id)
+ try:
+ r = self.origin_request(*args, **kwargs)
+ self._parent._market.report.log_http_request(args[0],
+ args[1], kwargs["data"], kwargs["headers"], r)
+ return r
+ except (SSLError, RequestException) as e:
+ self._parent._market.report.log_http_request(args[0],
+ args[1], kwargs["data"], kwargs["headers"], e)
+ raise e
+
self.session.request = request_wrap.__get__(self.session,
self.session.__class__)
else:
raise NotImplementedError
+ def common_currency_code(self, currency):
+ """
+ Wrapped to avoid the currency translation
+ """
+ return currency
+ def currency_id(self, currency):
+ """
+ Wrapped to avoid the currency translation
+ """
+ return currency