<commit_before>#!/usr/bin/env ruby

require 'bundler'
Bundler.setup

require 'selenium-webdriver'
require 'capybara/rspec'
require 'capybara/dsl'
require 'rspec'

Capybara.run_server  = false
Capybara.app_host    = "http://172.16.17.32:80"
Capybara.server_port = 80

Capybara.register_driver :selenium_firefox_driver do |app|
  profile = Selenium::WebDriver::Firefox::Profile.new
  profile['media.navigator.permission.disabled'] = true
  Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile)
end
Capybara.default_driver = :selenium_firefox_driver

module Session
  extend Capybara::DSL

  def self.start
    visit '/'
    sleep 2
    page.execute_script "lo = {login: '101', password: '<PASSWORD>'}; phone.app.login(lo); phone.app.getAccessToAudio();"
    sleep 2
    page.execute_script "phone.app.call('000');"
    sleep 1
    page.execute_script "cid = phone.app.calls[0].id;"
    sleep 6
    # puts ">>> send DTMF 1"
    page.execute_script "phone.app.sendDTMF(cid, '1');"
    sleep 10
    # puts ">>> send DTMF 2"
    page.execute_script "phone.app.sendDTMF(cid, '2');"
    sleep 5
  end
end

arr = []

arr << Thread.new {
  Capybara.session_name = :one
  Session.start
}

arr << Thread.new {
  Capybara.session_name = :two
  Session.start
}

arr << Thread.new {
  Capybara.session_name = :three
  Session.start
}

arr.map { |t| t.join }
<commit_msg>cleanup thread spawning<commit_after>#!/usr/bin/env ruby

require 'bundler'
Bundler.setup

require 'selenium-webdriver'
require 'capybara/rspec'
require 'capybara/dsl'
require 'rspec'

Capybara.app_host    = 'http://172.16.17.32'
Capybara.run_server  = false
Capybara.server_port = 80

Capybara.register_driver :selenium_firefox_driver do |app|
  profile = Selenium::WebDriver::Firefox::Profile.new
  profile['media.navigator.permission.disabled'] = true
  Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile)
end
Capybara.default_driver = :selenium_firefox_driver

module Session
  extend Capybara::DSL

  def self.start
    visit '/'
    sleep 2
    page.execute_script "lo = {login: '101', password: '<PASSWORD>'}; phone.app.login(lo); phone.app.getAccessToAudio();"
    sleep 2
    page.execute_script "phone.app.call('000');"
    sleep 1
    page.execute_script "cid = phone.app.calls[0].id;"
    sleep 6
    # puts ">>> send DTMF 1"
    page.execute_script "phone.app.sendDTMF(cid, '1');"
    sleep 10
    # puts ">>> send DTMF 2"
    page.execute_script "phone.app.sendDTMF(cid, '2');"
    sleep 5
  end
end

threads = []
count   = 1

(1..count).each do |n|
  threads << Thread.new {
    Capybara.session_name = "session_#{n}"
    Session.start
  }
end

threads.map { |t| t.join }

{'fraction_non_alphanumeric': 0.14205816554809844, 'fraction_numerical': 0.023117076808351976, 'mean_word_length': 3.9049360146252283, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '2522656', 'n_tokens_mistral': 1040, 'n_tokens_neox': 996, 'n_words': 202}