# Path: sc/client.py
# class scClient(docker.Client):
#     def __init__(self, *args, **kwargs):
#     def commit(self, container, *args, **kwargs):
#     def build(self, *args, **kwargs):
#     def put_label_image(self, image, label, *args, **kwargs):
#     def fileCopyOut(self, containerid, filename, path):
#     def fileCopyIn(self, containerid, filename, path):
#     def hasProv(self, containerid, filename, path):
#     def simple_tar(self, path):
#     def infect_image(self, image, *args, **kwargs):
#     def get_label_image(self, imageID):
#     def get_label_container(self, containerID):
#         BP = buildProcessor.buildProcessor()


import os
import stat
import pytest
from sc import client
from docker import tls


@pytest.fixture(scope="session")
def createClient():
    myclient = None
    # Find docker-machine environment variables
    docker_host = os.getenv("DOCKER_HOST")
    docker_cert_path = os.getenv("DOCKER_CERT_PATH")
    docker_machine_name = os.getenv("DOCKER_MACHINE_NAME")

    # Look for linux docker socket file
    path = "/var/run/docker.sock"
    isSocket = False
    if os.path.exists(path):
        mode = os.stat(path).st_mode
        isSocket = stat.S_ISSOCK(mode)
    if isSocket:
        docker_socket_file ="unix://"+path
        myclient = client.scClient(base_url=docker_socket_file, version="auto")
        return myclient
    elif (docker_host and docker_cert_path and docker_machine_name):
        tls_config = tls.TLSConfig(
            client_cert=(os.path.join(docker_cert_path, 'cert.pem'),
                         os.path.join(docker_cert_path,'key.pem')),
            ca_cert=os.path.join(docker_cert_path, 'ca.pem'),
            verify=True,
            assert_hostname = False
        )
        docker_host_https = docker_host.replace("tcp","https")

# Path: sc/client.py
# class scClient(docker.Client):
#     def __init__(self, *args, **kwargs):
#     def commit(self, container, *args, **kwargs):
#     def build(self, *args, **kwargs):
#     def put_label_image(self, image, label, *args, **kwargs):
#     def fileCopyOut(self, containerid, filename, path):
#     def fileCopyIn(self, containerid, filename, path):
#     def hasProv(self, containerid, filename, path):
#     def simple_tar(self, path):
#     def infect_image(self, image, *args, **kwargs):
#     def get_label_image(self, imageID):
#     def get_label_container(self, containerID):
#         BP = buildProcessor.buildProcessor()


# Path: tests/unit/conftest.py
import os
import stat
import pytest
from sc import client
from docker import tls



@pytest.fixture(scope="session")
def createClient():
    myclient = None
    # Find docker-machine environment variables
    docker_host = os.getenv("DOCKER_HOST")
    docker_cert_path = os.getenv("DOCKER_CERT_PATH")
    docker_machine_name = os.getenv("DOCKER_MACHINE_NAME")

    # Look for linux docker socket file
    path = "/var/run/docker.sock"
    isSocket = False
    if os.path.exists(path):
        mode = os.stat(path).st_mode
        isSocket = stat.S_ISSOCK(mode)
    if isSocket:
        docker_socket_file ="unix://"+path
        myclient = client.scClient(base_url=docker_socket_file, version="auto")
        return myclient
    elif (docker_host and docker_cert_path and docker_machine_name):
        tls_config = tls.TLSConfig(
            client_cert=(os.path.join(docker_cert_path, 'cert.pem'),
                         os.path.join(docker_cert_path,'key.pem')),
            ca_cert=os.path.join(docker_cert_path, 'ca.pem'),
            verify=True,
            assert_hostname = False
        )
        docker_host_https = docker_host.replace("tcp","https")

        myclient = client.scClient(base_url=docker_host_https, tls=tls_config,