<commit_before>/*
 * Licensed to Cloudkick, Inc ('Cloudkick') under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * Cloudkick licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

var log = require('util/log');
var fs = require('fs');
var path = require('path');
var Buffer = require('buffer').Buffer;
var jspack = require('../extern/jspack/jspack').jspack;

function getServiceList(dir, callback) {
  var services = [];
  // For every directory in the service directory, if its a service control
  // directory then add it to the services list
  fs.readdir(dir, function (err, files) {
    if (err) callback(err);
    var processedCount = 0;
    files.forEach(function (file) {
      fs.stat(path.join(dir, file), function (err, stats) {
        if (err) {
          log.warn(err);
          processedCount++;
          if (processedCount == files.length) callback(undefined, services);
        }
        // Ignore errors - these aren't services
        else if (stats.isDirectory()) {
          readServiceControl(file, function (err, obj) {
            if (err) log.debug(file + ': ' + err);
            else services.push(obj);
            processedCount++;
            if (processedCount == files.length) callback(undefined, services);
          });
        } else {
          processedCount++;
          if (processedCount == files.length) callback(undefined, services);
        }
      });
    });
  });
};

function createRunsvLayout(dir, owner, group) {
  var utils = ["run", "finish"];
  path.exists(dir, function (exists) {
    !exists && fs.mkdirSync(dir, 0700);
    // Bootstrap the run file
    for (i in utils) {
      var cfile = utils[i],
          ppath = path.join(dir, cfile);
      path.exists(ppath, (function (ppath) {
        var func = function (exists) {
          console.log("Creating file, " + ppath);
          !exists && fs.open(ppath, "w", 0700, function (err, fd) {
            if (err) throw err;
            fs.write(fd, TEMPLATE[cfile]);<commit_msg>Forgot to give the absolute path to the service directory<commit_after>/*
 * Licensed to Cloudkick, Inc ('Cloudkick') under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * Cloudkick licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

var log = require('util/log');
var fs = require('fs');
var path = require('path');
var Buffer = require('buffer').Buffer;
var jspack = require('../extern/jspack/jspack').jspack;

function getServiceList(dir, callback) {
  var services = [];
  // For every directory in the service directory, if its a service control
  // directory then add it to the services list
  fs.readdir(dir, function (err, files) {
    if (err) callback(err);
    var processedCount = 0;
    files.forEach(function (file) {
      fs.stat(path.join(dir, file), function (err, stats) {
        if (err) {
          log.warn(err);
          processedCount++;
          if (processedCount == files.length) callback(undefined, services);
        }
        // Ignore errors - these aren't services
        else if (stats.isDirectory()) {
          readServiceControl(path.join(dir, file), function (err, obj) {
            if (err) log.debug(file + ': ' + err);
            else services.push(obj);
            processedCount++;
            if (processedCount == files.length) callback(undefined, services);
          });
        } else {
          processedCount++;
          if (processedCount == files.length) callback(undefined, services);
        }
      });
    });
  });
};

function createRunsvLayout(dir, owner, group) {
  var utils = ["run", "finish"];
  path.exists(dir, function (exists) {
    !exists && fs.mkdirSync(dir, 0700);
    // Bootstrap the run file
    for (i in utils) {
      var cfile = utils[i],
          ppath = path.join(dir, cfile);
      path.exists(ppath, (function (ppath) {
        var func = function (exists) {
          console.log("Creating file, " + ppath);
          !exists && fs.open(ppath, "w", 0700, function (err, fd) {
            if (err) throw err;
            fs.write(fd, TEMPLATE[cfile]);
{'fraction_non_alphanumeric': 0.11824707215715904, 'fraction_numerical': 0.004911220249338874, 'mean_word_length': 2.798421807747489, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4090722', 'n_tokens_mistral': 1474, 'n_tokens_neox': 1438, 'n_words': 525}