<commit_before>/**
 * Created by Newton on 2014/4/2.
 */
var util = require('util'),
    path = require('path'),
    exec = require('child_process').exec,
    config = require('./config'),
    adodb = path.join(__dirname, 'adodb.js');

require('./colors');

function noop(){}

function isFunction(fun){
    return Object.prototype.toString.call(fun) === '[object Function]';
}

exports.exec = function (method, params, done, fail){
    var commond, stdio;

    done = isFunction(done) ? done : noop;
    fail = isFunction(fail) ? fail : noop;

    config.debug && console.log('Exec:'.green.bold, method.cyan.bold);
    config.debug && console.log('Params:'.green.bold, JSON.stringify(params, null, '  ').cyan.bold);

    params = (new Buffer(JSON.stringify(params))).toString('base64');
    commond = util.format(
        'CScript %s //e:JScript //h:CScript //Nologo %s %s',
        adodb,
        method,
        params
    );
    stdio = exec(commond);
    stdio.stdout.on('data', function (data){
        try {
            data = JSON.parse(data);
        } catch (e) {
            console.log('Parse Error:'.red.bold, e.message);
            return;
        }

        done(data);
    });
    stdio.stderr.on('data', fail);
    stdio.on('error', function (error){
        console.log('Exec Error:'.red.bold, error);
    });
};
<commit_msg>fixed error message<commit_after>/**
 * Created by Newton on 2014/4/2.
 */
var util = require('util'),
    path = require('path'),
    exec = require('child_process').exec,
    config = require('./config'),
    adodb = path.join(__dirname, 'adodb.js');

require('./colors');

function noop(){}

function isFunction(fun){
    return Object.prototype.toString.call(fun) === '[object Function]';
}

exports.exec = function (method, params, done, fail){
    var commond, stdio;

    done = isFunction(done) ? done : noop;
    fail = isFunction(fail) ? fail : noop;

    config.debug && console.log('Exec:'.green.bold, method.cyan.bold);
    config.debug && console.log('Params:'.green.bold, JSON.stringify(params, null, '  ').cyan.bold);

    params = (new Buffer(JSON.stringify(params))).toString('base64');
    commond = util.format(
        'CScript %s //e:JScript //h:CScript //Nologo %s %s',
        adodb,
        method,
        params
    );
    stdio = exec(commond);
    stdio.stdout.on('data', function (data){
        try {
            data = JSON.parse(data);
        } catch (e) {
            console.log('Parse Error:'.red.bold, e.message.bold);
            return;
        }

        done(data);
    });
    stdio.stderr.on('data', fail);
    stdio.on('error', function (error){
        console.log('Exec Error:'.red.bold, error.bold);
    });
};

{'fraction_non_alphanumeric': 0.18060695780903036, 'fraction_numerical': 0.005921539600296077, 'mean_word_length': 2.657645466847091, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1594522', 'n_tokens_mistral': 891, 'n_tokens_neox': 854, 'n_words': 182}