<commit_before>#!/opt/rightscale/sandbox/bin/ruby
# Copyright (c) 2010 by RightScale Inc., all rights reserved
#
# Discover the IP

require 'fileutils'
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'shell_utilities'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'config', 'platform'))

SHEBANG_REGEX = /^#!/

module RightScale
  class CloudInfo
    def self.metadata_server_url
      begin
        #Resolve Euca metadata server hostname
        addrs = Socket.gethostbyname('euca-metadata')[3..-1]
        #Select only IPv4 addresses
        addrs = addrs.select { |x| x.length == 4 }
        #Choose a random IPv4 address
        raw_ip = addrs[rand(addrs.size)]
        #Transform binary IP address into string representation
        ip = []
        raw_ip.each_byte { |x| ip << x.to_s }
        host = ip.join('.')
        port = 8773
      rescue Exception => e
        #Fall back to EC2-style fixed IP address
        host = '169.254.169.254'
        port = 80
      end

      return "http://#{host}:#{port}"
    end
  end
end<commit_msg>Remove useless dependency from cloud_info<commit_after>#!/opt/rightscale/sandbox/bin/ruby
# Copyright (c) 2010 by RightScale Inc., all rights reserved
#
# Discover the IP

require 'fileutils'
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'config', 'platform'))

SHEBANG_REGEX = /^#!/

module RightScale
  class CloudInfo
    def self.metadata_server_url
      begin
        #Resolve Euca metadata server hostname
        addrs = Socket.gethostbyname('euca-metadata')[3..-1]
        #Select only IPv4 addresses
        addrs = addrs.select { |x| x.length == 4 }
        #Choose a random IPv4 address
        raw_ip = addrs[rand(addrs.size)]
        #Transform binary IP address into string representation
        ip = []
        raw_ip.each_byte { |x| ip << x.to_s }
        host = ip.join('.')
        port = 8773
      rescue Exception => e
        #Fall back to EC2-style fixed IP address
        host = '169.254.169.254'
        port = 80
      end

      return "http://#{host}:#{port}"
    end
  end
end
{'fraction_non_alphanumeric': 0.13564814814814816, 'fraction_numerical': 0.025925925925925925, 'mean_word_length': 2.4967637540453076, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '7037424', 'n_tokens_mistral': 741, 'n_tokens_neox': 696, 'n_words': 179}