Create a Run from a direct definition of the main input file (without task definition)
517604
def create_run_for_input_file(
            self, input_file, options, property_file, required_files_pattern, append_file_tags):
        """"""
        input_files = [input_file]
        base_dir = os.path.dirname(input_file)
        for append_file in append_file_tags:
            input_files.extend(
                self.expand_filename_pattern(append_file.text, base_dir, sourcefile=input_file))

        run = Run(
            input_file,
            util.get_files(input_files), # expand directories to get their sub-files
            options,
            self,
            property_file,
            required_files_pattern)

        if not run.propertyfile:
            return run

        prop = result.Property.create(run.propertyfile, allow_unknown=False)
        run.properties = [prop]
        expected_results = result.expected_results_of_file(input_file)
        if prop.name in expected_results:
            run.expected_results[prop.filename] = expected_results[prop.name]
        # We do not check here if there is an expected result for the given propertyfile
        # like we do in create_run_from_task_definition, to keep backwards compatibility.
        return run
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=(',', ':'))))
218578
def main(args=None, prog=None):
    """"""
    args = args if args is not None else sys.argv[1:]
    prog = prog if prog is not None else sys.argv[0]
    # Prevent broken pipe exception from being raised.
    signal.signal(signal.SIGPIPE, signal.SIG_DFL)
    stdin = sys.stdin.buffer if hasattr(sys.stdin, 'buffer') else sys.stdin
    p = argparse.ArgumentParser(prog=prog)
    p.add_argument('-o', '--output', metavar='PATH',
                   type=argparse.FileType('w'), default=sys.stdout,
                   help='Write output to PATH')
    p.add_argument('--api', help='Match API', default=None)
    p.add_argument('--profile', help='Match profile', default=None)
    p.add_argument('--support', default=None,
                   help='Match extension support string')
    g = p.add_mutually_exclusive_group()
    g.add_argument('--list-apis', action='store_true', dest='list_apis',
                   help='List apis in registry', default=False)
    g.add_argument('--list-profiles', action='store_true', default=False,
                   dest='list_profiles', help='List profiles in registry')
    g.add_argument('--list-supports', action='store_true',
                   dest='list_supports', default=False,
                   help='List extension support strings')
    p.add_argument('registry', type=argparse.FileType('rb'), nargs='?',
                   default=stdin, help='Registry path')
    args = p.parse_args(args)
    o = args.output
    try:
        registry = load(args.registry)
        if args.list_apis:
            for x in sorted(registry.get_apis()):
                print(x, file=o)
            return 0
        elif args.list_profiles:
            for x in sorted(registry.get_profiles()):
                print(x, file=o)
            return 0
        elif args.list_supports:
            for x in sorted(registry.get_supports()):
                print(x, file=o)
            return 0
        apis = group_apis(registry, None, None, args.api, args.profile,
                          args.support)
        for api in apis:
            print('#ifndef', api.name, file=o)
            print('#define', api.name, file=o)
            print(api.text, file=o)
            print('#endif', file=o)
            print('', file=o)
    except:
        e = sys.exc_info()[1]
        print(prog, ': error: ', e, sep='', file=sys.stderr)
        return 1
    return 0
688818
def main():
    """"""

    parser = argparse.ArgumentParser()
    parser.add_argument("--input_dir", help="The Input file directory", default="doc_templates/")
    parser.add_argument("--output_dir", help="Where to store the processed files", default="current_docs/")
    parser.add_argument("--java_src_dir", help="Where Java snippet source files are located",
                        default="src/test/java/io/improbable/snippet/")
    parser.add_argument("--python_src_dir", help="Where Python snippet source files are located",
                        default="src/test/python/")
    parser.add_argument("--debug", action='store_true', help="Turn on script debugging")

    args = parser.parse_args()
    if args.debug:
        logging.basicConfig(level=logging.DEBUG)

    snippet_store = {}
    for_all_files_in_dir(args.java_src_dir, lambda x: read_file_snippets(args.java_src_dir + x, snippet_store))
    for_all_files_in_dir(args.python_src_dir, lambda x: read_file_snippets(args.python_src_dir + x, snippet_store))
    stripped_snippet_store = {k: strip_block_whitespace(v) for k, v in snippet_store.items()}
    printd(str(stripped_snippet_store))
    check_output_dir_exists(args.output_dir)
    for_all_in_subdirs(args.input_dir, lambda x: do_rewrites(x,
                                                             args.input_dir,
                                                             args.output_dir,
                                                             stripped_snippet_store))
464046
def run_file_or_script (script=None, file_name='script_from_command_line',
                        argv=None, params=None, **kwargs):
    """"""
    runner= Ayrton (**kwargs)

    if params is None:
        params= ExecParams ()

    if script is None:
        v= runner.run_file (file_name, argv, params)
    else:
        if not isinstance(script, bytes):
            # the problem here it's that the parser expects the source as bytes
            # so we must encode the source before passing it
            script = script.encode()
        v= runner.run_script (script, file_name, argv, params)

    return v
266465
def main(argv=None):
    """"""
    arguments = cli_common(__doc__, argv=argv)
    plugin = 'benchmark' if arguments['benchmark'] else None

    if arguments['-g']:
        template.generate_config(plugin, arguments['<FILE>'])
    else:
        with open(arguments['<FILE>']) as istr:
            context = json.load(istr)
        kwargs = dict(no_input=True, extra_context=context)
        if arguments['--output-dir']:
            kwargs.update(output_dir=arguments['--output-dir'])
        if arguments['--interactive']:
            kwargs.update(no_input=False)
        logging.info(
            'generating template in directory ' + kwargs.get('output_dir', os.getcwd())
        )
        template.generate_template(plugin, **kwargs)
105025
def build_and_run_file(filename):
    ''' 
    '''
    (directory, name, extension) = get_file_tuple(filename)
    if extension == 'c':
        print(" = = = = = = ", YELLOW, "GCC: Compiling " + filename + " file", \
              RESET, " = = = = = =\n")
        compiler = Compiler(filename)
        out = compiler.compile()
        if out != 0:
            print('Error while compiling. Code:', out, 'Please retry.')
            return out
        print("")

        out = compiler.run()
        return out

    elif extension == 'cpp':
        print(" = = = = = = ", YELLOW, "GPP: Compiling " + filename + " file", \
              RESET, " = = = = = =\n")
        compiler = Compiler(filename)
        out = compiler.compile()
        if out != 0:
            print('Error while compiling. Code:', out, 'Please retry.')
            return out
        print("")

        out = compiler.run()
        return out

    elif extension == 'py':
        print(" = = = = = = ", YELLOW, "PYTHON: Executing " + filename + " file", \
              RESET, " = = = = = =\n")
        compiler = Compiler(filename)
        out = compiler.run()
        return out
    elif extension == 'java':
        command = EXECUTABLE_JAVAC + ' ' + filename
        perform_system_command(command)
        command_run = EXECUTABLE_JAVA + ' ' + name
        test_file = directory + "/" + name + ".input"
        if os.path.exists(test_file):
            command_run += " < " + test_file
        return perform_system_command(command_run)
    else:
        print("Language yet not supported")
        return -1
1206495
def run_command(self, input_file, output_dir=None):
        
        base_name = os.path.basename(input_file)
        name, suffix = base_name.split('.', 1)
        output_file = '{}{}.tif'.format(name, self.split_pattern)
        if output_dir:
            output_file = os.path.join(output_dir, output_file)
        return ['bfconvert', input_file, output_file]
805065
function Buildit$run() {
		var externals, locals, define, out, patterns, walked, that = this;

		define = invert(this.define);
		externals = [];
		locals = {};
		patterns = [];

		each(this.exports, function(filepath, name) {
			var fullpath;

			fullpath = path.join(that.cwd, filepath + '.js');

			patterns.push(fullpath);
		});

		each(this.extensions, function(filepath) {
			var fullpath;

			fullpath = path.join(that.cwd, filepath + '.js');

			patterns.push(fullpath);
		});

		each(this.define, function(filepath, name) {
			var fullpath;

			fullpath = path.join(that.cwd, filepath + '.js');

			patterns.push(fullpath);
		});

		walked = walk(patterns, this.cwd);

		Array.prototype.push.apply(externals, walked.externals);
		unique(externals);

		each(walked.locals, function(file, name) {
			locals[name] = file;
		});

		each(this.define, function(filepath, name) {
			if (!locals.hasOwnProperty(filepath)) {
				throw new Error('Module "' + filepath + '" not found');
			}
		});

		each(this.exports, function(filepath, name) {
			if (!locals.hasOwnProperty(filepath)) {
				throw new Error('Module "' + filepath + '" not found');
			}
		});

		each(this.extensions, function(filepath) {
			if (!locals.hasOwnProperty(filepath)) {
				throw new Error('Module "' + filepath + '" not found');
			}
		});

		out = '';
		out += print.header(this.name, externals);
		out += print.library(externals);
		out += print.mappings(locals, this.cwd);
		out += print.machinery();

		each(locals, function(file, name) {
			out += print.file(name, file.source) + (define[name] ? print.define(define[name], name) : '');
		});

		each(this.extensions, function(filepath) {
			out += print.extension(filepath);
		});

		out += print.exports(this.exports);
		out += print.footer();

		return out;
	}
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
729646
def _get_input_for_run(args, executable, preset_inputs=None, input_name_prefix=None):
    
    # The following may throw if the executable is a workflow with no
    # input spec available (because a stage is inaccessible)
    exec_inputs = try_call(ExecutableInputs,
                           executable,
                           input_name_prefix=input_name_prefix,
                           active_region=args.region)

    # Use input and system requirements from a cloned execution
    if args.input_json is None and args.filename is None:
        # --input-json and --input-json-file completely override input
        # from the cloned job
        exec_inputs.update(args.input_from_clone, strip_prefix=False)

    # Update with inputs passed to the this function
    if preset_inputs is not None:
        exec_inputs.update(preset_inputs, strip_prefix=False)

    # Update with inputs passed with -i, --input_json, --input_json_file, etc.
    # If batch_tsv is set, do not prompt for missing arguments
    require_all_inputs = (args.batch_tsv is None)
    try_call(exec_inputs.update_from_args, args, require_all_inputs)

    return exec_inputs.inputs
338631
def run(self, *args, **kwargs):
        
        b_status            = True
        d_pftreeRun         = {}
        d_inputAnalysis     = {}
        d_env               = self.env_check()
        b_timerStart        = False

        self.dp.qprint(
                "\tStarting pfdicom run... (please be patient while running)", 
                level = 1
                )

        for k, v in kwargs.items():
            if k == 'timerStart':   b_timerStart    = bool(v)

        if b_timerStart:
            other.tic()

        if d_env['status']:
            d_pftreeRun = self.pf_tree.run(timerStart = False)
        else:
            b_status    = False 

        str_startDir    = os.getcwd()
        os.chdir(self.str_inputDir)
        if b_status:
            if len(self.str_extension):
                d_inputAnalysis = self.pf_tree.tree_process(
                                inputReadCallback       = None,
                                analysisCallback        = self.filelist_prune,
                                outputWriteCallback     = None,
                                applyResultsTo          = 'inputTree',
                                applyKey                = 'l_file',
                                persistAnalysisResults  = True
                )
        os.chdir(str_startDir)

        d_ret = {
            'status':           b_status and d_pftreeRun['status'],
            'd_env':            d_env,
            'd_pftreeRun':      d_pftreeRun,
            'd_inputAnalysis':  d_inputAnalysis,
            'runTime':          other.toc()
        }

        if self.b_json:
            self.ret_dump(d_ret, **kwargs)

        self.dp.qprint('\tReturning from pfdicom run...', level = 1)

        return d_ret
612772
def main() -> None:
    """"""
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--json",
        help="output in JSON format",
        action="store_true",
        default=False)
    parser.add_argument(
        "--config-file", help="Select config file to use", default=".snekrc")
    parser.add_argument(
        'files',
        metavar='file',
        nargs='*',
        default=[],
        help='Files to run checks against')
    parser.add_argument(
        "--init", help="generate snekrc", action="store_true", default=False)

    args = parser.parse_args()

    run_main(args)
1124155
def _create_empty_run(
        self, status=RunStatus.FINISHED, status_description=None
    ) -> Run:
        """"""
        run = Run(
            job_id=self.summary["job_id"],
            issue_instances=[],
            date=datetime.datetime.now(),
            status=status,
            status_description=status_description,
            repository=self.summary["repository"],
            branch=self.summary["branch"],
            commit_hash=self.summary["commit_hash"],
            kind=self.summary["run_kind"],
        )
        return run
1216845
def main() -> None:
    
    parser = ArgumentParser(
        description="Remove duplicate files"
    )
    parser.add_argument(
        "directory", nargs="+",
        help="Files and/or directories to check and remove duplicates from."
    )
    parser.add_argument(
        "--recursive", action="store_true",
        help="Recurse through any directories found"
    )
    parser.add_argument(
        "--dummy_run", action="store_true",
        help="Dummy run only; don't actually delete anything"
    )
    parser.add_argument(
        "--run_repeatedly", type=int,
        help="Run the tool repeatedly with a pause of <run_repeatedly> "
             "seconds between runs. (For this to work well,"
             "you should specify one or more DIRECTORIES in "
             "the 'filename' arguments, not files, and you will need the "
             "--recursive option.)"
    )
    parser.add_argument(
        "--verbose", action="store_true",
        help="Verbose output"
    )
    args = parser.parse_args()
    main_only_quicksetup_rootlogger(
        level=logging.DEBUG if args.verbose else logging.INFO)

    while True:
        deduplicate(args.directory,
                    recursive=args.recursive,
                    dummy_run=args.dummy_run)
        if args.run_repeatedly is None:
            break
        log.info("Sleeping for {} s...", args.run_repeatedly)
        sleep(args.run_repeatedly)
321262
def main():
    
    # Define Parser object and add to toil
    parser = build_parser()
    Job.Runner.addToilOptions(parser)
    args = parser.parse_args()
    # Store inputs from argparse
    inputs = {'config': args.config,
              'config_fastq': args.config_fastq,
              'input': args.input,
              'unc.bed': args.unc,
              'hg19.transcripts.fa': args.fasta,
              'composite_exons.bed': args.composite_exons,
              'normalize.pl': args.normalize,
              'output_dir': args.output_dir,
              'rsem_ref.zip': args.rsem_ref,
              'chromosomes.zip': args.chromosomes,
              'ebwt.zip': args.ebwt,
              'ssec': args.ssec,
              's3_dir': args.s3_dir,
              'sudo': args.sudo,
              'single_end_reads': args.single_end_reads,
              'upload_bam_to_s3': args.upload_bam_to_s3,
              'uuid': None,
              'sample.tar': None,
              'cpu_count': None}

    # Launch jobs
    Job.Runner.startToil(Job.wrapJobFn(download_shared_files, inputs), args)
919176
def main(
    output_file: str,
    entry_point: Optional[str],
    console_script: Optional[str],
    python: Optional[str],
    site_packages: Optional[str],
    compressed: bool,
    compile_pyc: bool,
    extend_pythonpath: bool,
    pip_args: List[str],
) -> None:
    

    if not pip_args and not site_packages:
        sys.exit(NO_PIP_ARGS_OR_SITE_PACKAGES)

    if output_file is None:
        sys.exit(NO_OUTFILE)

    # check for disallowed pip arguments
    for disallowed in DISALLOWED_ARGS:
        for supplied_arg in pip_args:
            if supplied_arg in disallowed:
                sys.exit(
                    DISALLOWED_PIP_ARGS.format(
                        arg=supplied_arg, reason=DISALLOWED_ARGS[disallowed]
                    )
                )

    with TemporaryDirectory() as working_path:
        tmp_site_packages = Path(working_path, "site-packages")

        if site_packages:
            shutil.copytree(site_packages, tmp_site_packages)

        if pip_args:
            # install deps into staged site-packages
            pip.install(["--target", str(tmp_site_packages)] + list(pip_args))

        # if entry_point is a console script, get the callable
        if entry_point is None and console_script is not None:
            try:
                entry_point = find_entry_point(tmp_site_packages, console_script)

            except KeyError:
                if not Path(tmp_site_packages, "bin", console_script).exists():
                    sys.exit(NO_ENTRY_POINT.format(entry_point=console_script))

        # create runtime environment metadata
        env = Environment(
            build_id=str(uuid.uuid4()),
            entry_point=entry_point,
            script=console_script,
            compile_pyc=compile_pyc,
            extend_pythonpath=extend_pythonpath,
        )

        Path(working_path, "environment.json").write_text(env.to_json())

        # create bootstrapping directory in working path
        bootstrap_target = Path(working_path, "_bootstrap")
        bootstrap_target.mkdir(parents=True, exist_ok=True)

        # copy bootstrap code
        copy_bootstrap(bootstrap_target)

        # create the zip
        builder.create_archive(
            Path(working_path),
            target=Path(output_file).expanduser(),
            interpreter=python or _interpreter_path(),
            main="_bootstrap:bootstrap",
            compressed=compressed,
        )