Search in sources :

Example 11 with ExecutableRunnerException

use of com.synopsys.integration.executable.ExecutableRunnerException in project synopsys-detect by blackducksoftware.

the class ClangPackageManagerRunner method applies.

public boolean applies(ClangPackageManager currentPackageManager, File workingDirectory, DetectableExecutableRunner executor) {
    ClangPackageManagerInfo packageManagerInfo = currentPackageManager.getPackageManagerInfo();
    try {
        ExecutableOutput versionOutput = executor.execute(workingDirectory, packageManagerInfo.getPkgMgrName(), packageManagerInfo.getCheckPresenceCommandArgs());
        logger.debug(String.format("packageStatusOutput: %s", versionOutput.getStandardOutput()));
        if (versionOutput.getStandardOutput().contains(packageManagerInfo.getCheckPresenceCommandOutputExpectedText())) {
            logger.debug(String.format("Found package manager %s", packageManagerInfo.getPkgMgrName()));
            return true;
        }
        logger.debug(String.format("Output of %s %s does not look right; concluding that the %s package manager is not present. The output: %s", packageManagerInfo.getPkgMgrName(), packageManagerInfo.getCheckPresenceCommandArgs(), packageManagerInfo.getPkgMgrName(), versionOutput));
    } catch (ExecutableRunnerException e) {
        logger.debug(String.format("Error executing %s %s; concluding that the %s package manager is not present. The error: %s", packageManagerInfo.getPkgMgrName(), packageManagerInfo.getCheckPresenceCommandArgs(), packageManagerInfo.getPkgMgrName(), e.getMessage()));
        return false;
    }
    return false;
}
Also used : ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput) ExecutableRunnerException(com.synopsys.integration.executable.ExecutableRunnerException)

Example 12 with ExecutableRunnerException

use of com.synopsys.integration.executable.ExecutableRunnerException in project synopsys-detect by blackducksoftware.

the class ClangPackageManagerRunner method getPackages.

public PackageDetailsResult getPackages(ClangPackageManager currentPackageManager, File workingDirectory, DetectableExecutableRunner executableRunner, File dependencyFile) {
    ClangPackageManagerInfo packageManagerInfo = currentPackageManager.getPackageManagerInfo();
    Set<PackageDetails> dependencyDetails = new HashSet<>();
    Set<File> unRecognizedDependencyFiles = new HashSet<>();
    try {
        List<String> fileSpecificGetOwnerArgs = new ArrayList<>(packageManagerInfo.getPkgMgrGetOwnerCmdArgs());
        fileSpecificGetOwnerArgs.add(dependencyFile.getAbsolutePath());
        ExecutableOutput queryPackageResult = executableRunner.execute(workingDirectory, packageManagerInfo.getPkgMgrCmdString(), fileSpecificGetOwnerArgs);
        String queryPackageOutputToParse;
        if (StringUtils.isNotBlank(queryPackageResult.getStandardOutput())) {
            queryPackageOutputToParse = queryPackageResult.getStandardOutput();
        } else {
            queryPackageOutputToParse = queryPackageResult.getErrorOutput();
        }
        ClangPackageManagerResolver resolver = currentPackageManager.getPackageResolver();
        List<PackageDetails> packageDetails = resolver.resolvePackages(currentPackageManager.getPackageManagerInfo(), executableRunner, workingDirectory, queryPackageOutputToParse);
        dependencyDetails.addAll(packageDetails);
    } catch (NotOwnedByAnyPkgException notOwnedException) {
        logger.debug(String.format("%s is not recognized by the linux package manager (%s)", dependencyFile.getAbsolutePath(), notOwnedException.getMessage()));
        unRecognizedDependencyFiles.add(dependencyFile);
    } catch (ExecutableRunnerException e) {
        logger.debug(String.format("Error with dependency file %s when running %s", dependencyFile.getAbsolutePath(), packageManagerInfo.getPkgMgrCmdString()));
        logger.error(String.format("Error executing %s: %s", packageManagerInfo.getPkgMgrCmdString(), e.getMessage()));
    }
    return new PackageDetailsResult(dependencyDetails, unRecognizedDependencyFiles);
}
Also used : ArrayList(java.util.ArrayList) ExecutableRunnerException(com.synopsys.integration.executable.ExecutableRunnerException) ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput) NotOwnedByAnyPkgException(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.NotOwnedByAnyPkgException) ClangPackageManagerResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ClangPackageManagerResolver) File(java.io.File) HashSet(java.util.HashSet)

Example 13 with ExecutableRunnerException

use of com.synopsys.integration.executable.ExecutableRunnerException in project synopsys-detect by blackducksoftware.

the class DpkgPkgDetailsResolver method resolvePackageDetails.

public Optional<PackageDetails> resolvePackageDetails(ClangPackageManagerInfo currentPackageManager, DetectableExecutableRunner executableRunner, File workingDirectory, NameArchitecture packageNameArchitecture) {
    try {
        List<String> args = new ArrayList<>(currentPackageManager.getPkgInfoArgs().get());
        args.add(constructPackageArg(packageNameArchitecture.getName(), packageNameArchitecture.getArchitecture().orElse(null)));
        ExecutableOutput packageInfoOutput = executableRunner.execute(workingDirectory, currentPackageManager.getPkgMgrCmdString(), args);
        return parsePackageDetailsFromInfoOutput(packageNameArchitecture.getName(), packageInfoOutput.getStandardOutput());
    } catch (ExecutableRunnerException e) {
        logger.warn(String.format("Error executing %s to get package info: %s", currentPackageManager.getPkgMgrName(), e.getMessage()));
    }
    return Optional.empty();
}
Also used : ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput) ArrayList(java.util.ArrayList) ExecutableRunnerException(com.synopsys.integration.executable.ExecutableRunnerException)

Example 14 with ExecutableRunnerException

use of com.synopsys.integration.executable.ExecutableRunnerException in project synopsys-detect by blackducksoftware.

the class DotNetRuntimeFinder method listAvailableRuntimes.

public List<String> listAvailableRuntimes() throws DetectableException {
    try {
        ExecutableOutput runtimesOutput = dotnetListRuntimes();
        List<String> foundRuntimes = runtimesOutput.getStandardOutputAsList().stream().map(StringUtils::trimToEmpty).filter(StringUtils::isNotBlank).collect(Collectors.toList());
        logger.info("Found {} available dotnet runtimes", foundRuntimes.size());
        if (foundRuntimes.isEmpty()) {
            throw new DetectableException("No available dotnet runtimes");
        }
        return foundRuntimes;
    } catch (ExecutableRunnerException e) {
        throw new DetectableException("Could not determine available dotnet runtimes", e);
    }
}
Also used : ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput) StringUtils(org.apache.commons.lang3.StringUtils) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException) ExecutableRunnerException(com.synopsys.integration.executable.ExecutableRunnerException)

Aggregations

ExecutableRunnerException (com.synopsys.integration.executable.ExecutableRunnerException)14 ExecutableOutput (com.synopsys.integration.executable.ExecutableOutput)10 File (java.io.File)8 DetectableException (com.synopsys.integration.detectable.detectable.exception.DetectableException)7 ArrayList (java.util.ArrayList)7 Extraction (com.synopsys.integration.detectable.extraction.Extraction)6 IOException (java.io.IOException)5 ExecutableTarget (com.synopsys.integration.detectable.ExecutableTarget)4 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)4 HashMap (java.util.HashMap)4 List (java.util.List)4 DetectableExecutableRunner (com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner)3 Executable (com.synopsys.integration.executable.Executable)3 NameVersion (com.synopsys.integration.util.NameVersion)3 Collectors (java.util.stream.Collectors)3 StringUtils (org.apache.commons.lang3.StringUtils)3 MissingExternalIdException (com.synopsys.integration.bdio.graph.builder.MissingExternalIdException)2 FileFinder (com.synopsys.integration.common.util.finder.FileFinder)2 ExecutableUtils (com.synopsys.integration.detectable.ExecutableUtils)2 NugetInspectorParser (com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser)2