<commit_before>#!/usr/bin/ruby

require 'rubygems'
require 'uri'
require 'OpenNebula'

require 'net/https'

begin
    require 'curb'
    CURL_LOADED=true
rescue LoadError
    CURL_LOADED=false
end

begin
    require 'net/http/post/multipart'
rescue LoadError
end



module ONEOCCIClient
    
    #####################################################################
    #  Client Library to interface with the OpenNebula OCCI Service
    #####################################################################
    class Client
        
        ######################################################################
        # Initialize client library
        ######################################################################
        def initialize(endpoint_str=nil, user=nil, pass=nil, debug_flag=false)
            @debug = debug_flag
            
            # Server location
            if endpoint_str
                @endpoint =  endpoint_str
            elsif ENV["OCCI_URL"]
                @endpoint = ENV["OCCI_URL"]
            else
                @endpoint = "http://localhost:4567"
            end
            
            # Autentication            
            if user && pass
                @occiauth = user + ":" + Digest::SHA1.hexdigest(pass)  
            elsif ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and File.file?(ENV["ONE_AUTH"])
                one_auth=File.read(ENV["ONE_AUTH"])
            elsif File.file?(ENV["HOME"]+"/.one/one_auth")
                one_auth=File.read(ENV["HOME"]+"/.one/one_auth")
            else
                raise "No authorization data present"
                return
            end
            
            one_auth=~/(\w+):(\w+)/
            user  = $1
            pass  = $2
            
            if user && pass
                @occiauth = user + ":" + Digest::SHA1.hexdigest(pass)
            else
                raise "Authorization data malformed"
            end          
        end
        
        # Starts an http connection and calls the block provided. SSL flag
        # is set if needed.
        def http_start(url, &block)
            http = Net::HTTP.new(url.host, url.port)
            http.use_ssl = (url.scheme == 'https')
            http.start do |connection|
                block.call(connection)
            end
        end

        #################################
        # Pool Resource Request Methods #<commit_msg>Disabled HTTPS Server certificate check and warning<commit_after>#!/usr/bin/ruby

require 'rubygems'
require 'uri'
require 'OpenNebula'

require 'net/https'

begin
    require 'curb'
    CURL_LOADED=true
rescue LoadError
    CURL_LOADED=false
end

begin
    require 'net/http/post/multipart'
rescue LoadError
end



module ONEOCCIClient
    
    #####################################################################
    #  Client Library to interface with the OpenNebula OCCI Service
    #####################################################################
    class Client
        
        ######################################################################
        # Initialize client library
        ######################################################################
        def initialize(endpoint_str=nil, user=nil, pass=nil, debug_flag=false)
            @debug = debug_flag
            
            # Server location
            if endpoint_str
                @endpoint =  endpoint_str
            elsif ENV["OCCI_URL"]
                @endpoint = ENV["OCCI_URL"]
            else
                @endpoint = "http://localhost:4567"
            end
            
            # Autentication            
            if user && pass
                @occiauth = user + ":" + Digest::SHA1.hexdigest(pass)  
            elsif ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and File.file?(ENV["ONE_AUTH"])
                one_auth=File.read(ENV["ONE_AUTH"])
            elsif File.file?(ENV["HOME"]+"/.one/one_auth")
                one_auth=File.read(ENV["HOME"]+"/.one/one_auth")
            else
                raise "No authorization data present"
                return
            end
            
            one_auth=~/(\w+):(\w+)/
            user  = $1
            pass  = $2
            
            if user && pass
                @occiauth = user + ":" + Digest::SHA1.hexdigest(pass)
            else
                raise "Authorization data malformed"
            end          
        end
        
        # Starts an http connection and calls the block provided. SSL flag
        # is set if needed.
        def http_start(url, &block)
            http = Net::HTTP.new(url.host, url.port)
            if url.scheme=='https'
                http.use_ssl = true
                http.verify_mode=OpenSSL::SSL::VERIFY_NONE
            end
            
            http.start do |connection|
                block.call(connection)
            end
        end

        #################################
        # Pool Resource Request Methods #
{'fraction_non_alphanumeric': 0.20570510245078344, 'fraction_numerical': 0.0032141422257934912, 'mean_word_length': 1.7432506887052341, 'pattern_counts': {'":': 4, '<': 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': '4920709', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1235, 'n_words': 283}