Skip to content

Commit

Permalink
replace requests exceptions and import urllib3
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Feb 8, 2024
1 parent 7242082 commit 884fb79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/pyDataverse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
Licensed under the MIT License.
"""

from __future__ import absolute_import

from requests.packages import urllib3
import urllib3

urllib3.disable_warnings() # noqa

Expand Down
18 changes: 9 additions & 9 deletions src/pyDataverse/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import subprocess as sp
from urllib.parse import urljoin

from requests import ConnectionError, Response, delete, get, post, put
from httpx import ConnectError, Response

from pyDataverse.exceptions import (
ApiAuthorizationError,
Expand Down Expand Up @@ -139,8 +139,8 @@ def get_request(self, url, params=None, auth=False):
)
)
return resp
except ConnectionError:
raise ConnectionError(
except ConnectError:
raise ConnectError(
"ERROR: GET - Could not establish connection to api {0}.".format(url)
)

Expand Down Expand Up @@ -184,8 +184,8 @@ def post_request(self, url, data=None, auth=False, params=None, files=None):
)
)
return resp
except ConnectionError:
raise ConnectionError(
except ConnectError:
raise ConnectError(
"ERROR: POST - Could not establish connection to API: {0}".format(url)
)

Expand Down Expand Up @@ -225,8 +225,8 @@ def put_request(self, url, data=None, auth=False, params=None):
)
)
return resp
except ConnectionError:
raise ConnectionError(
except ConnectError:
raise ConnectError(
"ERROR: PUT - Could not establish connection to api '{0}'.".format(url)
)

Expand Down Expand Up @@ -256,8 +256,8 @@ def delete_request(self, url, auth=False, params=None):

try:
return httpx.delete(url, params=params)
except ConnectionError:
raise ConnectionError(
except ConnectError:
raise ConnectError(
"ERROR: DELETE could not establish connection to api {}.".format(url)
)

Expand Down

0 comments on commit 884fb79

Please sign in to comment.