Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
BioHPC
clair-singularity
Commits
4a393379
Commit
4a393379
authored
Aug 24, 2017
by
David Trudgian
Browse files
Fix pretty_json calls
parent
e922c53c
Changes
2
Hide whitespace changes
Inline
Side-by-side
clair_singularity/clair.py
View file @
4a393379
...
@@ -38,7 +38,7 @@ def post_layer(API_URI, image_name, image_uri, quiet):
...
@@ -38,7 +38,7 @@ def post_layer(API_URI, image_name, image_uri, quiet):
if
not
quiet
:
if
not
quiet
:
sys
.
stderr
.
write
(
"Image registered as layer with Clair
\n
"
)
sys
.
stderr
.
write
(
"Image registered as layer with Clair
\n
"
)
else
:
else
:
raise
ClairException
(
"Failed registering image with Clair
\n
%s
\n
"
%
pretty_json
(
r
))
raise
ClairException
(
"Failed registering image with Clair
\n
%s
\n
"
%
pretty_json
(
r
.
json
()
))
except
Exception
as
e
:
except
Exception
as
e
:
raise
ClairException
(
"Error - couldn't send image to Clair - %s
\n
"
%
(
e
))
raise
ClairException
(
"Error - couldn't send image to Clair - %s
\n
"
%
(
e
))
...
@@ -53,7 +53,7 @@ def get_report(API_URI, image_name):
...
@@ -53,7 +53,7 @@ def get_report(API_URI, image_name):
if
r
.
status_code
==
requests
.
codes
.
ok
:
if
r
.
status_code
==
requests
.
codes
.
ok
:
return
r
.
json
()
return
r
.
json
()
else
:
else
:
raise
ClairException
(
"Failed retrieving report from Clair
\n
%s
\n
"
%
pretty_json
(
r
))
raise
ClairException
(
"Failed retrieving report from Clair
\n
%s
\n
"
%
pretty_json
(
r
.
json
()
))
except
Exception
as
e
:
except
Exception
as
e
:
raise
ClairException
(
"Error - couldn't retrieve report from Clair - %s
\n
"
%
(
e
))
raise
ClairException
(
"Error - couldn't retrieve report from Clair - %s
\n
"
%
(
e
))
...
...
clair_singularity/util.py
View file @
4a393379
...
@@ -14,7 +14,7 @@ def sha256(fname):
...
@@ -14,7 +14,7 @@ def sha256(fname):
def
pretty_json
(
obj
):
def
pretty_json
(
obj
):
"""Format an object into json nicely"""
"""Format an object into json nicely"""
return
json
.
dumps
(
obj
.
json
()
,
separators
=
(
','
,
':'
),
sort_keys
=
True
,
indent
=
2
)
return
json
.
dumps
(
obj
,
separators
=
(
','
,
':'
),
sort_keys
=
True
,
indent
=
2
)
def
err_and_exit
(
message
,
code
=
1
):
def
err_and_exit
(
message
,
code
=
1
):
...
...
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