Processes search results as specified by command arguments.

        :param args: Sequence of command arguments
        :param input_file: Pipeline input file
        :param output_file: Pipeline output file
347220
def process(self, args=argv, input_file=stdin, output_file=stdout):
        
        self.logger.debug(u'%s arguments: %s', type(self).__name__, args)
        self._configuration = None
        self._output_file = output_file

        try:
            if len(args) >= 2 and args[1] == '__GETINFO__':

                ConfigurationSettings, operation, args, reader = self._prepare(args, input_file=None)
                self.parser.parse(args, self)
                self._configuration = ConfigurationSettings(self)
                writer = splunk_csv.DictWriter(output_file, self, self.configuration.keys(), mv_delimiter=',')
                writer.writerow(self.configuration.items())

            elif len(args) >= 2 and args[1] == '__EXECUTE__':

                self.input_header.read(input_file)
                ConfigurationSettings, operation, args, reader = self._prepare(args, input_file)
                self.parser.parse(args, self)
                self._configuration = ConfigurationSettings(self)

                if self.show_configuration:
                    self.messages.append(
                        'info_message', '%s command configuration settings: %s'
                        % (self.name, self._configuration))

                writer = splunk_csv.DictWriter(output_file, self)
                self._execute(operation, reader, writer)

            else:

                file_name = path.basename(args[0])
                message = (
                    u'Command {0} appears to be statically configured and static '
                    u'configuration is unsupported by splunklib.searchcommands. '
                    u'Please ensure that default/commands.conf contains this '
                    u'stanza:\n'
                    u'[{0}]\n'
                    u'filename = {1}\n'
                    u'supports_getinfo = true\n'
                    u'supports_rawargs = true\n'
                    u'outputheader = true'.format(type(self).name, file_name))
                raise NotImplementedError(message)

        except SystemExit:
            raise

        except:

            import traceback
            import sys

            error_type, error_message, error_traceback = sys.exc_info()
            self.logger.error(traceback.format_exc(error_traceback))

            origin = error_traceback

            while origin.tb_next is not None:
                origin = origin.tb_next

            filename = origin.tb_frame.f_code.co_filename
            lineno = origin.tb_lineno

            self.write_error('%s at "%s", line %d : %s', error_type.__name__, filename, lineno, error_message)

            exit(1)

        return
26811
def process_inputs(self):
        
        ret = []
        files = self.args.files
        if files is None:
            return ret

        for fname in files:

            # arguments are host specs
            if self.args.hosts:
                sub = self.process_host(fname, fname, 0)
                if sub is not None:
                    ret.append(sub)
                continue

            # arguments are file names
            fh = open(fname, 'r')
            with fh:
                data = fh.read()
                sub = self.process_tls(data, fname)
                ret.append(sub)

        return ret
67274
def iter_file_commands(self):
        
        while True:
            line = self.next_line()
            if line is None:
                break
            elif len(line) == 0 or line.startswith(b'#'):
                continue
            # Search for file commands in order of likelihood
            elif line.startswith(b'M '):
                yield self._parse_file_modify(line[2:])
            elif line.startswith(b'D '):
                path = self._path(line[2:])
                yield commands.FileDeleteCommand(path)
            elif line.startswith(b'R '):
                old, new = self._path_pair(line[2:])
                yield commands.FileRenameCommand(old, new)
            elif line.startswith(b'C '):
                src, dest = self._path_pair(line[2:])
                yield commands.FileCopyCommand(src, dest)
            elif line.startswith(b'deleteall'):
                yield commands.FileDeleteAllCommand()
            else:
                self.push_line(line)
                break
252773
def print_search_results(self, search_results, buf=sys.stdout):
        
        formatted_lines = self.format_search_results(search_results)
        pr = Printer(buf)

        for txt, style in formatted_lines:
            pr(txt, style)
1271037
def action(arguments):
    
    for input_file in arguments.input_files:
        logging.info(input_file)
        # Generate a temporary file
        with common.atomic_write(
                input_file.name, file_factory=common.FileType('wt')) as tf:
            convert.transform_file(input_file, tf, arguments)
            if hasattr(input_file, 'close'):
                input_file.close()
951276
def __run_blast(blast_command, input_file, *args, **kwargs):
    '''
    
    '''

    # XXX: Eventually, translate results on the fly as requested? Or
    #      just always use our parsed object?
    if 'outfmt' in kwargs:
        raise Exception('Use of the -outfmt option is not supported')

    num_processes = kwargs.get(
        'pb_num_processes', os.sysconf('SC_NPROCESSORS_ONLN'))
    fields = kwargs.get('pb_fields', DEFAULT_HIT_FIELDS)

    blast_args = [blast_command]
    blast_args += ['-outfmt', '7 {}'.format(' '.join(fields))]
    for a in args:
        blast_args += ['-' + a]
    for k, v in kwargs.iteritems():
        if not k.startswith('pb_'):
            blast_args += ['-' + k, str(v)]

    popens = []
    for _ in range(num_processes):
        popens.append(
            subprocess.Popen(
                args=blast_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                stderr=None, close_fds=True))

    try:
        for r in __run_blast_select_loop(input_file, popens, fields):
            yield r
    finally:
        for p in popens:
            if p.poll() is None:
                p.terminate()
            p.wait()
721818
def get(self, *args, **kwargs):
        
        args, kwargs = self.__process__(*args, **kwargs)
        return check_output(args, **kwargs)
475730
def _process(compressor, input_filename, output_filename):
    
    compressor(input_filename, output_filename)
    result_size = os.path.getsize(output_filename)

    return _CompressorResult(result_size, output_filename, compressor.__name__)
469003
def run(self) -> Generator[Tuple[int, int, str, type], None, None]:
        
        if self.filename != STDIN:
            buffer = StringIO()
            options = _Options(aggressive=self.options.eradicate_aggressive)
            fix_file(self.filename, options, buffer)
            traceback = buffer.getvalue()

            if traceback:
                yield 1, 0, self._error(traceback), type(self)
407335
def do_results(args):
    
    config,name,label,coord = args

    filenames = make_filenames(config,label)
    srcfile = filenames['srcfile']
    samples = filenames['samfile']

    if not exists(srcfile):
        logger.warning("Couldn't find %s; skipping..."%srcfile)
        return
    if not exists(samples):
        logger.warning("Couldn't find %s; skipping..."%samples)
        return

    logger.info("Writing %s..."%srcfile)
    from ugali.analysis.results import write_results
    write_results(srcfile,config,srcfile,samples)
1313096
def cmd_query(self, txt):
        
        self.show_output('Searching for ', txt)
        res = self.raw.find(txt)
        for d in res:
            self.show_output(d)
        return str(len(res)) + ' results for ' + txt
672055
def main(filename):
    
    if filename:
        if not os.path.exists(filename):
            logger.error("'%s' doesn't exists!" % filename)
            sys.stderr.write("'%s' doesn't exists!\n" % filename)
            sys.exit(1)

        logger.info("Processing '%s'" % filename)
        for ir in process_log(sh.tail("-f", filename, _iter=True)):
            print ir
    else:
        logger.info("Processing stdin.")
        for ir in process_log(_read_stdin()):
            print ir
467051
def cli_action(args):
    
    problem = read_param_file(args.paramfile)
    param_values = sample(problem, seed=args.seed)
    np.savetxt(args.output, param_values, delimiter=args.delimiter,
               fmt='%.' + str(args.precision) + 'e')
566603
def genargs() -> ArgumentParser:
    
    parser = ArgumentParser()
    parser.add_argument("infile", help="Input JSG specification")
    parser.add_argument("-o", "--outfile", help="Output python file (Default: {infile}.py)")
    parser.add_argument("-e", "--evaluate", help="Evaluate resulting python file as a test", action="store_true")
    parser.add_argument("-v", "--verbose", help="Verbose output", action="store_true")
    return parser
1374098
def perform_command(self):
        
        if len(self.actual_arguments) < 2:
            return self.print_help()
        input_file_path = self.actual_arguments[0]
        output_file_path = self.actual_arguments[1]

        if not self.check_input_file(input_file_path):
            return self.ERROR_EXIT_CODE
        if not self.check_output_file(output_file_path):
            return self.ERROR_EXIT_CODE

        try:
            converter = FFMPEGWrapper(rconf=self.rconf, logger=self.logger)
            converter.convert(input_file_path, output_file_path)
            self.print_success(u"Converted '%s' into '%s'" % (input_file_path, output_file_path))
            return self.NO_ERROR_EXIT_CODE
        except FFMPEGPathError:
            self.print_error(u"Unable to call the ffmpeg executable '%s'" % (self.rconf[RuntimeConfiguration.FFMPEG_PATH]))
            self.print_error(u"Make sure the path to ffmpeg is correct")
        except OSError:
            self.print_error(u"Cannot convert file '%s' into '%s'" % (input_file_path, output_file_path))
            self.print_error(u"Make sure the input file has a format supported by ffmpeg")

        return self.ERROR_EXIT_CODE
169247
def get_output_from_pipe(self, input_file):
        
        args = shlex.split(self.cmd)
        p = Popen(args, stdout=PIPE, stdin=PIPE)  # | grep es
        p.stdin.write(bytearray(input_file.encode("utf8")))  # echo test |
        return p.communicate()[0].decode("utf8")
1363241
def searchone(filename, scan, paramfile, logfile, bdfdir):
    

    filename = os.path.abspath(filename)
    scans = ps.read_scans(filename, bdfdir=bdfdir)

    if scan != 0:
        d = rt.set_pipeline(filename, scan, paramfile=paramfile,
                            fileroot=os.path.basename(filename), logfile=logfile)
        rt.pipeline(d, range(d['nsegments']))

        # clean up and merge files
        pc.merge_segments(filename, scan)
        pc.merge_scans(os.path.dirname(filename), os.path.basename(filename), scans.keys())
    else:
        logger.info('Scans, Target names:')
        logger.info('%s' % str([(ss, scans[ss]['source']) for ss in scans]))
        logger.info('Example pipeline:')
        state = rt.set_pipeline(filename, scans.popitem()[0], paramfile=paramfile,
                                fileroot=os.path.basename(filename), logfile=logfile)