Esempio n. 1
0
    def env_check(self, *args, **kwargs):
        """
        DESC
            This method provides a common entry for any checks on the
            environment (input / output dirs, etc). Essentially, this
            method checks the at the <self.str_outputDir> was specified
            and that the <self.str_inputDir> exists.

        IMPLICIT INPUT
            self.str_outputDir
            self.str_inputDir

        RETURN
            {
                'status':       True|False
                'str_error':    Optional error message
            }
        """
        b_status = True
        str_error = ''
        if not len(self.str_outputDir):
            b_status = False
            str_error = 'output directory not specified.'
            self.dp.qprint(str_error, comms='error')
            error.fatal(self, 'outputDirFail', drawBox=True)
        if not os.path.isdir(self.str_inputDir):
            b_status = False
            str_error = 'input dirspec does seem to be a valid directory.'
            self.dp.qprint(str_error, comms='error')
            error.fatal(self, 'inputDirFail', drawBox=True)
        return {'status': b_status, 'str_error': str_error}
Esempio n. 2
0
        def analysis_do(path, data, index, **kwargs):
            nonlocal filesAnalyzed
            nonlocal d_tree
            nonlocal fn_analysisCallback

            self.simpleProgress_show(
                index, total,
                '%s:%s' % ('%25s' % threading.currentThread().getName(),
                           '%25s' % fn_analysisCallback.__name__))

            d_analysis = fn_analysisCallback(
                ('%s/%s' % (self.str_inputDir, path), d_tree[path]), **kwargs)

            if 'status' in d_analysis.keys():
                if d_analysis['status']:
                    # Analysis was successful
                    if len(str_applyKey):
                        d_tree[path] = d_analysis[str_applyKey]
                    else:
                        d_tree[path] = d_analysis
                    if 'filesAnalyzed' in d_analysis.keys():
                        filesAnalyzed += d_analysis['filesAnalyzed']
                    elif 'l_file' in d_analysis.keys():
                        filesAnalyzed += len(d_analysis['l_file'])
                else:
                    # If status was false, mark this key/path as
                    # None
                    d_tree[path] = None
            else:
                self.dp.qprint(
                    "The analysis callback did not return a 'status' value!",
                    comms='error',
                    level=0)
                error.fatal(self, 'analysisCallback', drawBox=True)
            return d_analysis
Esempio n. 3
0
        def inputSet_read(path, data):
            """
            The core canonical component that reads file sets
            from specific "leaf" nodes in the <inputDir>.
            """
            nonlocal filesRead
            nonlocal index
            nonlocal d_tree
            nonlocal fn_inputReadCallback

            self.simpleProgress_show(
                index, total,
                '%s:%s' % ('%25s' % threading.currentThread().getName(),
                           '%25s' % fn_inputReadCallback.__name__))

            d_read = fn_inputReadCallback(
                ('%s/%s' % (self.str_inputDir, path), data), **kwargs)

            if 'status' in d_read.keys():
                d_tree[path] = d_read
                if 'filesRead' in d_read.keys():
                    filesRead += d_read['filesRead']
            else:
                self.dp.qprint(
                    "The inputReadCallback callback did not return a 'status' value!",
                    comms='error',
                    level=0)
                error.fatal(self, 'inputReadCallback', drawBox=True)
            return d_read
Esempio n. 4
0
 def imageFileName_process(str_imageFile):
     b_OK = False
     l_indexAndFile = str_imageFile.split(':')
     if len(l_indexAndFile) == 1:
         b_OK = True
         self.str_outputImageFile = l_indexAndFile[0]
     if len(l_indexAndFile) == 2:
         b_OK = True
         self.str_outputImageFile = l_indexAndFile[1]
         self.str_imageIndex = l_indexAndFile[0]
     if not b_OK:
         self.dp.qprint("Invalid image specifier.", comms='error')
         error.fatal(self, 'imageFileSpecFail', drawBox=True)
     if len(self.str_outputImageFile):
         self.b_convertToImg = True
Esempio n. 5
0
        def outputSet_write(path, data):
            """
            The core canonical component that writes file sets
            to specific leaf nodes in the <outputDir>.
            """
            nonlocal filesSaved
            nonlocal index
            nonlocal d_tree
            nonlocal fn_analysisCallback
            nonlocal b_persistAnalysisResults

            self.simpleProgress_show(
                index, total,
                '%s:%s' % ('%25s' % threading.currentThread().getName(),
                           '%25s' % fn_outputWriteCallback.__name__))

            if len(self.str_outputLeafDir):
                (dirname, basename) = os.path.split(path)
                str_format = '\'%s\'' % self.str_outputLeafDir
                new_basename = str_format + ' % basename'
                str_eval = eval(new_basename)
                path = '%s/%s' % (dirname, str_eval)

            d_output = fn_outputWriteCallback(
                ('%s/%s' % (self.str_outputDir, path), data), **kwargs)

            if 'status' in d_output.keys():
                if not b_persistAnalysisResults:
                    d_tree[path] = d_output
                filesSaved += d_output['filesSaved']
            else:
                self.dp.qprint(
                    "The outputWriteCallback callback did not return a 'status' value!",
                    comms='error',
                    level=0)
                error.fatal(self, 'outputWriteCallback', drawBox=True)
            return d_output