Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Romain Courteaud
slapos.core
Commits
70ccd32a
Commit
70ccd32a
authored
Jan 23, 2025
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slap/hateoas: reduce number of errors catched/rewriten by do_request
parent
8600945f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
15 deletions
+19
-15
slapos/slap/hateoas.py
slapos/slap/hateoas.py
+19
-15
No files found.
slapos/slap/hateoas.py
View file @
70ccd32a
...
...
@@ -131,34 +131,29 @@ class ConnectionHelper:
path
=
path
[
1
:]
# raise ValueError('method path should be relative: %s' % path)
try
:
if
url
.
startswith
(
'https'
):
cert
=
(
self
.
cert_file
,
self
.
key_file
)
else
:
cert
=
None
# XXX TODO: handle host cert verify
try
:
req
=
method
(
url
=
url
,
params
=
params
,
cert
=
cert
,
# XXX TODO: handle host cert verify
verify
=
False
,
data
=
data
,
headers
=
headers
,
timeout
=
self
.
timeout
)
try
:
req
.
raise_for_status
()
except
TypeError
:
# In Py3, a comparison between NoneType and int can occur if req has no
# status_code (= None).
pass
except
(
requests
.
Timeout
,
requests
.
ConnectionError
)
as
exc
:
raise
ConnectionError
(
"Couldn't connect to the server. Please "
"double check given master-url argument, and make sure that IPv6 is "
"enabled on your machine and that the server is available. The "
"original error was:
\
n
%s"
%
exc
)
except
requests
.
HTTPError
as
exc
:
raise
# XXX Desactivated by Romain, to get ride of custom slaptool behaviour
"""
if exc.response.status_code == requests.status_codes.codes.not_found:
msg = url
if params:
...
...
@@ -170,7 +165,8 @@ class ConnectionHelper:
# XXX TODO test request timeout and resource not found
else:
# we don't know how or don't want to handle these (including Unauthorized)
req
.
raise_for_status
()
raise
"""
except
requests
.
exceptions
.
SSLError
as
exc
:
raise
AuthenticationError
(
"%s
\
n
Couldn't authenticate computer. Please "
"check that certificate and key exist and are valid."
%
exc
)
...
...
@@ -182,6 +178,14 @@ class ConnectionHelper:
# path)
# raise ServerError(message)
try
:
req
.
raise_for_status
()
except
TypeError
:
# In Py3, a comparison between NoneType and int can occur if req has no
# status_code (= None).
# pass
# XXX Desactivated by Romain, as we expect a status code
raise
return
req
def
callJsonRpcAPI
(
self
,
path
,
data
,
cert_key
=
None
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment