<commit_before>package slave

import (
	"bufio"
	"fmt"
	"github.com/KIT-MAMID/mamid/msp"
	"github.com/Masterminds/semver"
	"os/exec"
	"regexp"
)

const mongodMinRequiredVersion = ">= 3.2"

func (p *ProcessManager) buildMongodCommandLine(m msp.Mongod) (args []string) {

	args = []string{
		"--dbpath", p.processDBPathDir(m),
		"--port", fmt.Sprintf("%d", m.Port),
		"--replSet", m.ReplicaSetConfig.ReplicaSetName,
		"--keyFile", p.processKeyfilePath(m),
	}

	switch m.ReplicaSetConfig.ShardingRole {
	case msp.ShardingRoleShardServer:
		args = append(args, "--shardsvr")
	case msp.ShardingRoleConfigServer:
		args = append(args, "--configsvr")
	}

	return args

}

func (p *ProcessManager) checkMongoDVersion() (bool, error) {
	version := ""
	cmd := exec.Command("mongod", "--version")
	stdOut, err := cmd.StdoutPipe()
	defer stdOut.Close()
	if err != nil {
		return false, fmt.Errorf("processmanager.checkMongoDVersion() failed with: %s", err)
	}
	scan := bufio.NewScanner(stdOut)
	if err := cmd.Start(); err != nil {
		return false, fmt.Errorf("processmanager.checkMongoDVersion() failed with: %s", err)
	}
	if scan.Scan() {
		re, _ := regexp.Compile(`v([0-9].*)`)
		res := re.FindStringSubmatch(scan.Text())
		if len(res) >= 2 {
			version = res[1]
		}
	}
	if err := cmd.Wait(); err != nil {
		return false, fmt.Errorf("processmanager.checkMongoDVersion() failed with: %s", err)
	}
	constraint, err := semver.NewConstraint(mongodMinRequiredVersion)
	if err != nil {
		return false, fmt.Errorf("processmanager.checkMongoDVersion() failed with: %s", err)
	}

	v, err := semver.NewVersion(version)
	if err != nil {
		return false, fmt.Errorf("processmanager.checkMongoDVersion() failed with: %s", err)
	}

	return constraint.Check(v), nil
}<commit_msg>FIX: slave: use correct command name in checkMogoDversion<commit_after>package slave

import (
	"bufio"
	"fmt"
	"github.com/KIT-MAMID/mamid/msp"
	"github.com/Masterminds/semver"
	"os/exec"
	"regexp"
)

const mongodMinRequiredVersion = ">= 3.2"

func (p *ProcessManager) buildMongodCommandLine(m msp.Mongod) (args []string) {

	args = []string{
		"--dbpath", p.processDBPathDir(m),
		"--port", fmt.Sprintf("%d", m.Port),
		"--replSet", m.ReplicaSetConfig.ReplicaSetName,
		"--keyFile", p.processKeyfilePath(m),
	}

	switch m.ReplicaSetConfig.ShardingRole {
	case msp.ShardingRoleShardServer:
		args = append(args, "--shardsvr")
	case msp.ShardingRoleConfigServer:
		args = append(args, "--configsvr")
	}

	return args

}

func (p *ProcessManager) checkMongoDVersion() (bool, error) {
	version := ""
	cmd := exec.Command(p.command, "--version")
	stdOut, err := cmd.StdoutPipe()
	defer stdOut.Close()
	if err != nil {
		return false, fmt.Errorf("processmanager.checkMongoDVersion() failed with: %s", err)
	}
	scan := bufio.NewScanner(stdOut)
	if err := cmd.Start(); err != nil {
		return false, fmt.Errorf("processmanager.checkMongoDVersion() failed with: %s", err)
	}
	if scan.Scan() {
		re, _ := regexp.Compile(`v([0-9].*)`)
		res := re.FindStringSubmatch(scan.Text())
		if len(res) >= 2 {
			version = res[1]
		}
	}
	if err := cmd.Wait(); err != nil {
		return false, fmt.Errorf("processmanager.checkMongoDVersion() failed with: %s", err)
	}
	constraint, err := semver.NewConstraint(mongodMinRequiredVersion)
	if err != nil {
		return false, fmt.Errorf("processmanager.checkMongoDVersion() failed with: %s", err)
	}

	v, err := semver.NewVersion(version)
	if err != nil {
		return false, fmt.Errorf("processmanager.checkMongoDVersion() failed with: %s", err)
	}

	return constraint.Check(v), nil
}
{'fraction_non_alphanumeric': 0.16821639898562976, 'fraction_numerical': 0.0033812341504649195, 'mean_word_length': 4.52099533437014, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7357737', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1311, 'n_words': 277}