From e504128ae7dedf5b569d2b78e46b1d5136aa3747 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Thu, 28 Sep 2023 13:58:02 +0200 Subject: [PATCH] switched to requests --- InvenTree/InvenTree/exchange.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/InvenTree/InvenTree/exchange.py b/InvenTree/InvenTree/exchange.py index c186b8023d..29dd74a0ed 100644 --- a/InvenTree/InvenTree/exchange.py +++ b/InvenTree/InvenTree/exchange.py @@ -1,12 +1,10 @@ -"""Exchangerate backend to use `exchangerate.host` to get rates.""" +"""Exchangerate backend to use `frankfurter.app` to get rates.""" -import ssl from urllib.error import URLError -from urllib.request import urlopen from django.db.utils import OperationalError -import certifi +import requests from djmoney.contrib.exchange.backends.base import SimpleExchangeBackend from common.settings import currency_code_default, currency_codes @@ -40,9 +38,8 @@ class InvenTreeExchange(SimpleExchangeBackend): url = self.get_url(**kwargs) try: - context = ssl.create_default_context(cafile=certifi.where()) - response = urlopen(url, timeout=5, context=context) - return response.read() + response = requests.get(url=url, timeout=5) + return response.content except Exception: # Something has gone wrong, but we can just try again next time # Raise a TypeError so the outer function can handle this