Skip to content

Commit

Permalink
Add message for 403
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvaingaudan committed Nov 4, 2024
1 parent 3a5dce8 commit 34c6844
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions arlas/cli/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def __arlas__(arlas: str, suffix, post=None, put=None, patch=None, delete=None,
if delete:
method = "DELETE"
r: requests.Response = Service.__request__(url, method, data, __headers__)
if r.ok:
if r.status_code >= 200 and r.status_code < 300:
return r.json()
else:
print("Error: request {} failed with status {}: {}".format(method, str(r.status_code), str(r.reason)), file=sys.stderr)
Expand Down Expand Up @@ -496,12 +496,14 @@ def __es__(arlas: str, suffix, post=None, put=None, delete=None, exit_on_failure
if delete is not None:
method = "DELETE"
r: requests.Response = Service.__request__(url, method, data, __headers, auth)
if r.ok:
if r.status_code >= 200 and r.status_code < 300:
return r.content
elif exit_on_failure:
print("Error: request {} failed with status {}: {}".format(method, str(r.status_code), str(r.reason)), file=sys.stderr)
print(" url: {}".format(url), file=sys.stderr)
print(r.content)
if r.status_code == 403:
print("IMPORTANT: This error occurs because you are not allowed to trigger this action. If you are using ARLAS Cloud, please check that you have not used up your quota. You can contact [email protected] for help.", file=sys.stderr)
exit(1)
else:
raise RequestException(r.status_code, r.content)
Expand Down Expand Up @@ -533,7 +535,7 @@ def __fetch__(resource: Resource, bytes: bool = False):
content = f.read()
return content
r: requests.Response = requests.get(resource.location, headers=resource.headers, verify=False)
if r.ok:
if r.status_code >= 200 and r.status_code < 300:
return r.content
else:
print("Error: request failed with status {}: {}".format(str(r.status_code), str(r.reason)), file=sys.stderr)
Expand Down

0 comments on commit 34c6844

Please sign in to comment.