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
0fa38190
Commit
0fa38190
authored
Aug 23, 2017
by
David Trudgian
Browse files
Travis flake8 / source flake8 fixes
parent
4329be5e
Changes
9
Hide whitespace changes
Inline
Side-by-side
.travis.yml
View file @
0fa38190
...
...
@@ -7,6 +7,6 @@ python:
-
"
3.6"
install
:
-
pip install --only-binary=numpy,scipy,scikit-learn numpy scipy scikit-learn
-
pip install flake8
-
pip install flake8
pytest pytest-cov pytest-flake8
-
python setup.py install
script
:
pytest --cov
script
:
pytest --cov
--flake8
clair_singularity/clair.py
View file @
0fa38190
...
...
@@ -27,9 +27,7 @@ def post_layer(API_URI, image_name, image_uri):
"Path"
:
image_uri
,
"Format"
:
"Docker"
}
}
)
})
if
r
.
status_code
==
requests
.
codes
.
created
:
sys
.
stderr
.
write
(
"Image registered as layer with Clair
\n
"
)
...
...
clair_singularity/cli.py
View file @
0fa38190
import
click
import
json
from
os
import
path
import
shutil
from
multiprocessing
import
Process
from
.clair
import
*
from
.clair
import
check_clair
,
post_layer
,
get_report
,
format_report_text
from
.util
import
sha256
from
.image
import
*
from
.image
import
check_image
,
image_to_tgz
,
http_server
@
click
.
command
()
@
click
.
option
(
'--clair-uri'
,
default
=
"http://localhost:6060"
,
help
=
'Base URI for your Clair server'
)
@
click
.
option
(
'--clair-uri'
,
default
=
"http://localhost:6060"
,
help
=
'Base URI for your Clair server'
)
@
click
.
option
(
'--text-output'
,
is_flag
=
True
,
help
=
'Report in Text (Default)'
)
@
click
.
option
(
'--json-output'
,
is_flag
=
True
,
help
=
'Report in JSON'
)
@
click
.
option
(
'--bind-ip'
,
default
=
"127.0.0.1"
,
help
=
'IP address that the HTTP server providing image to Clair should listen on'
)
@
click
.
option
(
'--bind-port'
,
default
=
8088
,
help
=
'Port that the HTTP server providing image to Clair should listen on'
)
@
click
.
option
(
'--bind-port'
,
default
=
8088
,
help
=
'Port that the HTTP server providing image to Clair should listen on'
)
@
click
.
argument
(
'image'
,
required
=
True
)
def
main
(
image
,
clair_uri
,
text_output
,
json_output
,
bind_ip
,
bind_port
):
API_URI
=
clair_uri
+
'/v1/'
...
...
@@ -51,5 +55,3 @@ def main(image, clair_uri, text_output, json_output, bind_ip, bind_port):
click
.
echo
(
pretty_report
)
else
:
format_report_text
(
report
)
clair_singularity/image.py
View file @
0fa38190
...
...
@@ -45,6 +45,7 @@ def image_to_tgz(image):
return
(
temp_dir
,
tar_gz_file
)
def
http_server
(
dir
,
ip
,
port
):
"""Use Python's Simple HTTP server to expose the image over HTTP for
clair to grab it.
...
...
clair_singularity/util.py
View file @
0fa38190
import
hashlib
def
sha256
(
fname
):
hash_sha256
=
hashlib
.
sha256
()
with
open
(
fname
,
"rb"
)
as
f
:
for
chunk
in
iter
(
lambda
:
f
.
read
(
65536
),
b
""
):
hash_sha256
.
update
(
chunk
)
return
hash_sha256
.
hexdigest
()
\ No newline at end of file
return
hash_sha256
.
hexdigest
()
setup.cfg
View file @
0fa38190
[wheel]
universal = 1
[aliases]
test=pytest
[tool:pytest]
flake8-max-line-length = 99
\ No newline at end of file
setup.py
View file @
0fa38190
...
...
@@ -19,7 +19,7 @@ setup(
platforms
=
'any'
,
install_requires
=
dependencies
,
setup_requires
=
[
'pytest-runner'
],
tests_require
=
[
'pytest'
,
'pytest-cov'
],
tests_require
=
[
'pytest'
,
'pytest-cov'
,
'pytest-flake8'
],
entry_points
=
{
'console_scripts'
:
[
'clair-singularity = clair_singularity.cli:main'
,
...
...
tests/__init__.py
View file @
0fa38190
tests/test_cli.py
View file @
0fa38190
...
...
@@ -7,5 +7,6 @@ from clair_singularity import cli
def
runner
():
return
CliRunner
()
def
test_help
(
runner
):
result
=
runner
.
invoke
(
cli
,
[
'--help'
])
runner
.
invoke
(
cli
,
[
'--help'
])
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