<commit_before>require 'open3'
require 'colorize'

def sheepdog_ping(tag,r)
  ok = redis_ping(r)

  errval = !ok
  event = {
    time: Time.new.to_s,
    elapsed: 0,
    host: Socket.gethostname, # sending host
    command: 'sheepdog_ping.rb',
    tag: tag,
    stdout: "",
    stderr: "",
    status: 0,
    err: "SUCCESS"
  }
  event
end

def run(tag,cmd,verbose=false)
  starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)

  print(cmd.green+"\n") if verbose
  begin
    stdout, stderr, status = Open3.capture3(cmd)
    errval = status.exitstatus
  rescue Errno::ENOENT
    stderr = "Command not found"
    err    = "CMD_NOT_FOUND"
    errval = 1
  end

  ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  elapsed = ending - starting

  time = Time.now
  # timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
  timestamp = time.to_i

  event = {
    time: time.to_s,
    elapsed: elapsed.round(),
    host: Socket.gethostname, # sending host
    command: cmd,
    tag: tag,
    stdout: stdout,
    stderr: stderr,<commit_msg>spaces<commit_after>require 'open3'
require 'colorize'

def sheepdog_ping(tag,r)
  ok = redis_ping(r)

  errval = !ok
  event = {
    time: Time.new.to_s,
    elapsed: 0,
    host: Socket.gethostname, # sending host
    command: 'sheepdog_ping.rb',
    tag: tag,
    stdout: "",
    stderr: "",
    status: 0,
    err: "SUCCESS"
  }
  event
end

def run(tag, cmd, verbose=false)
  starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)

  print(cmd.green+"\n") if verbose
  begin
    stdout, stderr, status = Open3.capture3(cmd)
    errval = status.exitstatus
  rescue Errno::ENOENT
    stderr = "Command not found"
    err    = "CMD_NOT_FOUND"
    errval = 1
  end

  ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  elapsed = ending - starting

  time = Time.now
  # timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
  timestamp = time.to_i

  event = {
    time: time.to_s,
    elapsed: elapsed.round(),
    host: Socket.gethostname, # sending host
    command: cmd,
    tag: tag,
    stdout: stdout,
    stderr: stderr,
{'fraction_non_alphanumeric': 0.12928123492522914, 'fraction_numerical': 0.005788712011577424, 'mean_word_length': 3.074656188605108, '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': '3055912', 'n_tokens_mistral': 799, 'n_tokens_neox': 768, 'n_words': 171}