Retrieve the base Picard command, handling both shell scripts and directory of jars.
762078
def _get_picard_cmd(self, command, memscale=None):
        
        resources = config_utils.get_resources("picard", self._config)
        if memscale:
            jvm_opts = get_picard_opts(self._config, memscale=memscale)
        elif resources.get("jvm_opts"):
            jvm_opts = resources.get("jvm_opts")
        else:
            jvm_opts = self._jvm_opts
        if os.path.isdir(self._picard_ref):
            dist_file = self._get_jar(command)
            return ["java"] + jvm_opts + get_default_jvm_opts() + ["-jar", dist_file]
        else:
            # XXX Cannot currently set JVM opts with picard-tools script
            return [self._picard_ref, command]
93193
def _get_base_command(self):
        
        command_parts = []
        # Append a change directory to the beginning of the command to change
        # to self.WorkingDir before running the command
        # WorkingDir should be in quotes -- filenames might contain spaces
        cd_command = ''.join(['cd ', str(self.WorkingDir), ';'])
        if self._command is None:
            raise ApplicationError('_command has not been set.')
        command = self._command
        parameters = self.Parameters

        command_parts.append(cd_command)
        command_parts.append(command)
        command_parts.append(self._command_delimiter.join(filter(
            None, (map(str, parameters.values())))))

        return self._command_delimiter.join(command_parts).strip()
1129378
def _get_result_files_base(self, temp_dir):
        """"""
        if not self._use_namespaces:
            return super(ContainerExecutor, self)._get_result_files_base(temp_dir)
        else:
            return os.path.join(temp_dir, "temp")
591003
def shellne(command):
    

    child = os.popen(command)
    data = child.read()
    err = child.close()
    if err:
        raise RuntimeError('%s failed w/ exit code %d' % (command, err))
    return data
921930
def _get_cromwell_execution_dir(base_dir, target_glob):
    
    cur_dir = glob.glob(os.path.join(base_dir, target_glob))[0]
    if os.path.exists(os.path.join(cur_dir, "cwl.output.json")):
        return base_dir
    else:
        symlink_dir = os.path.dirname(os.path.realpath(os.path.join(cur_dir, "script")))
        ref_base = os.path.dirname(base_dir)
        new_guid = symlink_dir[symlink_dir.find(ref_base) + len(ref_base) + 1:].split("/")[0]
        return _get_cromwell_execution_dir(os.path.join(ref_base, new_guid), target_glob)
103584
def get_basebackup(self, arg):
        """"""
        if not arg.tablespace_dir:
            tablespace_mapping = {}
        else:
            try:
                tablespace_mapping = dict(v.split("=", 1) for v in arg.tablespace_dir)
            except ValueError:
                raise RestoreError("Invalid tablespace mapping {!r}".format(arg.tablespace_dir))

        self.config = config.read_json_config_file(arg.config, check_commands=False, check_pgdata=False)
        site = config.get_site_from_config(self.config, arg.site)
        try:
            self.storage = self._get_object_storage(site, arg.target_dir)
            self._get_basebackup(
                pgdata=arg.target_dir,
                basebackup=arg.basebackup,
                site=site,
                debug=arg.debug,
                status_output_file=arg.status_output_file,
                primary_conninfo=arg.primary_conninfo,
                recovery_end_command=arg.recovery_end_command,
                recovery_target_action=arg.recovery_target_action,
                recovery_target_name=arg.recovery_target_name,
                recovery_target_time=arg.recovery_target_time,
                recovery_target_xid=arg.recovery_target_xid,
                restore_to_master=arg.restore_to_master,
                overwrite=arg.overwrite,
                tablespace_mapping=tablespace_mapping,
                tablespace_base_dir=arg.tablespace_base_dir,
            )
        except RestoreError:  # pylint: disable=try-except-raise
            # Pass RestoreErrors thru
            raise
        except Exception as ex:
            if self.log_tracebacks:
                self.log.exception("Unexpected _get_basebackup failure")
            raise RestoreError("{}: {}".format(ex.__class__.__name__, ex))
325266
def _get_script(self):
        
        if settings.repeat:
            repeat_fuck = '{} --repeat {}--force-command {}'.format(
                get_alias(),
                '--debug ' if settings.debug else '',
                shell.quote(self.script))
            return shell.or_(self.script, repeat_fuck)
        else:
            return self.script
954823
function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) {
                // Make all paths absolute/normalized if they are not already
                rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); });
                // Determine the path to the directory containing the script relative to the root directory it is contained within
                var relativeDirectory;
                for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) {
                    var rootDirectory = rootDirs_1[_i];
                    if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) {
                        relativeDirectory = scriptPath.substr(rootDirectory.length);
                        break;
                    }
                }
                // Now find a path for each potential directory that is to be merged with the one containing the script
                return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }));
            }
1320373
function parseDir(base) {
  const stats = fs.statSync(base);
  let packageFileHandler;

  if (!stats.isDirectory()) {
    throw new Error(`${base} is not a directory`);
  }

  try {
    fs.statSync(`${base}/deploy.json`);
    packageFileHandler = _.partial(parseDeployjson, `${base}/deploy.json`);
  }
  catch (ex) {
    try {
      fs.statSync(`${base}/package.js`);
      packageFileHandler = _.partial(parsePackagejs, `${base}/package.js`);
    }
    catch (_ex) {
      const message = `could not find 'deploy.json' or 'package.js' in directory '${base}'`;
      throw new Error(message);
    }
  }

  return packageFileHandler();
}
313013
def _get_base_command(self):
        
        command_parts = []
        # Append a change directory to the beginning of the command to change
        # to self.WorkingDir before running the command
        # WorkingDir should be in quotes -- filenames might contain spaces
        cd_command = ''.join(['cd ', str(self.WorkingDir), ';'])
        if self._command is None:
            raise ApplicationError('_command has not been set.')
        command = self._command
        # also make sure there's a subcommand!
        if self._subcommand is None:
            raise ApplicationError('_subcommand has not been set.')
        subcommand = self._subcommand
        # sorting makes testing easier, since the options will be written out
        # in alphabetical order. Could of course use option parsing scripts
        # in cogent for this, but this works as well.
        parameters = sorted([str(x) for x in self.Parameters.values()
                            if str(x)])
        synonyms = self._synonyms

        command_parts.append(cd_command)
        command_parts.append(command)
        # add in subcommand
        command_parts.append(subcommand)
        command_parts += parameters
        # add in the positional arguments in the correct order
        for k in self._input_order:
            # this check is necessary to account for optional positional
            # arguments, such as the mate file for bwa bwasw
            # Note that the input handler will ensure that all required
            # parameters have valid values
            if k in self._input:
                command_parts.append(self._input[k])

        return self._command_delimiter.join(command_parts).strip()
119852
def get_command(self, command):
		
		shutit_global.shutit_global_object.yield_to_draw()
		if command in ('md5sum','sed','head'):
			if self.get_current_shutit_pexpect_session_environment().distro == 'osx':
				return 'g' + command
		return command
288846
def get_context_from_cmdln(args, desc="Run scriptworker"):
    
    context = Context()
    parser = argparse.ArgumentParser(description=desc)
    parser.add_argument(
        "config_path", type=str, nargs="?", default="scriptworker.yaml",
        help="the path to the config file"
    )
    parsed_args = parser.parse_args(args)
    context.config, credentials = create_config(config_path=parsed_args.config_path)
    update_logging_config(context)
    return context, credentials
518462
def run_code_in_container(cli, image, code, mount, entrypoint):
    
    kwargs = {
        'image': image,
    }

    if entrypoint:
        kwargs['entrypoint'] = '/bin/bash'
        kwargs['command'] = '-c {}'.format(quote(code))
    else:
        kwargs['command'] = '/bin/bash -c {}'.format(quote(code))

    if mount:
        binds = []
        volumes = []

        for m in mount:
            part = m.split(':')

            if len(part) == 3:
                pass
            elif len(part) == 2:
                part.append('rw')
            else:
                raise

            src, target, mode = part
            src = os.path.abspath(os.path.expanduser(src))

            binds.append('{}:{}:{}'.format(src, target, mode))
            volumes.append(target)

        kwargs['host_config'] = cli.create_host_config(binds=binds)
        kwargs['volumes'] = volumes

    container = cli.create_container(**kwargs)
    container_id = container['Id']

    cli.start(container=container_id)

    return container_id
1030094
def get_java_binpath(cmd=None):
    
    if os.environ.get("BCBIO_JAVA_HOME"):
        test_cmd = os.path.join(os.environ["BCBIO_JAVA_HOME"], "bin", "java")
        if os.path.exists(test_cmd):
            cmd = test_cmd
    if not cmd:
        cmd = Rscript_cmd()
    return os.path.dirname(cmd)
620571
def get_shell(self):
        
        if (not hasattr(self.shell, 'get_doc') or
                (hasattr(self.shell, 'is_running') and
                 not self.shell.is_running())):
            self.shell = None
            if self.main.ipyconsole is not None:
                shell = self.main.ipyconsole.get_current_shellwidget()
                if shell is not None and shell.kernel_client is not None:
                    self.shell = shell
            if self.shell is None:
                self.shell = self.internal_shell
        return self.shell
972752
def _get_runner(classpath, main, jvm_options, args, executor,
               cwd, distribution,
               create_synthetic_jar, synthetic_jar_dir):
  """"""

  executor = executor or SubprocessExecutor(distribution)

  safe_cp = classpath
  if create_synthetic_jar:
    safe_cp = safe_classpath(classpath, synthetic_jar_dir)
    logger.debug('Bundling classpath {} into {}'.format(':'.join(classpath), safe_cp))

  return executor.runner(safe_cp, main, args=args, jvm_options=jvm_options, cwd=cwd)
298495
def _get_source(self):
        "  "
        source_dir = op.join(self.deploy_dir, 'source')
        for tp, cmd in settings.SRC_CLONE:
            if self.src.startswith(tp + '+'):
                program = which(tp)
                assert program, '%s not found.' % tp
                cmd = cmd % dict(src=self.src[len(tp) + 1:],
                                 source_dir=source_dir,
                                 branch=self.branch)
                cmd = "sudo -u %s %s" % (self['src_user'], cmd)
                call(cmd, shell=True)
                self.templates.append('src-%s' % tp)
                break
        else:
            self.templates.append('src-dir')
            copytree(self.src, source_dir)

        return source_dir