def read(self, read_list, verbose=False, log=False):
        """Read the content, returning a list of ReadingData objects."""
        ret = []
        mem_tot = _get_mem_total()
        if mem_tot is not None and mem_tot <= self.REACH_MEM + self.MEM_BUFFER:
            logger.error(
                "Too little memory to run reach. At least %s required." %
                (self.REACH_MEM + self.MEM_BUFFER)
                )
            logger.info("REACH not run.")
            return ret

        # Prep the content
        self.prep_input(read_list)

        if self.num_input > 0:
            # Run REACH!
            logger.info("Beginning reach.")
            args = [
                'java',
                '-Dconfig.file=%s' % self.conf_file_path,
                '-jar', self.exec_path
                ]
            p = subprocess.Popen(args, stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            log_file_str = ''
            for line in iter(p.stdout.readline, b''):
                log_line = 'REACH: ' + line.strip().decode('utf8')
                if verbose:
                    logger.info(log_line)
                if log:
                    log_file_str += log_line + '\n'
            if log:
                with open('reach_run.log', 'ab') as f:
                    f.write(log_file_str.encode('utf8'))
            p_out, p_err = p.communicate()
            if p.returncode:
                logger.error('Problem running REACH:')
                logger.error('Stdout: %s' % p_out.decode('utf-8'))
                logger.error('Stderr: %s' % p_err.decode('utf-8'))
                raise ReachError("Problem running REACH")
            logger.info("Reach finished.")
            ret = self.get_output()
            self.clear_input()
        return ret
def read ( self , read_list , verbose = False , log = False ) : ret = [ ] mem_tot = _get_mem_total ( ) if mem_tot is not None and mem_tot <= self . REACH_MEM + self . MEM_BUFFER : logger . error ( "Too little memory to run reach. At least %s required." % ( self . REACH_MEM + self . MEM_BUFFER ) ) logger . info ( "REACH not run." ) return ret self . prep_input ( read_list ) if self . num_input > 0 : logger . info ( "Beginning reach." ) args = [ 'java' , '-Dconfig.file=%s' % self . conf_file_path , '-jar' , self . exec_path ] p = subprocess . Popen ( args , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) log_file_str = '' for line in iter ( p . stdout . readline , b'' ) : log_line = 'REACH: ' + line . strip ( ) . decode ( 'utf8' ) if verbose : logger . info ( log_line ) if log : log_file_str += log_line + '\n' if log : with open ( 'reach_run.log' , 'ab' ) as f : f . write ( log_file_str . encode ( 'utf8' ) ) p_out , p_err = p . communicate ( ) if p . returncode : logger . error ( 'Problem running REACH:' ) logger . error ( 'Stdout: %s' % p_out . decode ( 'utf-8' ) ) logger . error ( 'Stderr: %s' % p_err . decode ( 'utf-8' ) ) raise ReachError ( "Problem running REACH" ) logger . info ( "Reach finished." ) ret = self . get_output ( ) self . clear_input ( ) return ret
Read the content, returning a list of ReadingData objects.