<commit_before>var knox = require('knox'),
    crypto = require('crypto'),
    fs = require('fs');

var Booty = module.exports = function(options) {

  this.client = knox.createClient({
    key: options.key,
    secret: options.secret,
    bucket: options.bucket
  });

};

Booty.prototype.getConfig = function(id,dest,key,cb) {
  this.client.getFile('/' + id + '.enc', function(err, res){
    if(err || res.statusCode !== 200) {
      cb(err || new Error("Not status code 200"));
    } else {
      var config_file = fs.createWriteStream(dest);
      var decipher = crypto.createDecipher('aes-256-cfb', key);
      config_file.on('close', function() {
        cb();
      });
      res.on('data', function(data) {
        config_file.write(decipher.update(data));
      });
      res.on('end', function() {
        config_file.write(decipher.final());
        config_file.end();
      });
    }
  });
};

Booty.prototype.putConfig = function(id,src,key,cb) {
  var config_file = fs.createReadStream(src);
  var fstat = fs.statSync(src);
  var cipher = crypto.createCipher('aes-256-cfb', key);
  var headers = {
    'Content-Length': fstat.size
  };

  var req = this.client.put('/' + id + '.enc', headers);

  req.on('response', function(res) {
    if(res.statusCode !== 200) {
      cb(err || new Error("Not status code 200"));
    } else {
      cb();
    }
  });

  config_file.on('data', function(data) {
    req.write(cipher.update(data), 'binary');
  });

  config_file.on('end', function() {
    req.end();
  });
};

<commit_msg>print status code on error<commit_after>var knox = require('knox'),
    crypto = require('crypto'),
    fs = require('fs');

var Booty = module.exports = function(options) {

  this.client = knox.createClient({
    key: options.key,
    secret: options.secret,
    bucket: options.bucket
  });

};

Booty.prototype.getConfig = function(id,dest,key,cb) {
  this.client.getFile('/' + id + '.enc', function(err, res){
    if(err || res.statusCode !== 200) {
      cb(err || new Error("status code " + res.statusCode));
    } else {
      var config_file = fs.createWriteStream(dest);
      var decipher = crypto.createDecipher('aes-256-cfb', key);
      config_file.on('close', function() {
        cb();
      });
      res.on('data', function(data) {
        config_file.write(decipher.update(data));
      });
      res.on('end', function() {
        config_file.write(decipher.final());
        config_file.end();
      });
    }
  });
};

Booty.prototype.putConfig = function(id,src,key,cb) {
  var config_file = fs.createReadStream(src);
  var fstat = fs.statSync(src);
  var cipher = crypto.createCipher('aes-256-cfb', key);
  var headers = {
    'Content-Length': fstat.size
  };

  var req = this.client.put('/' + id + '.enc', headers);

  req.on('response', function(res) {
    if(res.statusCode !== 200) {
      cb(err || new Error("Not status code 200"));
    } else {
      cb();
    }
  });

  config_file.on('data', function(data) {
    req.write(cipher.update(data), 'binary');
  });

  config_file.on('end', function() {
    req.end();
  });
};


{'fraction_non_alphanumeric': 0.18727801097836616, 'fraction_numerical': 0.010655473038424281, 'mean_word_length': 2.946496815286624, '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': '5403883', 'n_tokens_mistral': 1090, 'n_tokens_neox': 1041, 'n_words': 191}