<commit_before>#!/usr/bin/env python3
import sys, getopt, os
import signal
import time
import pprint
import logging
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0


class JibriSeleniumDriver():
    def __init__(self, 
            url, 
            authtoken=None, 
            xmpp_connect_timeout=60, 
            binary_location=None, 
            google_account=None,
            google_account_password=<PASSWORD>, 
            displayname='Live Stream', 
            email='<EMAIL>',
            xmpp_login = None,
            xmpp_password = <PASSWORD>,
            pjsua_flag = False):

      #init based on url and optional token
      self.url = url
      self.authtoken = authtoken
      self.google_account = google_account
      self.google_account_password = <PASSWORD>
      self.displayname = displayname
      self.xmpp_login = xmpp_login
      self.xmpp_password = <PASSWORD>
      self.email = email
      self.pjsua_flag = pjsua_flag

      self.flag_jibri_identifiers_set = False
      self.flag_google_login_set = False

      #only wait this only before failing to load meet
      self.xmpp_connect_timeout = xmpp_connect_timeout

      self.desired_capabilities = DesiredCapabilities.CHROME
      self.desired_capabilities['loggingPrefs'] = { 'browser':'ALL' }

      self.options = Options()
      self.options.add_argument('--use-fake-ui-for-media-stream')
      self.options.add_argument('--start-maximized')
      self.options.add_argument('--kiosk')
      self.options.add_argument('--enabled')
      self.options.add_argument('--enable-logging')
      self.options.add_argument('--vmodule=*=3')
      self.options.add_argument('--alsa-output-device=plug:amix')

      #use microphone if provided
      if self.pjsua_flag:
        self.options.add_argument('--alsa-input-device=plughw:1,1')
        self.xmpp_login=None
        self.xmpp_password=None

      if binary_location:
        self.options.binary_location = binary_location
      self.initDriver()

    def initDriver(self, options=None, desired_capabilities=None):
      #make sure the environment is set properly
      display=os.environ.get('DISPLAY', None)
      if not display:
        os.environ['DISPLAY'] =':0'

      if not desired_capabilities:
        desired_capabilities = self.desired_capabilities
      if not options:
        options = self.options

      print("Initializing Driver")
      self.driver = webdriver.Chrome(chrome_options=options, desired_capabilities=desired_capabilities)<commit_msg>info bars bring only problems for live streaming, so disable them<commit_after>#!/usr/bin/env python3
import sys, getopt, os
import signal
import time
import pprint
import logging
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0


class JibriSeleniumDriver():
    def __init__(self, 
            url, 
            authtoken=None, 
            xmpp_connect_timeout=60, 
            binary_location=None, 
            google_account=None,
            google_account_password=<PASSWORD>, 
            displayname='Live Stream', 
            email='<EMAIL>',
            xmpp_login = None,
            xmpp_password = <PASSWORD>,
            pjsua_flag = False):

      #init based on url and optional token
      self.url = url
      self.authtoken = authtoken
      self.google_account = google_account
      self.google_account_password = <PASSWORD>_account_password
      self.displayname = displayname
      self.xmpp_login = xmpp_login
      self.xmpp_password = xmpp_password
      self.email = email
      self.pjsua_flag = pjsua_flag

      self.flag_jibri_identifiers_set = False
      self.flag_google_login_set = False

      #only wait this only before failing to load meet
      self.xmpp_connect_timeout = xmpp_connect_timeout

      self.desired_capabilities = DesiredCapabilities.CHROME
      self.desired_capabilities['loggingPrefs'] = { 'browser':'ALL' }

      self.options = Options()
      self.options.add_argument('--use-fake-ui-for-media-stream')
      self.options.add_argument('--start-maximized')
      self.options.add_argument('--kiosk')
      self.options.add_argument('--enabled')
      self.options.add_argument('--enable-logging')
      self.options.add_argument('--vmodule=*=3')
      self.options.add_argument("--disable-infobars")      
      self.options.add_argument('--alsa-output-device=plug:amix')

      #use microphone if provided
      if self.pjsua_flag:
        self.options.add_argument('--alsa-input-device=plughw:1,1')
        self.xmpp_login=None
        self.xmpp_password=None

      if binary_location:
        self.options.binary_location = binary_location
      self.initDriver()

    def initDriver(self, options=None, desired_capabilities=None):
      #make sure the environment is set properly
      display=os.environ.get('DISPLAY', None)
      if not display:
        os.environ['DISPLAY'] =':0'

      if not desired_capabilities:
        desired_capabilities = self.desired_capabilities
      if not options:
        options = self.options

      print("Initializing Driver")
      self.driver = webdriver.Chrome(chrome_options=options, desired_capabilities=desired_capabilities)
{'fraction_non_alphanumeric': 0.0882936507936508, 'fraction_numerical': 0.004629629629629629, 'mean_word_length': 3.1121685927940175, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '4872462', 'n_tokens_mistral': 1823, 'n_tokens_neox': 1745, 'n_words': 356}