from helium.bfs10060.system import bfs10122
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.chrome.service import Service as bfs10131
from selenium.webdriver.common import utils
from time import sleep
import os
import selenium
import selenium.webdriver.chrome.webdriver
import subprocess
import sys
def bfs10137():
  global bfs10133
  if (not bfs10135()):
    return 

  if (sys.version_info[:2] < (2, 7)):
    from _subprocess import STARTF_USESTDHANDLES, STARTF_USESHOWWINDOW, SW_HIDE, CREATE_NEW_CONSOLE
  else:
    from subprocess import STARTF_USESTDHANDLES, STARTF_USESHOWWINDOW, SW_HIDE, CREATE_NEW_CONSOLE

  class bfs10134(bfs10131):
    def start(self):
      env = (self.env or os.environ)
      try:
        bfs10136 = subprocess.STARTUPINFO()
        bfs10136.dwFlags = (STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW)
        bfs10136.wShowWindow = SW_HIDE
        bfs10136.hStdInput = open(os.devnull, 'r').fileno()
        bfs10136.hStdOutput = open(os.devnull, 'w').fileno()
        bfs10136.hStdError = open(os.devnull, 'w').fileno()
        self.process = subprocess.Popen(([self.path, ('--port=%d' % self.port)] + self.service_args), env=env, close_fds=True, creationflags=CREATE_NEW_CONSOLE, startupinfo=bfs10136)
      except:
        raise WebDriverException(('Could not execute ChromeDriver located at %s.' % self.path))

      count = 0
      while (not utils.is_connectable(self.port)):
        count += 1
        sleep(1)
        if (count == 30):
          raise WebDriverException('Can not connect to the ChromeDriver')




  selenium.webdriver.chrome.webdriver.Service = bfs10134
  bfs10133 = True

def bfs10135():
  if bfs10133:
    return False

  if (not bfs10122()):
    return False

  try:
    bfs10141 = tuple(map(int, selenium.__version__.split('.')))
  except:
    return False
  else:
    return (bfs10141 >= (2, 32, 0))


bfs10133 = False
