<commit_before>package cz.pojd.rpi.system;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.inject.Inject;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.StringUtils;

/**
 * RuntimeExecutorImpl is an implementation of RuntimeExecutor using java.lang.Runtime
 * 
 * @author <NAME>
 * @since Jul 30, 2014 12:19:44 AM
 */
public class RuntimeExecutorImpl implements RuntimeExecutor {
    private static final Log LOG = LogFactory.getLog(RuntimeExecutorImpl.class);
    private static final String[] COMMAND_START = new String[] { "/bin/sh", "-c" };

    @Inject
    private Runtime runtime;

    public Runtime getRuntime() {
	return runtime;
    }

    public void setRuntime(Runtime runtime) {
	this.runtime = runtime;
    }

    @Override
    public int getCpuCount() {
	return getRuntime().availableProcessors();
    }

    @Override
    public boolean executeNoReturn(String command) {
	return executeCommand(command) != null;
    }

    @Override
    public List<Double> executeDouble(String command) {
	List<Double> output = new ArrayList<>();
	for (String s : execute(command)) {
	    output.add(Double.parseDouble(s));
	}
	return output;
    }

    @Override
    public List<String> executeString(String command) {
	return execute(command);
    }

    private List<String> execute(String command) {
	List<String> output = new ArrayList<>();
	try {
	    Process process = executeCommand(command);
	    if (process != null) {
		for (String s : getOutput(process.getInputStream())) {
		    output.add(s);
		}
	    }
	} catch (IOException e) {
	    LOG.error("Unable to parse output of system command " + command, e);
	}
	return output;
    }

    private Process executeCommand(String commandSimple) {
	String[] command = new String[] { COMMAND_START[0], COMMAND_START[1], commandSimple };<commit_msg> #20 simplified the code inside runtime executor<commit_after>package cz.pojd.rpi.system;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.inject.Inject;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.StringUtils;

/**
 * RuntimeExecutorImpl is an implementation of RuntimeExecutor using java.lang.Runtime
 * 
 * @author <NAME>
 * @since Jul 30, 2014 12:19:44 AM
 */
public class RuntimeExecutorImpl implements RuntimeExecutor {
    private static final Log LOG = LogFactory.getLog(RuntimeExecutorImpl.class);
    private static final String[] COMMAND_START = new String[] { "/bin/sh", "-c" };

    @Inject
    private Runtime runtime;

    public Runtime getRuntime() {
	return runtime;
    }

    public void setRuntime(Runtime runtime) {
	this.runtime = runtime;
    }

    @Override
    public int getCpuCount() {
	return getRuntime().availableProcessors();
    }

    @Override
    public boolean executeNoReturn(String command) {
	return executeCommand(command) != null;
    }

    @Override
    public List<Double> executeDouble(String command) {
	List<Double> output = new ArrayList<>();
	for (String s : execute(command)) {
	    output.add(Double.parseDouble(s));
	}
	return output;
    }

    @Override
    public List<String> executeString(String command) {
	return execute(command);
    }

    private List<String> execute(String command) {
	try {
	    Process process = executeCommand(command);
	    if (process != null) {
		return getOutput(process.getInputStream());
	    }
	} catch (IOException e) {
	    LOG.error("Unable to parse output of system command " + command, e);
	}
	return new ArrayList<>();
    }

    private Process executeCommand(String commandSimple) {
	String[] command = new String[] { COMMAND_START[0], COMMAND_START[1], commandSimple };
{'fraction_non_alphanumeric': 0.111248149975333, 'fraction_numerical': 0.00740009866798224, 'mean_word_length': 3.9938423645320196, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2651467', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1136, 'n_words': 315}