<commit_before>require "/opt/engines/lib/ruby/ManagedContainer.rb"

require_relative "SoftwareService.rb"
class CronService < SoftwareService 
  
  def add_consumer_to_service(site_hash)
    site_hash[:container_name] = site_hash[:parent_engine]  
      return  add_cron(site_hash) 
     end
     
  def rm_consumer_from_service (site_hash)
       return  rebuild_crontab()  
  end 
     
  def get_site_hash(site_hash)
    site_hash[:service_type]='cron'
    site_hash[:service_provider] = "EnginesSystem"
        return site_hash          
   end
   
  #noop overloads 
   
    def reregister_consumers
          #No Need they are static
    end
    
  def format_cron_line(cron_hash)
      cron_line = String.new
      cron_line_split = cron_hash[:cron_job].split(/[\s\t]{1,10}/)
      for n in 0..4
        cron_line +=  cron_line_split[n] + " "
      end
      cron_line +=" docker exec " +  cron_hash[:container_name] + " "
      n=5
      cnt = cron_line_split.count

      while n < cnt
        cron_line += " " + cron_line_split[n]
        n+=1
      end
      return     cron_line
    rescue Exception=>e

      log_exception(e)

      return false
    end

  def remove_containers_cron_list(containerName)
   
    p :remove_cron_for
    p containerName

  consumers.each do |cron_job|
      if cron_job != nil
        p cron_job
        p :looking_at
        p cron_job[1][:container_name]
        if cron_job[1][:container_name] ==  containerName
          remove_consumer(cron_job[1])
        end
      end
    end
  rescue Exception=>e

    log_exception(e)

    return false
  end

  
  def reload_crontab
    docker_cmd="docker exec cron crontab " + "/home/crontabs/crontab"
    return SystemUtils.run_system(docker_cmd)
  rescue Exception=>e
  
    SystemUtils.log_exception(e)
  
    return false
  end
  <commit_msg>system_cmd does not return boolean<commit_after>require "/opt/engines/lib/ruby/ManagedContainer.rb"

require_relative "SoftwareService.rb"
class CronService < SoftwareService 
  
  def add_consumer_to_service(site_hash)
    site_hash[:container_name] = site_hash[:parent_engine]  
      return  add_cron(site_hash) 
     end
     
  def rm_consumer_from_service (site_hash)
       return  rebuild_crontab()  
  end 
     
  def get_site_hash(site_hash)
    site_hash[:service_type]='cron'
    site_hash[:service_provider] = "EnginesSystem"
        return site_hash          
   end
   
  #noop overloads 
   
    def reregister_consumers
          #No Need they are static
    end
    
  def format_cron_line(cron_hash)
      cron_line = String.new
      cron_line_split = cron_hash[:cron_job].split(/[\s\t]{1,10}/)
      for n in 0..4
        cron_line +=  cron_line_split[n] + " "
      end
      cron_line +=" docker exec " +  cron_hash[:container_name] + " "
      n=5
      cnt = cron_line_split.count

      while n < cnt
        cron_line += " " + cron_line_split[n]
        n+=1
      end
      return     cron_line
    rescue Exception=>e

      log_exception(e)

      return false
    end

  def remove_containers_cron_list(containerName)
   
    p :remove_cron_for
    p containerName

  consumers.each do |cron_job|
      if cron_job != nil
        p cron_job
        p :looking_at
        p cron_job[1][:container_name]
        if cron_job[1][:container_name] ==  containerName
          remove_consumer(cron_job[1])
        end
      end
    end
  rescue Exception=>e

    log_exception(e)

    return false
  end

  
  def reload_crontab
    docker_cmd="docker exec cron crontab " + "/home/crontabs/crontab"
     SystemUtils.run_system(docker_cmd)
     return true
  rescue Exception=>e
  
    SystemUtils.log_exception(e)
  
    return false
  end
  
{'fraction_non_alphanumeric': 0.08049702863317126, 'fraction_numerical': 0.005402485143165856, 'mean_word_length': 2.441449814126394, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '5560048', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1261, 'n_words': 243}