Skip to content

Commit

Permalink
Don't use requests ok code (Qiskit#94)
Browse files Browse the repository at this point in the history
* fix catching exception

* update provider version
  • Loading branch information
jyu00 authored and GitHub Enterprise committed Nov 10, 2021
1 parent a0f0d12 commit a626561
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ stage_generic: &stage_linux
install:
- pip install -U -r requirements.txt
- pip install -U -r requirements-dev.txt
- pip install -I git+https://github.com/Qiskit/qiskit-ibmq-provider.git@runtime-release-q4

###############################################################################
# Stage-related definitions
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
qiskit-optimization
qiskit-ibmq-provider
qiskit-ibmq-provider>=0.18
qiskit-nature
pyyaml
requests
11 changes: 7 additions & 4 deletions tools/cloud_rt.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ def _get_url_token(self):
def _make_request(self, url, func, **kwargs):
headers = self._header.copy()
headers.update(kwargs.pop("headers", {}))
response = func(url, headers=headers, **kwargs)
if response.status_code != requests.codes.ok:
LOG.error("Bad request: %s", response.text)
response.raise_for_status()
try:
response = func(url, headers=headers, **kwargs)
response.raise_for_status()
except requests.RequestException as ex:
if ex.response is not None:
LOG.error("%s: %s", str(ex), ex.response.text)
raise
return response
11 changes: 7 additions & 4 deletions tools/legacy_rt.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ def _get_url_token(self):
def _make_request(self, url, func, **kwargs):
headers = self._header.copy()
headers.update(kwargs.pop("headers", {}))
response = func(url, headers=headers, **kwargs)
if response.status_code != requests.codes.ok:
LOG.error("Bad request: %s", response.text)
response.raise_for_status()
try:
response = func(url, headers=headers, **kwargs)
response.raise_for_status()
except requests.RequestException as ex:
if ex.response is not None:
LOG.error("%s: %s", str(ex), ex.response.text)
raise
return response

0 comments on commit a626561

Please sign in to comment.