<commit_before>require 'rexml/document'
include REXML

class Puppet::Provider::Checklcstatus <  Puppet::Provider
  def initialize (ip,username,password)
    @ip = ip
    @username = username
    @password = password
  end
  def checklcstatus
    response = `wsman invoke -a "GetRemoteServicesAPIStatus"  http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_LCService?SystemCreationClassName="DCIM_ComputerSystem",CreationClassName="DCIM_LCService",SystemName="DCIM:ComputerSystem",Name="DCIM:LCService" -h #{@ip} -V -v -c dummy.cert -P 443 -u #{@username} -p #{@password} -j utf-8 -y basic`
    puts response
    xmldoc = Document.new(response)
    lcnode = XPath.first(xmldoc, "//n1:LCStatus")
    lcstatus=lcnode.text
    puts "lc status #{lcstatus}"
    return lcstatus 
  end
end<commit_msg>Modified code to handle interactive command output.<commit_after>require 'rexml/document'
include REXML
require 'pty'

class Puppet::Provider::Checklcstatus <  Puppet::Provider
  def initialize (ip,username,password)
    @ip = ip
    @username = username
    @password = password
  end

  def checklcstatus

    cmd = "wsman invoke -a \"GetRemoteServicesAPIStatus\"  http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_LCService?SystemCreationClassName=\"DCIM_ComputerSystem\",CreationClassName=\"DCIM_LCService\",SystemName=\"DCIM:ComputerSystem\",Name=\"DCIM:LCService\" -h #{@ip} -V -v -c dummy.cert -P 443 -u #{@username} -p #{@password} -j utf-8 -y basic"
    #puts ("#{cmd}")
    lcstatus = ""
    response = ""

    PTY.spawn(cmd) do
        |output, input, pid|
        #input.write("hello from parent\n")
        buffer = ""
        output.readpartial(2048, buffer) until buffer =~ /Authentication failed/ || buffer =~ /xml version=/ || buffer =~ /Connection failed./
        #puts "#{buffer}"
        response = buffer
    end
   
    if response =~ /xml version=/
        xmldoc = Document.new(response)
        lcnode = XPath.first(xmldoc, "//n1:LCStatus")
        lcstatus=lcnode.text
        puts "lc status #{lcstatus}"
       # return lcstatus
    end

    if response =~ /Authentication failed/
        raise "Authentication failed, please retry with correct credentials after resetting the iDrac."
    end

     if response =~ /Connection failed./
         raise "Connection failed, Couldn't connect to server. Please check IP address credentials."
     end

return lcstatus
  end
end
{'fraction_non_alphanumeric': 0.12716763005780346, 'fraction_numerical': 0.007431874483897605, 'mean_word_length': 3.3815551537070525, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 2, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '5698284', 'n_tokens_mistral': 789, 'n_tokens_neox': 772, 'n_words': 190}