Commit 0fa38190 authored by David Trudgian's avatar David Trudgian
Browse files

Travis flake8 / source flake8 fixes

parent 4329be5e
......@@ -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
......@@ -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")
......
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)
......@@ -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.
......
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()
[wheel]
universal = 1
[aliases]
test=pytest
[tool:pytest]
flake8-max-line-length = 99
\ No newline at end of file
......@@ -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',
......
......@@ -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'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment