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:
...
@@ -131,34 +131,29 @@ class ConnectionHelper:
path
=
path
[
1
:]
path
=
path
[
1
:]
# raise ValueError('method path should be relative: %s' % path)
# raise ValueError('method path should be relative: %s' % path)
try
:
if
url
.
startswith
(
'https'
):
if
url
.
startswith
(
'https'
):
cert
=
(
self
.
cert_file
,
self
.
key_file
)
cert
=
(
self
.
cert_file
,
self
.
key_file
)
else
:
else
:
cert
=
None
cert
=
None
# XXX TODO: handle host cert verify
try
:
req
=
method
(
url
=
url
,
req
=
method
(
url
=
url
,
params
=
params
,
params
=
params
,
cert
=
cert
,
cert
=
cert
,
# XXX TODO: handle host cert verify
verify
=
False
,
verify
=
False
,
data
=
data
,
data
=
data
,
headers
=
headers
,
headers
=
headers
,
timeout
=
self
.
timeout
)
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
:
except
(
requests
.
Timeout
,
requests
.
ConnectionError
)
as
exc
:
raise
ConnectionError
(
"Couldn't connect to the server. Please "
raise
ConnectionError
(
"Couldn't connect to the server. Please "
"double check given master-url argument, and make sure that IPv6 is "
"double check given master-url argument, and make sure that IPv6 is "
"enabled on your machine and that the server is available. The "
"enabled on your machine and that the server is available. The "
"original error was:
\
n
%s"
%
exc
)
"original error was:
\
n
%s"
%
exc
)
except
requests
.
HTTPError
as
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:
if exc.response.status_code == requests.status_codes.codes.not_found:
msg = url
msg = url
if params:
if params:
...
@@ -170,7 +165,8 @@ class ConnectionHelper:
...
@@ -170,7 +165,8 @@ class ConnectionHelper:
# XXX TODO test request timeout and resource not found
# XXX TODO test request timeout and resource not found
else:
else:
# we don't know how or don't want to handle these (including Unauthorized)
# 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
:
except
requests
.
exceptions
.
SSLError
as
exc
:
raise
AuthenticationError
(
"%s
\
n
Couldn't authenticate computer. Please "
raise
AuthenticationError
(
"%s
\
n
Couldn't authenticate computer. Please "
"check that certificate and key exist and are valid."
%
exc
)
"check that certificate and key exist and are valid."
%
exc
)
...
@@ -182,6 +178,14 @@ class ConnectionHelper:
...
@@ -182,6 +178,14 @@ class ConnectionHelper:
# path)
# path)
# raise ServerError(message)
# 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
return
req
def
callJsonRpcAPI
(
self
,
path
,
data
,
cert_key
=
None
):
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