<commit_before>require 'open-uri'
require 'net-purge'

def quietly_try_to_open(url)
    begin 
        result = open(url).read.strip
    rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH
        Rails.logger.warn("Unable to open third-party URL #{url}")
        result = ""
    end
    return result
end
    
def quietly_try_to_purge(host, url)
    begin 
        result = ""
        result_body = ""
        Net::HTTP.bind '127.0.0.1' do 
            Net::HTTP.start(host) {|http|
                request = Net::HTTP::Purge.new(url)
                response = http.request(request)
                result = response.code
                result_body = response.body
            }
        end
    rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH
        Rails.logger.warn("PURGE: Unable to reach host #{host}")
    end
    if result == "200"
        Rails.logger.info("PURGE: Purged URL #{url} at #{host}: #{result}")
    else
        Rails.logger.warn("PURGE: Unable to purge URL #{url} at #{host}: status #{result}")
    end
    return result
end
    <commit_msg>Make successful PURGEs log at debug level to reduce unecessary noise at default level (info)<commit_after>require 'open-uri'
require 'net-purge'

def quietly_try_to_open(url)
    begin 
        result = open(url).read.strip
    rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH
        Rails.logger.warn("Unable to open third-party URL #{url}")
        result = ""
    end
    return result
end
    
def quietly_try_to_purge(host, url)
    begin 
        result = ""
        result_body = ""
        Net::HTTP.bind '127.0.0.1' do 
            Net::HTTP.start(host) {|http|
                request = Net::HTTP::Purge.new(url)
                response = http.request(request)
                result = response.code
                result_body = response.body
            }
        end
    rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH
        Rails.logger.warn("PURGE: Unable to reach host #{host}")
    end
    if result == "200"
        Rails.logger.debug("PURGE: Purged URL #{url} at #{host}: #{result}")
    else
        Rails.logger.warn("PURGE: Unable to purge URL #{url} at #{host}: status #{result}")
    end
    return result
end
    
{'fraction_non_alphanumeric': 0.11970074812967581, 'fraction_numerical': 0.007481296758104738, 'mean_word_length': 2.4238975817923185, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7206115', 'n_tokens_mistral': 785, 'n_tokens_neox': 773, 'n_words': 182}