# Path: processing/docker_utils.py
#     HAVE_DOCKER = True
#     HAVE_DOCKER = False
# def temp_volume(target):


import os
from shutil import copyfile
from fame.core.module import ProcessingModule, ModuleInitializationError
from fame.common.utils import tempdir
from ..docker_utils import HAVE_DOCKER, docker_client

        self.results["files"] = namelist

    def extract(self, file):
        args = '"{}" {} {}'.format(file, self.maximum_extracted_files, self.maximum_automatic_analyses)

        # start the right docker
        output = docker_client.containers.run(
            "fame/extract",
            args,
            volumes={self.outdir: {"bind": "/data", "mode": "rw"}},
            stderr=True,
            stdout=True,
            remove=True,
        )

        if type(output) is bytes:
            output = output.decode("utf-8", errors="replace")

        return output

    def each(self, target):
        self.results = {"warnings": []}

        # Create temporary directory to get results
        self.outdir = tempdir()

        self.results_dir = os.path.join(self.outdir, "output")

        if not os.path.isdir(self.results_dir):

# Path: processing/docker_utils.py
#     HAVE_DOCKER = True
#     HAVE_DOCKER = False
# def temp_volume(target):


# Path: processing/extract/extract.py
import os
from shutil import copyfile
from fame.core.module import ProcessingModule, ModuleInitializationError
from fame.common.utils import tempdir
from ..docker_utils import HAVE_DOCKER, docker_client


        self.results["files"] = namelist

    def extract(self, file):
        args = '"{}" {} {}'.format(file, self.maximum_extracted_files, self.maximum_automatic_analyses)

        # start the right docker
        output = docker_client.containers.run(
            "fame/extract",
            args,
            volumes={self.outdir: {"bind": "/data", "mode": "rw"}},
            stderr=True,
            stdout=True,
            remove=True,
        )

        if type(output) is bytes:
            output = output.decode("utf-8", errors="replace")

        return output

    def each(self, target):
        self.results = {"warnings": []}

        # Create temporary directory to get results
        self.outdir = tempdir()

        self.results_dir = os.path.join(self.outdir, "output")

        if not os.path.isdir(self.results_dir):

            os.mkdir(self.results_dir)