Skip to content

Commit

Permalink
Use self.auth.client instead of requests (per suggestion by @meksor)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann committed Aug 3, 2022
1 parent 515c153 commit 6224bd8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pyam/iiasa.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ def __init__(self, name=None, creds=None, auth_url=_AUTH_URL):
def _connection_map(self):
# TODO: application-list will be reimplemented in conjunction with ixmp-server
url = "/".join([self._auth_url, "legacy", "applications"])
r = requests.get(url, headers=self.auth())
_check_response(r, "Could not get valid connection list")
r = self.auth.client.get("legacy/applications", headers=self.auth())
if r.status_code >= 400:
raise ValueError("Unknown API error: " + r.text)
aliases = set()
conn_map = {}
for x in r.json():
Expand Down Expand Up @@ -227,9 +228,12 @@ def connect(self, name):
)

# TODO: config will be reimplemented in conjunction with ixmp-server
url = "/".join([self._auth_url, "legacy", "applications", name, "config"])
r = requests.get(url, headers=self.auth())
_check_response(r, "Could not get application information")
r = self.auth.client.get(
f"legacy/applications/{name}/config", headers=self.auth()
)
if r.status_code >= 400:
raise ValueError("Unknown API error: " + r.text)

response = r.json()
idxs = {x["path"]: i for i, x in enumerate(response)}

Expand Down

0 comments on commit 6224bd8

Please sign in to comment.