<commit_before>#!/usr/bin/env node

var os = require("os");
var promise = require("deferred");
var keygen = require('ssh-keygen');
var fs = require('fs');
var path = require('path');

var vccutil = require("./vccutil.js");
var logger = require("./log.js");
var kvstore = require("./kvstore.js");

/**
 * Public key discovery for the VCC
 * @constructor
 * @param {Object} config - A configuration object (usually loaded from vccutil.GetConfig)
 */
var ClusterKeys = function (config) {
    this.config = config;
    this.current_user = os.userInfo().username;
    this.current_home = os.userInfo().homedir;
    // the discovery kv store
    this.kv = new kvstore();
    this.kv.connect(config.kvstore.host, config.kvstore.port);
};

/**
 * Enumerate all public keys in the discovery
 */
ClusterKeys.prototype.enumeratePublicKeys = function () {
    var me = this;
}

/**
 * Write an authorized_keys file for the current user
 */
ClusterKeys.prototype.writeAuthorizedKeys = function () {
    var me = this;
}

/**
 * Generate keys if they don't exist for the current user
 */
ClusterKeys.prototype.generateKeys = function (basepath) {
    var deferred = promise();
    var me = this;

    if (!basepath) {
        var basepath = path.join(me.current_home, ".ssh");
    }
    var location = path.join(basepath, "id_rsa");
    var comment = '@vcc';
    var password = <PASSWORD>;

    // does key exist?
    fs.stat(location, function(err, stat) {
        if(err == null) {
            logger.info("Private key already exists for", me.current_user);
            deferred.resolve(false);
        } else if(err.code == 'ENOENT') {
            // file does not exist
            logger.debug('Private key does not exist for', me.current_user, "ENOENT");
            logger.info("Start generating keys for", me.current_user);
            logger.info("This could take a while...");
            keygen({
                location: location,
                comment: comment,
                password: password,
                read: false
            }, function(err){
                if (err) {<commit_msg>set key comment correctly #1<commit_after>#!/usr/bin/env node

var os = require("os");
var promise = require("deferred");
var keygen = require('ssh-keygen');
var fs = require('fs');
var path = require('path');

var vccutil = require("./vccutil.js");
var logger = require("./log.js");
var kvstore = require("./kvstore.js");

/**
 * Public key discovery for the VCC
 * @constructor
 * @param {Object} config - A configuration object (usually loaded from vccutil.GetConfig)
 */
var ClusterKeys = function (config) {
    this.config = config;
    this.current_user = os.userInfo().username;
    this.current_home = os.userInfo().homedir;
    // the discovery kv store
    this.kv = new kvstore();
    this.kv.connect(config.kvstore.host, config.kvstore.port);
};

/**
 * Enumerate all public keys in the discovery
 */
ClusterKeys.prototype.enumeratePublicKeys = function () {
    var me = this;
}

/**
 * Write an authorized_keys file for the current user
 */
ClusterKeys.prototype.writeAuthorizedKeys = function () {
    var me = this;
}

/**
 * Generate keys if they don't exist for the current user
 */
ClusterKeys.prototype.generateKeys = function (basepath) {
    var deferred = promise();
    var me = this;

    if (!basepath) {
        var basepath = path.join(me.current_home, ".ssh");
    }
    var location = path.join(basepath, "id_rsa");
    var comment = this.current_user+'@vcc';
    var password = <PASSWORD>;

    // does key exist?
    fs.stat(location, function(err, stat) {
        if(err == null) {
            logger.info("Private key already exists for", me.current_user);
            deferred.resolve(false);
        } else if(err.code == 'ENOENT') {
            // file does not exist
            logger.debug('Private key does not exist for', me.current_user, "ENOENT");
            logger.info("Start generating keys for", me.current_user);
            logger.info("This could take a while...");
            keygen({
                location: location,
                comment: comment,
                password: password,
                read: false
            }, function(err){
                if (err) {
{'fraction_non_alphanumeric': 0.13603028152353916, 'fraction_numerical': 0.0002365744026496333, 'mean_word_length': 2.5891341256366722, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2703456', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1212, 'n_words': 352}