To get brew default commands on local environment
324274
def _get_brew_commands(brew_path_prefix):
    """"""
    brew_cmd_path = brew_path_prefix + BREW_CMD_PATH

    return [name[:-3] for name in os.listdir(brew_cmd_path)
            if name.endswith(('.rb', '.sh'))]
1030141
def rebuild_app(app_name, quiet=False, force=True, without_exec=False,
                restart=False):
    '''
        
    '''
    user = 'cozy-{app_name}'.format(app_name=app_name)
    home = '{prefix}/{app_name}'.format(prefix=PREFIX, app_name=app_name)
    command_line = 'cd {home}'.format(home=home)
    command_line += ' && git pull'
    if force:
        command_line += ' && ([ -d node_modules ] && rm -rf node_modules || true)'
        command_line += ' && ([ -d .node-gyp ] && rm -rf .node-gyp || true)'
        command_line += ' && ([ -d .npm ] && rm -rf .npm || true)'
    command_line += ' && chown -R {user}:{user} .'.format(user=user)
    command_line += ' && sudo -u {user} env HOME={home} npm install --production'.format(
        user=user,
        home=home
    )
    if restart:
        command_line += ' && cozy-monitor update {app_name}'.format(
            app_name=app_name)
        command_line += ' && cozy-monitor restart {app_name}'.format(
            app_name=app_name)

    if not quiet:
        print 'Execute:'
        print command_line

    if not without_exec:
        result = helpers.cmd_exec(command_line)
        print result['stdout']
        print result['stderr']
        print result['error']
1215694
def _get_cmd(command, arguments):
    """"""
    if arguments is None:
        arguments = []
    if command.endswith(".py") or command.endswith(".pyw"):
        return [sys.executable, command] + list(arguments)
    else:
        return [command] + list(arguments)
766926
protected function getDefaultCommands()
    {
        $commands = parent::getDefaultCommands();
        $commands[] = new InitCommand();
        $commands[] = new InstallReleaseCommand();
        $commands[] = new DeployReleaseCommand();

        return $commands;
    }
981274
def checkInstalledBrew(package, similar=True, speak=True, speakSimilar=True):
    """"""
    packages = subprocess.check_output(['brew', 'list']).split()
    installed = package in packages
    similar = []

    if not installed:
        similar = [pkg for pkg in packages if package in pkg]
    if speak:
        speakInstalledPackages(package, "homebrew", installed, similar, speakSimilar)

    return (installed, similar)
450473
def cli(ctx, path, renku_home, use_external_storage):
    """"""
    ctx.obj = LocalClient(
        path=path,
        renku_home=renku_home,
        use_external_storage=use_external_storage,
    )
747985
private void useDefaultConf() {
        appName = getDefaultAppName();
        rootPackage = getDefaultRootPackage() + "." + getDefaultAppName();
        bootstrapPackName = getDefaultBootstrapPackName();
        sqlConfName = getDefaultSqlConfName();
    }
231098
def main(arguments=None):
    

    # setup the command-line util settings
    su = tools(
        arguments=arguments,
        docString=__doc__,
        logLevel="WARNING",
        options_first=False,
        projectName=False
    )
    arguments, settings, log, dbConn = su.setup()

    # unpack remaining cl arguments using `exec` to setup the variable names
    # automatically
    for arg, val in arguments.iteritems():
        if arg[0] == "-":
            varname = arg.replace("-", "") + "Flag"
        else:
            varname = arg.replace("<", "").replace(">", "")
        if isinstance(val, str) or isinstance(val, unicode):
            exec(varname + " = '%s'" % (val,))
        else:
            exec(varname + " = %s" % (val,))
        if arg == "--dbConn":
            dbConn = val
        log.debug('%s = %s' % (varname, val,))

    if os.path.isfile(pathToYaml):
        from fundamentals.mysql import yaml_to_database
        # PARSE YAML FILE CONTENTS AND ADD TO DATABASE
        yaml2db = yaml_to_database(
            log=log,
            settings=settings,
            dbConn=dbConn
        )
        yaml2db.add_yaml_file_content_to_database(
            filepath=pathToYaml,
            deleteFile=deleteFlag
        )
        basename = os.path.basename(pathToYaml)
        print "Content of %(basename)s added to database" % locals()

    else:
        from fundamentals.mysql import yaml_to_database
        yaml2db = yaml_to_database(
            log=log,
            settings=settings,
            dbConn=dbConn,
            pathToInputDir=pathToYaml,
            deleteFiles=deleteFlag
        )
        yaml2db.ingest()
        print "Content of %(pathToYaml)s directory added to database" % locals()

    return
687081
def default_command(command_name = nil)
      if command_name
        if commands.key?(command_name)
          @default_command = commands[command_name] if command_name
          @default_command
        else
          raise ArgumentError, "'#{command_name}' couldn't be found in this command's list of commands."
        end
      else
        @default_command
      end
    end
1269890
protected function getDefaultCommands()
    {

        $shell = new Shell(dirname(VENDOR_PATH));

        $handlers = [
            'source' => new Handler\Source($shell),
            'coverage' => new Handler\Coverage(),
            'pdepend' => new Handler\PDepend($shell),
            'dependencies' => new Handler\Dependencies($shell),
            'phpmd' => new Handler\PHPMD($shell),
            'checkstyle' => new Handler\Checkstyle($shell),
            'tests' => new Handler\Tests(),
            'cpd' => new Handler\CPD($shell),
            'phploc' => new Handler\Phploc($shell),
            'git' => new Handler\Git($shell),
            'gitDetailed' => new Handler\GitDetailed($shell),
        ];

        return array_merge(
            parent::getDefaultCommands(),
            [
                new Command\Serve(),
                new Command\Bundle(),
                new Command\Analyze($handlers),
                new Command\Analyzers($handlers),
            ]
        );
    }
756499
def main(arguments=None):
    
    # setup the command-line util settings
    su = tools(
        arguments=arguments,
        docString=__doc__,
        logLevel="ERROR",
        options_first=True
    )
    arguments, settings, log, dbConn = su.setup()

    # tab completion for raw_input
    readline.set_completer_delims(' \t\n;')
    readline.parse_and_bind("tab: complete")
    readline.set_completer(tab_complete)

    # unpack remaining cl arguments using `exec` to setup the variable names
    # automatically
    for arg, val in arguments.iteritems():
        if arg[0] == "-":
            varname = arg.replace("-", "") + "Flag"
        else:
            varname = arg.replace("<", "").replace(">", "")
        if isinstance(val, str) or isinstance(val, unicode):
            exec(varname + " = '%s'" % (val,))
        else:
            exec(varname + " = %s" % (val,))
        if arg == "--dbConn":
            dbConn = val
        log.debug('%s = %s' % (varname, val,))

    ## START LOGGING ##
    startTime = times.get_now_sql_datetime()
    log.info(
        '--- STARTING TO RUN THE cl_utils.py AT %s' %
        (startTime,))

    # set options interactively if user requests
    if "interactiveFlag" in locals() and interactiveFlag:

        # load previous settings
        moduleDirectory = os.path.dirname(__file__) + "/resources"
        pathToPickleFile = "%(moduleDirectory)s/previousSettings.p" % locals()
        try:
            with open(pathToPickleFile):
                pass
            previousSettingsExist = True
        except:
            previousSettingsExist = False
        previousSettings = {}
        if previousSettingsExist:
            previousSettings = pickle.load(open(pathToPickleFile, "rb"))

        # x-raw-input
        # x-boolean-raw-input
        # x-raw-input-with-default-value-from-previous-settings

        # save the most recently used requests
        pickleMeObjects = []
        pickleMe = {}
        theseLocals = locals()
        for k in pickleMeObjects:
            pickleMe[k] = theseLocals[k]
        pickle.dump(pickleMe, open(pathToPickleFile, "wb"))

    # call the worker function
    # x-if-settings-or-database-credientials
    if cone and filelist:
        import codecs
        pathToReadFile = pathToCoordinateList
        readFile = codecs.open(pathToReadFile, encoding='utf-8', mode='r')

        listOfCoordinates = []
        for line in readFile.readlines():
            line = line.strip()
            [ra, dec] = line.split()
            listOfCoordinates.append(str(ra) + " " + str(dec))
        search = conesearch(
            log=log,
            radiusArcsec=radiusArcsec,
            nearestOnly=nearestFlag,
            unclassified=unclassifiedFlag,
            listOfCoordinates=listOfCoordinates,
            outputFilePath=outPutFile,
            verbose=verboseFlag,
            redshift=redshiftFlag)
    elif cone:
        search = conesearch(
            log=log,
            ra=ra,
            dec=dec,
            radiusArcsec=radiusArcsec,
            nearestOnly=nearestFlag,
            unclassified=unclassifiedFlag,
            outputFilePath=outPutFile,
            verbose=verboseFlag,
            redshift=redshiftFlag
        )
    elif obj:
        search = namesearch(
            log=log,
            names=objectName,
            verbose=verboseFlag,
            outputFilePath=outPutFile
        )
    search.get()

    if "dbConn" in locals() and dbConn:
        dbConn.commit()
        dbConn.close()
    ## FINISH LOGGING ##
    endTime = times.get_now_sql_datetime()
    runningTime = times.calculate_time_difference(startTime, endTime)
    log.info('-- FINISHED ATTEMPT TO RUN THE cl_utils.py AT %s (RUNTIME: %s) --' %
             (endTime, runningTime, ))

    return
857237
def get_default_terminal(environ=None, fallback=_UNSPECIFIED):
    """"""
    if environ is None:
        environ = os.environ
    # If the option is specified in the environment, respect it.
    if "PIAS_OPT_TERMINAL" in environ:
        return environ["PIAS_OPT_TERMINAL"]
    # Find all candiate terminal programs.
    terminals = []
    colorterm = environ.get("COLORTERM")
    for filename in (colorterm, "gnome-terminal", "konsole", "xterm"):
        if filename is not None:
            filepath = find_executable(filename, environ)
            if filepath is not None:
                terminals.append(filepath)
    # If one of them is an ancestor process, use that.
    for ancestor in get_ancestor_processes():
        if ancestor in terminals:
            return ancestor
    # Otherwise use the first option that we found.
    for term in terminals:
        return term
    # Use an explicit fallback option if given.
    if fallback is not _UNSPECIFIED:
        return fallback
    raise ValueError("Could not find a terminal")
170864
def _get_versions(config=None):
    
    try:
        from bcbio.pipeline import version
        if hasattr(version, "__version__"):
            bcbio_version = ("%s-%s" % (version.__version__, version.__git_revision__)
                             if version.__git_revision__ else version.__version__)
        else:
            bcbio_version = ""
    except ImportError:
        bcbio_version = ""
    out = [{"program": "bcbio-nextgen", "version": bcbio_version}]
    manifest_dir = _get_manifest_dir(config)
    manifest_vs = _get_versions_manifest(manifest_dir) if manifest_dir else []
    if manifest_vs:
        out += manifest_vs
    else:
        assert config is not None, "Need configuration to retrieve from non-manifest installs"
        brew_vs = _get_brew_versions()
        for p in _cl_progs:
            out.append({"program": p["cmd"],
                        "version": (brew_vs[p["cmd"]] if p["cmd"] in brew_vs else
                                    _get_cl_version(p, config))})
        for p in _alt_progs:
            out.append({"program": p["name"],
                        "version": (brew_vs[p["name"]] if p["name"] in brew_vs else
                                    p["version_fn"](config))})
    out.sort(key=lambda x: x["program"])
    return out
539389
def _get_base_command(self):
        
        cd_command = ''.join(['cd ', str(self.WorkingDir), ';'])
        jvm_command = "java"
        jvm_arguments = self._commandline_join(
            [self.Parameters[k] for k in self._jvm_parameters])
        jar_arguments = '-jar "%s"' % self._get_jar_fp()
        rdp_arguments = self._commandline_join(
            [self.Parameters[k] for k in self._options])

        command_parts = [
            cd_command, jvm_command, jvm_arguments, jar_arguments,
            rdp_arguments, '-q']
        return self._commandline_join(command_parts).strip()
782754
def cli(ctx, env):
    """"""

    # Set up the environment
    env = copy.deepcopy(env)
    env.load_modules_from_python(routes.ALL_ROUTES)
    env.aliases.update(routes.ALL_ALIASES)
    env.vars['global_args'] = ctx.parent.params
    env.vars['is_shell'] = True
    env.vars['last_exit_code'] = 0

    # Set up prompt_toolkit settings
    app_path = click.get_app_dir('softlayer_shell')
    if not os.path.exists(app_path):
        os.makedirs(app_path)
    complete = completer.ShellCompleter(core.cli)

    while True:
        try:
            line = p_shortcuts.prompt(
                completer=complete,
                complete_while_typing=True,
                auto_suggest=p_auto_suggest.AutoSuggestFromHistory(),
            )

            # Parse arguments
            try:
                args = shlex.split(line)
            except ValueError as ex:
                print("Invalid Command: %s" % ex)
                continue

            if not args:
                continue

            # Run Command
            try:
                # Reset client so that the client gets refreshed
                env.client = None
                core.main(args=list(get_env_args(env)) + args,
                          obj=env,
                          prog_name="",
                          reraise_exceptions=True)
            except SystemExit as ex:
                env.vars['last_exit_code'] = ex.code
            except EOFError:
                return
            except ShellExit:
                return
            except Exception as ex:
                env.vars['last_exit_code'] = 1
                traceback.print_exc(file=sys.stderr)

        except KeyboardInterrupt:
            env.vars['last_exit_code'] = 130
1197244
def run_local(self, commands):
        
        process = subprocess.Popen(
            commands.get('cli_command'),
            shell=self.shell,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )

        out, err = process.communicate()

        # display app output
        self.run_display_app_output(out)
        self.run_display_app_errors(err)

        # Exit Code
        return self.run_exit_code(process.returncode)
1065933
def cmdloop(self, intro=None):
    """"""
    style = style_from_pygments(BasicStyle, style_dict)
    self.preloop()
    stop = None
    while not stop:
        line = prompt(get_prompt_tokens=get_prompt_tokens, lexer=lexer,
                      get_bottom_toolbar_tokens=get_bottom_toolbar_tokens,
                      history=history, style=style, true_color=True,
                      on_exit='return-none', on_abort='return-none',
                      completer=QCompleter())
        if line is None or line.strip() == r'\\':
            raise SystemExit
        else:
            line = self.precmd(line)
            stop = self.onecmd(line)
        stop = self.postcmd(stop, line)
    self.postloop()