<commit_before>require 'yaml'
require 'fileutils'
include FileUtils

module Notify

  def get_repo(repo_name)
    settings = YAML.load(IO.read("config/repo.yml"))
    return settings['repositories'][repo_name]
  end

  def checkout(repo)
    if File.exists?(repo['checkout-to'])
      cd repo['checkout-to']
      system("git pull")
    else
      cd File.dirname(repo['checkout-to'])
      baseName = File.basename(repo['checkout-to'])
    
      system("git clone #{repo['url']} #{baseName}")
    
      cd repo['checkout-to']
    end
  end

  def find_commands(repo)
    cd repo['commands']
    puts "Pwd: #{pwd()}"
    commands = []
    Dir.glob("*") do |f|
      if File.executable?(f)
        puts "Found: #{f}"
        commands << f
      end
    end
    return commands
  end

  def run_commands(commands)
    passed = []
    failed = []
    commands.each do |cmd|
      puts "Trying: #{cmd}"
      success = system("./#{cmd} >/tmp/out 2>&1")
      if success
        passed << cmd
      else
        failed << cmd
      end
    end
    return passed, failed
  end
 
  def display_report(passed, failed)
    puts "----------------"
    puts "Report"
    puts "Passed: #{passed.length}"
    puts "Failed: #{failed.length}"
  end

  def handle_alert(repo, failed)
    if !failed.empty?
      puts "Send alert to #{repo['alert']}"
    end
  end
end
<commit_msg>added mail lines on failure<commit_after>require 'yaml'
require 'fileutils'
include FileUtils

module Notify

  def get_repo(repo_name)
    settings = YAML.load(IO.read("config/repo.yml"))
    return settings['repositories'][repo_name]
  end

  def checkout(repo)
    if File.exists?(repo['checkout-to'])
      cd repo['checkout-to']
      system("git pull")
    else
      cd File.dirname(repo['checkout-to'])
      baseName = File.basename(repo['checkout-to'])
    
      system("git clone #{repo['url']} #{baseName}")
    
      cd repo['checkout-to']
    end
  end

  def find_commands(repo)
    cd repo['commands']
    puts "Pwd: #{pwd()}"
    commands = []
    Dir.glob("*") do |f|
      if File.executable?(f)
        puts "Found: #{f}"
        commands << f
      end
    end
    return commands
  end

  def run_commands(commands)
    passed = []
    failed = []
    commands.each do |cmd|
      puts "Trying: #{cmd}"
      success = system("./#{cmd} >/tmp/out 2>&1")
      if success
        passed << cmd
      else
        failed << cmd
      end
    end
    return passed, failed
  end
 
  def display_report(passed, failed)
    puts "----------------"
    puts "Report"
    puts "Passed: #{passed.length}"
    puts "Failed: #{failed.length}"
  end

  def handle_alert(repo, failed)
    if !failed.empty?
      puts "Send alert to #{repo['alert']}"
      subject = "#{failed.length} #{repo['subject']}"
      recips = repo['alert'].gsub(',', ' ')
      system("echo \"Failed: #{failed[0]}\" | mail -s \"#{subject}\" #{recips}")
    end
  end
end

{'fraction_non_alphanumeric': 0.1606837606837607, 'fraction_numerical': 0.0017094017094017094, 'mean_word_length': 2.3826589595375722, 'pattern_counts': {'":': 0, '<': 15, '<?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': '1144829', 'n_tokens_mistral': 973, 'n_tokens_neox': 971, 'n_words': 240}