%prog batchccn test.csv

    Run CCN script in batch. Write makefile.
326239
def batchccn(args):
    
    p = OptionParser(batchccn.__doc__)
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    csvfile, = args
    mm = MakeManager()
    pf = op.basename(csvfile).split(".")[0]
    mkdir(pf)

    header = next(open(csvfile))
    header = None if header.strip().endswith(".bam") else "infer"
    logging.debug("Header={}".format(header))
    df = pd.read_csv(csvfile, header=header)
    cmd = "perl /mnt/software/ccn_gcn_hg38_script/ccn_gcn_hg38.pl"
    cmd += " -n {} -b {}"
    cmd += " -o {} -r hg38".format(pf)
    for i, (sample_key, bam) in df.iterrows():
        cmdi = cmd.format(sample_key, bam)
        outfile = "{}/{}/{}.ccn".format(pf, sample_key, sample_key)
        mm.add(csvfile, outfile, cmdi)
    mm.write()
1118171
def run_shell(args: dict) -> int:
    """"""

    if args.get('project_directory'):
        return run_batch(args)

    shell = CauldronShell()

    if in_project_directory():
        shell.cmdqueue.append('open "{}"'.format(os.path.realpath(os.curdir)))

    shell.cmdloop()
    return 0
649985
def run(self):
        '''
        
        '''
        qry = os.path.abspath(self.qry)
        ref = os.path.abspath(self.ref)
        outfile = os.path.abspath(self.outfile)
        tmpdir = tempfile.mkdtemp(prefix='tmp.run_nucmer.', dir=os.getcwd())
        original_dir = os.getcwd()
        os.chdir(tmpdir)
        script = 'run_nucmer.sh'
        self._write_script(script, ref, qry, outfile)
        syscall.run('bash ' + script, verbose=self.verbose)
        os.chdir(original_dir)
        shutil.rmtree(tmpdir)
1204592
def batch(args):
    
    from jcvi.apps.grid import MakeManager

    p = OptionParser(batch.__doc__)
    opts, args = p.parse_args(args)

    if len(args) < 2:
        sys.exit(not p.print_help())

    cdsfile = args[0]
    anchors = args[1:]
    workdirs = [".".join(op.basename(x).split(".")[:2]) for x in anchors]
    for wd in workdirs:
        mkdir(wd)

    mm = MakeManager()
    for wd, ac in zip(workdirs, anchors):
        pairscdsfile = wd + ".cds.fasta"
        cmd = "python -m jcvi.apps.ks prepare {} {} -o {}".\
                format(ac, cdsfile, pairscdsfile)
        mm.add((ac, cdsfile), pairscdsfile, cmd)
        ksfile = wd + ".ks"
        cmd = "python -m jcvi.apps.ks calc {} -o {} --workdir {}".\
                format(pairscdsfile, ksfile, wd)
        mm.add(pairscdsfile, ksfile, cmd)
    mm.write()
1073847
def _setup_output_file(self, output_filename, args, write_header=True):
        """"""
        # write command line into outputFile
        # (without environment variables, they are documented by benchexec)
        try:
            output_file = open(output_filename, 'w') # override existing file
        except IOError as e:
            sys.exit(e)

        if write_header:
            output_file.write(' '.join(map(util.escape_string_shell, self._build_cmdline(args)))
                              + '\n\n\n' + '-' * 80 + '\n\n\n')
            output_file.flush()

        return output_file
965860
def run(self):
        """"""
        # Try to create the directory
        if not os.path.exists(self.output):
            try:
                os.mkdir(self.output)
            except:
                print 'failed to create output directory %s' % self.output

        # Be sure it is a directory
        if not os.path.isdir(self.output):
            print 'invalid output directory %s' % self.output
            sys.exit(1)

        # Create the CSV handlers
        visitors = [
            _CompaniesCSV(self.output),
            _ActivitiesCSV(self.output),
            _ActivitiesSeenCSV(self.output),
            _QSACSV(self.output),
        ]

        # Run by each company populating the CSV files
        for path in glob.glob(os.path.join(self.input, '*.json')):
            with open(path, 'r') as f:
                try:
                    data = json.load(f, encoding='utf-8')
                except ValueError:
                    continue

                for visitor in visitors:
                    visitor.visit(data)
721801
def run(command, get_output=False, cwd=None):
    
    if cwd is None:
        cwd = GITPATH

    cprint('===')
    cprint('===  Command: ', command)
    cprint('===  CWD:     ', cwd)
    cprint('===')

    if get_output:
        proc = capture_stdout(command, cwd=cwd)
        out = proc.stdout.read().decode()
        print(out, end='')
        check_exit_code(proc.returncode)
        return out
    else:
        proc = sarge_run(command, cwd=cwd)
        check_exit_code(proc.returncode)
363915
def batch(ctx, path, recursive, watch):
    
    batch = Batch(ctx.obj['config'], ctx.obj['cucco'])

    if os.path.exists(path):
        if watch:
            batch.watch(path, recursive)
        elif os.path.isfile(path):
            batch.process_file(path)
        else:
            batch.process_files(path, recursive)
    else:
        click.echo('Error: Specified path doesn\'t exists', err=True)
        sys.exit(-1)
1109895
def main(argv=None, directory=None):
    
    logging.basicConfig(format='%(message)s')

    argv = argv or sys.argv
    arg_dict = parse_quality_args(argv[1:])
    GitPathTool.set_cwd(directory)
    fail_under = arg_dict.get('fail_under')
    tool = arg_dict['violations']
    user_options = arg_dict.get('options')
    if user_options:
        # strip quotes if present
        first_char = user_options[0]
        last_char = user_options[-1]
        if first_char == last_char and first_char in ('"', "'"):
            user_options = user_options[1:-1]
    driver = QUALITY_DRIVERS.get(tool)

    if driver is not None:
        # If we've been given pre-generated reports,
        # try to open the files
        input_reports = []

        for path in arg_dict['input_reports']:
            try:
                input_reports.append(open(path, 'rb'))
            except IOError:
                LOGGER.warning("Could not load '{}'".format(path))
        try:
            reporter = QualityReporter(driver, input_reports, user_options)
            percent_passing = generate_quality_report(
                reporter,
                arg_dict['compare_branch'],
                html_report=arg_dict['html_report'],
                css_file=arg_dict['external_css_file'],
                ignore_staged=arg_dict['ignore_staged'],
                ignore_unstaged=arg_dict['ignore_unstaged'],
                exclude=arg_dict['exclude'],
            )
            if percent_passing >= fail_under:
                return 0
            else:
                LOGGER.error("Failure. Quality is below {}%.".format(fail_under))
                return 1

        except (ImportError, EnvironmentError):
            LOGGER.error(
                "Quality tool not installed: '{}'".format(tool)
            )
            return 1
        # Close any reports we opened
        finally:
            for file_handle in input_reports:
                file_handle.close()

    else:
        LOGGER.error("Quality tool not recognized: '{}'".format(tool))
        return 1
348087
def run(cmd, input=None, capture_output=False, check=False, quiet=False, **kwargs):
    """"""
    if input is not None:
        kwargs['stdin'] = subprocess.PIPE
    if capture_output:
        kwargs['stdout'] = kwargs['stderr'] = subprocess.PIPE

    try:
        proc = subprocess.Popen(cmd, startupinfo=get_startupinfo(), **kwargs)
    except OSError as e:
        if e.errno == errno.ENOENT:
            raise ExecutableNotFound(cmd)
        else:
            raise

    out, err = proc.communicate(input)

    if not quiet and err:
        stderr_write_bytes(err, flush=True)
    if check and proc.returncode:
        raise CalledProcessError(proc.returncode, cmd, output=out, stderr=err)

    return out, err
545995
def run(cmds, **kwargs):
    
    proc = sp.Popen(cmds, bufsize=-1, stdout=sp.PIPE, stderr=sp.STDOUT,
                    close_fds=sys.platform != 'win32')
    for line in proc.stdout:
        print(line[:-1].decode())
    retcode = proc.wait()
    if retcode:
        raise sp.CalledProcessError(retcode, cmds)
328287
def run():
    """"""

    command = sys.argv[1].strip().lower()
    print('[COMMAND]:', command)

    if command == 'test':
        return run_test()
    elif command == 'build':
        return run_build()
    elif command == 'up':
        return run_container()
    elif command == 'serve':
        import cauldron
        cauldron.run_server(port=5010, public=True)
572149
def run(self):
        
        with zopen(self.output_file, 'w') as fout:
            return subprocess.Popen(self.nwchem_cmd + [self.input_file],
                                    stdout=fout)
114831
def run_process(self, slug, inputs):
        """"""
        def export_files(value):
            """Export input files of spawned process."""
            if isinstance(value, str) and os.path.isfile(value):
                # TODO: Use the protocol to export files and get the
                # process schema to check field type.
                print("export {}".format(value))
            elif isinstance(value, dict):
                for item in value.values():
                    export_files(item)
            elif isinstance(value, list):
                for item in value:
                    export_files(item)

        export_files(inputs)
        print('run {}'.format(json.dumps({'process': slug, 'input': inputs}, separators=(',', ':'))))
199792
def run(self, in_batches):
        
        if len(in_batches) != len(self._batcmd.batch_to_file_s):
            BaseShellOperator._rm_process_input_tmpfiles(self._batcmd.batch_to_file_s)  # [todo] - Removing tmpfiles can be easily forgot. Less lifetime for tmpfile.
            raise AttributeError('len(in_batches) == %d, while %d IN_BATCH* are specified in command below:%s$ %s' %
                                 (len(in_batches), len(self._batcmd.batch_to_file_s), os.linesep, self._batcmd.sh_cmd))

        # prepare & start process (if necessary)
        BaseShellOperator._batches_to_tmpfile(self._in_record_sep, self._in_column_sep, in_batches, self._batcmd.batch_to_file_s)
        if self._process is None:
            self._process = BaseShellOperator._start_process(
                self._batcmd, self._cwd, self._env,
                non_blocking_stdout=True)

        # Begin thread to read from subprocess's stdout.
        # Without this thread, subprocess's output buffer becomes full and no one solves it.
        t_consumer = Thread(target=get_subprocess_output,
                            args=(self._process.stdout, self._batch_done_output, self._subprocess_out_str))
        t_consumer.start()

        # pass batch to subprocess
        BaseShellOperator._batch_to_stdin(self._process, self._in_record_sep, self._in_column_sep,
                                          in_batches, self._batcmd.batch_to_file_s)

        # pass batch-done indicator to subprocess
        self._process.stdin.write(self._batch_done_indicator)

        # get output from subprocess
        t_consumer.join()
        subprocess_out_str       = self._subprocess_out_str[0]
        self._subprocess_out_str = []
        out_batch = BaseShellOperator._out_str_to_batch(subprocess_out_str,
                                                        self._out_recdef, self._out_col_patterns)
        return out_batch
1312848
def run(ctx, commandline):
    """"""
    file = ctx.obj['FILE']
    dotenv_as_dict = dotenv_values(file)
    if not commandline:
        click.echo('No command given.')
        exit(1)
    ret = run_command(commandline, dotenv_as_dict)
    exit(ret)
998694
def create_batch(cls, size, **kwargs):
        
        return [cls.create(**kwargs) for _ in range(size)]