Search in sources :

Example 31 with Executor

use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.

the class RuntimeEnvironment method validateExuberantCtags.

/**
     * Validate that I have a Exuberant ctags program I may use
     *
     * @return true if success, false otherwise
     */
public boolean validateExuberantCtags() {
    if (exCtagsFound == null) {
        Executor executor = new Executor(new String[] { getCtags(), "--version" });
        executor.exec(false);
        String output = executor.getOutputString();
        boolean isUnivCtags = output != null ? output.contains("Universal Ctags") : false;
        if (output == null || (!output.contains("Exuberant Ctags") && !isUnivCtags)) {
            LOGGER.log(Level.SEVERE, "Error: No Exuberant Ctags found in PATH !\n" + "(tried running " + "{0}" + ")\n" + "Please use option -c to specify path to a good " + "Exuberant Ctags program.\n" + "Or set it in java property " + "org.opensolaris.opengrok.analysis.Ctags", getCtags());
            exCtagsFound = false;
        } else {
            if (isUnivCtags) {
                isUniversalCtagsVal = true;
            }
            exCtagsFound = true;
        }
    }
    return exCtagsFound;
}
Also used : Executor(org.opensolaris.opengrok.util.Executor)

Example 32 with Executor

use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.

the class RuntimeEnvironment method isUniversalCtags.

/**
     * Are we using Universal ctags?
     *
     * @return true if we are using Universal ctags
     */
public boolean isUniversalCtags() {
    if (isUniversalCtagsVal == null) {
        isUniversalCtagsVal = false;
        Executor executor = new Executor(new String[] { getCtags(), "--version" });
        executor.exec(false);
        String output = executor.getOutputString();
        if (output.contains("Universal Ctags")) {
            isUniversalCtagsVal = true;
        }
    }
    return isUniversalCtagsVal;
}
Also used : Executor(org.opensolaris.opengrok.util.Executor)

Example 33 with Executor

use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.

the class MercurialRepository method determineCurrentVersion.

@Override
String determineCurrentVersion() throws IOException {
    String line = null;
    File directory = new File(directoryName);
    List<String> cmd = new ArrayList<>();
    ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
    cmd.add(RepoCommand);
    cmd.add("log");
    cmd.add("-l");
    cmd.add("1");
    cmd.add("--template");
    cmd.add("{date|isodate}: {node|short} {author} {desc|strip}");
    Executor executor = new Executor(cmd, directory);
    if (executor.exec(false) != 0) {
        throw new IOException(executor.getErrorString());
    }
    return executor.getOutputString().trim();
}
Also used : Executor(org.opensolaris.opengrok.util.Executor) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File)

Example 34 with Executor

use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.

the class MercurialRepository method update.

@Override
public void update() throws IOException {
    File directory = new File(directoryName);
    List<String> cmd = new ArrayList<>();
    ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
    cmd.add(RepoCommand);
    cmd.add("showconfig");
    Executor executor = new Executor(cmd, directory);
    if (executor.exec() != 0) {
        throw new IOException(executor.getErrorString());
    }
    if (executor.getOutputString().contains("paths.default=")) {
        cmd.clear();
        cmd.add(RepoCommand);
        cmd.add("pull");
        cmd.add("-u");
        executor = new Executor(cmd, directory);
        if (executor.exec() != 0) {
            throw new IOException(executor.getErrorString());
        }
    }
}
Also used : Executor(org.opensolaris.opengrok.util.Executor) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File)

Example 35 with Executor

use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.

the class MonotoneHistoryParser method parse.

/**
     * Parse the history for the specified file or directory. If a changeset is
     * specified, only return the history from the changeset right after the
     * specified one.
     *
     * @param file the file or directory to get history for
     * @param changeset the changeset right before the first one to fetch, or
     * {@code null} if all changesets should be fetched
     * @return history for the specified file or directory
     * @throws HistoryException if an error happens when parsing the history
     */
History parse(File file, String changeset) throws HistoryException {
    try {
        Executor executor = repository.getHistoryLogExecutor(file, changeset);
        int status = executor.exec(true, this);
        if (status != 0) {
            throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\" Exit code: " + status);
        }
    } catch (IOException e) {
        throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e);
    }
    return new History(entries);
}
Also used : Executor(org.opensolaris.opengrok.util.Executor) IOException(java.io.IOException)

Aggregations

Executor (org.opensolaris.opengrok.util.Executor)56 ArrayList (java.util.ArrayList)43 File (java.io.File)33 IOException (java.io.IOException)33 BufferedReader (java.io.BufferedReader)6 InputStream (java.io.InputStream)4 Properties (java.util.Properties)4 Matcher (java.util.regex.Matcher)4 BufferedInputStream (java.io.BufferedInputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Date (java.util.Date)2 RuntimeEnvironment (org.opensolaris.opengrok.configuration.RuntimeEnvironment)2 FileInputStream (java.io.FileInputStream)1 FileReader (java.io.FileReader)1 ParseException (java.text.ParseException)1 HashMap (java.util.HashMap)1 Scanner (java.util.Scanner)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1