<commit_before>
module Rudy; module Routines; module Handlers;
  module Group
    include Rudy::Routines::Handlers::Base
    extend self
    
    ##Rudy::Routines.add_handler :machines, self
    
    
    def raise_early_exceptions(name=nil)
      
    end
    
    def create(name=nil)
      name ||= current_group_name
      return if exists? name
      li "Creating group: #{name}"
      Rudy::AWS::EC2::Groups.create name
    end
    
    def authorize(name=nil, addresses=nil, ports=nil)
      name ||= current_group_name
      addresses ||= [Rudy::Utils::external_ip_address]
      if ports.nil?
        ports = current_machine_os.to_s == 'win32' ? [22,3389] : [22]
      end
      
      ports.each do |port|
        #li "Authorizing port #{port} access for: #{addresses.join(', ')}"
        Rudy::AWS::EC2::Groups.authorize(name, addresses, [[port, port]]) 
      end
      
    end
    
    def exists?(name=nil)
      name ||= current_group_name
      Rudy::AWS::EC2::Groups.exists? name
    end
    
    def destroy(name=nil)
      name ||= current_group_name
      return unless exists? name
      li "Destroying group: #{name}"
      Rudy::AWS::EC2::Groups.destroy name
    end
    
  end
end; end; end<commit_msg>Fix security group authorization for new windows instances<commit_after>
module Rudy; module Routines; module Handlers;
  module Group
    include Rudy::Routines::Handlers::Base
    extend self
    
    ##Rudy::Routines.add_handler :machines, self
    
    
    def raise_early_exceptions(name=nil)
      
    end
    
    def create(name=nil)
      name ||= current_group_name
      return if exists? name
      li "Creating group: #{name}"
      Rudy::AWS::EC2::Groups.create name
    end
    
    def authorize(name=nil, addresses=nil, ports=nil)
      name ||= current_group_name
      addresses ||= [Rudy::Utils::external_ip_address]
      if ports.nil?
        ports = current_machine_os.to_s == 'win32' ? [3389,22] : [22]
      end
      
      ports.each do |port|
        #li "Authorizing port #{port} access for: #{addresses.join(', ')}"
        Rudy::AWS::EC2::Groups.authorize(name, addresses, [[port, port]]) rescue nil
      end
      
    end
    
    def exists?(name=nil)
      name ||= current_group_name
      Rudy::AWS::EC2::Groups.exists? name
    end
    
    def destroy(name=nil)
      name ||= current_group_name
      return unless exists? name
      li "Destroying group: #{name}"
      Rudy::AWS::EC2::Groups.destroy name
    end
    
  end
end; end; end
{'fraction_non_alphanumeric': 0.11797528895974492, 'fraction_numerical': 0.011159824631327222, 'mean_word_length': 2.5602836879432624, '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': '4105416', 'n_tokens_mistral': 844, 'n_tokens_neox': 831, 'n_words': 192}