<commit_before>require 'rubygems'
require 'net/sftp'
require 'find'

# This module contains functions for uploading the pages to a remote site.
#
# It requires the following constants to be declared to work:
#   HOSTNAME - the hostname of the server
#   USERNAME - your username to login with
#   PASSWORD - <PASSWORD>

module SftpUploader  
  # This function writes the 'string' to the file of name 'filename' to the
  #  'remote_path'.
  def write_string_to_remote_file(filename, string, remote_path)
    Net::SFTP.start(HOSTNAME, USERNAME, :password => PASSWORD) do |sftp|
      file_perm = 0644
      begin
        file = sftp.open!(remote_path + filename, 'w')
      rescue Net::SFTP::StatusException => e
        raise unless e.code == 2
        puts 'Error: file #{filename} on remote server'
        next
      end
      
      sftp.write!(file, 0, string)
      sftp.close!(file)
    end
  end


  # This function uploads the 'local_file' to the 'remote_path'. It checks if
  #  the file has been modified more recently than the one on the server it will
  #  upload the new version otherwise it does not upload the file.
  def upload_file(local_file, remote_path)
    Net::SFTP.start(HOSTNAME, USERNAME, :password => PASSWORD) do |sftp|
      file_perm = 0644
      next if File.stat(local_file).directory?
      remote_file = remote_path + "/" + local_file
      
      begin
        rstat = sftp.stat!(remote_file)
      rescue Net::SFTP::StatusException => e
        raise unless e.code == 2
        puts "Copying #{local_file} to #{remote_file}"
        sftp.upload(local_file, remote_file)<commit_msg>added notification of file uploading<commit_after>require 'rubygems'
require 'net/sftp'
require 'find'

# This module contains functions for uploading the pages to a remote site.
#
# It requires the following constants to be declared to work:
#   HOSTNAME - the hostname of the server
#   USERNAME - your username to login with
#   PASSWORD - <PASSWORD>

module SftpUploader  
  # This function writes the 'string' to the file of name 'filename' to the
  #  'remote_path'.
  def write_string_to_remote_file(filename, string, remote_path)
    Net::SFTP.start(HOSTNAME, USERNAME, :password => PASSWORD) do |sftp|
      file_perm = 0644
      begin
        file = sftp.open!(remote_path + filename, 'w')
      rescue Net::SFTP::StatusException => e
        raise unless e.code == 2
        puts 'Error: file #{filename} on remote server'
        next
      end
      
      puts "Writing file #{filename} to #{remote_path}"
      sftp.write!(file, 0, string)
      sftp.close!(file)
    end
  end


  # This function uploads the 'local_file' to the 'remote_path'. It checks if
  #  the file has been modified more recently than the one on the server it will
  #  upload the new version otherwise it does not upload the file.
  def upload_file(local_file, remote_path)
    Net::SFTP.start(HOSTNAME, USERNAME, :password => PASSWORD) do |sftp|
      file_perm = 0644
      next if File.stat(local_file).directory?
      remote_file = remote_path + "/" + local_file
      
      begin
        rstat = sftp.stat!(remote_file)
      rescue Net::SFTP::StatusException => e
        raise unless e.code == 2
        puts "Copying #{local_file} to #{remote_file}"
        sftp.upload(local_file, remote_file)
{'fraction_non_alphanumeric': 0.09000302023557838, 'fraction_numerical': 0.006644518272425249, 'mean_word_length': 3.0243013365735116, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '3712576', 'n_tokens_mistral': 1046, 'n_tokens_neox': 1013, 'n_words': 345}