Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
0
Merge Requests
0
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
Eric Zheng
slapos.toolbox
Commits
f81eb5ff
Commit
f81eb5ff
authored
Jul 01, 2021
by
Eric Zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add trailing commas and make logging lazy
parent
980b1276
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
slapos/promise/plugin/check_url_available.py
slapos/promise/plugin/check_url_available.py
+8
-8
slapos/test/promise/plugin/test_check_url_available.py
slapos/test/promise/plugin/test_check_url_available.py
+6
-6
No files found.
slapos/promise/plugin/check_url_available.py
View file @
f81eb5ff
...
...
@@ -57,15 +57,15 @@ class RunPromise(GenericPromise):
except
requests
.
exceptions
.
SSLError
as
e
:
if
'certificate verify failed'
in
str
(
e
):
self
.
logger
.
error
(
"ERROR SSL verify failed while accessing %r"
%
(
url
,)
)
"ERROR SSL verify failed while accessing %r"
,
url
)
else
:
self
.
logger
.
error
(
"ERROR Unknown SSL error %r while accessing %r"
%
(
e
,
url
)
)
"ERROR Unknown SSL error %r while accessing %r"
,
e
,
url
)
except
requests
.
ConnectionError
as
e
:
self
.
logger
.
error
(
"ERROR connection not possible while accessing %r"
%
(
url
,
)
)
"ERROR connection not possible while accessing %r"
,
url
)
except
Exception
as
e
:
self
.
logger
.
error
(
"ERROR: %s"
%
(
e
,)
)
self
.
logger
.
error
(
"ERROR: %s"
,
e
)
else
:
# Check that the returned status code is what we expected
...
...
@@ -73,12 +73,12 @@ class RunPromise(GenericPromise):
check_secure
=
int
(
self
.
getConfig
(
'check-secure'
,
0
))
if
http_code
==
401
and
check_secure
==
1
:
self
.
logger
.
info
(
"%r is protected (returned %s)."
%
(
url
,
http_code
)
)
self
.
logger
.
info
(
"%r is protected (returned %s)."
,
url
,
http_code
)
elif
not
ignore_code
and
http_code
!=
expected_http_code
:
self
.
logger
.
error
(
"%r is not available (returned %s, expected %s)."
%
(
url
,
http_code
,
expected_http_code
)
)
self
.
logger
.
error
(
"%r is not available (returned %s, expected %s)."
,
url
,
http_code
,
expected_http_code
)
else
:
self
.
logger
.
info
(
"%r is available"
%
(
url
,)
)
self
.
logger
.
info
(
"%r is available"
,
url
)
def
sense
(
self
):
"""
...
...
slapos/test/promise/plugin/test_check_url_available.py
View file @
f81eb5ff
...
...
@@ -288,7 +288,7 @@ extra_config_dict = {
'timeout': %(timeout)s,
'check-secure': %(check_secure)s,
'ignore-code': %(ignore_code)s,
'http_code': %(http_code)s
'http_code': %(http_code)s
,
}
"""
...
...
@@ -298,7 +298,7 @@ extra_config_dict = {
'url': '%(url)s',
'username': '%(username)s',
'password': '%(password)s',
'require-auth': %(require_auth)s
'require-auth': %(require_auth)s
,
}
"""
...
...
@@ -532,7 +532,7 @@ class TestCheckUrlAvailable(CheckUrlAvailableMixin):
'url'
:
url
,
'username'
:
TEST_GOOD_USERNAME
,
'password'
:
TEST_GOOD_PASSWORD
,
'require_auth'
:
1
'require_auth'
:
1
,
}
self
.
writePromise
(
self
.
promise_name
,
content
)
self
.
configureLauncher
()
...
...
@@ -554,7 +554,7 @@ class TestCheckUrlAvailable(CheckUrlAvailableMixin):
'url'
:
url
,
'username'
:
TEST_GOOD_USERNAME
,
'password'
:
TEST_GOOD_PASSWORD
,
'require_auth'
:
0
'require_auth'
:
0
,
}
self
.
writePromise
(
self
.
promise_name
,
content
)
self
.
configureLauncher
()
...
...
@@ -573,7 +573,7 @@ class TestCheckUrlAvailable(CheckUrlAvailableMixin):
'url'
:
url
,
'username'
:
TEST_BAD_USERNAME
,
'password'
:
TEST_BAD_PASSWORD
,
'require_auth'
:
1
'require_auth'
:
1
,
}
self
.
writePromise
(
self
.
promise_name
,
content
)
self
.
configureLauncher
()
...
...
@@ -598,7 +598,7 @@ class TestCheckUrlAvailable(CheckUrlAvailableMixin):
'url'
:
url
,
'username'
:
TEST_GOOD_USERNAME
,
'password'
:
TEST_GOOD_PASSWORD
,
'require_auth'
:
1
'require_auth'
:
1
,
}
self
.
writePromise
(
self
.
promise_name
,
content
)
self
.
configureLauncher
()
...
...
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