<commit_before>import sys
import os
import subprocess
from .downloader import Downloader
from .browsers import CHROMEDRIVER, GECKODRIVER, IEDRIVER


def download_chrome_driver(path_to_download="default", version="autodetect"):
    return download_driver(path_to_download, version, CHROMEDRIVER)


def download_gecko_driver(path_to_download="default", version="autodetect"):
    return download_driver(path_to_download, version, GECKODRIVER)


def download_ie_driver(path_to_download="default", version="autodetect"):
    return download_driver(path_to_download, version, IEDRIVER)


def download_driver(path_to_download, version, browser):
    driver = Downloader(browser)

    if version == "autodetect":
        driver_version = driver.browser.version_suported
    elif version == "latest":
        driver_version = driver.browser.version_latest
    else:
        driver_version = version

    file_name = driver.browser.file_name_zip
    file_name = file_name.replace('{version}', str(driver_version))

    download_url = "{}{}".format(driver.browser.base_url, file_name)
    download_url = download_url.replace("{version}", str(driver_version))

    if path_to_download == "default":

        driver.drivers_path += "{}{}{}".\
            format(str(driver.browser.driver), os.sep, str(driver_version))

        if not os.path.exists(driver.drivers_path):
            os.makedirs(driver.drivers_path)
        full_path = driver.drivers_path + os.sep + file_name
    else:
        full_path = path_to_download + os.sep + file_name

    if driver._check_driver_exists(full_path):
        return full_path

    driver._download_file(download_url, full_path)
    driver._unzip(full_path, driver.drivers_path, True)
    if sys.platform == "linux" and browser == CHROMEDRIVER:
        make_executable = "chmod +x {}{}{}".format(driver.drivers_path, os.sep, "chromedriver")
        if int(sys.version[0]) == 3 and int(sys.version[2]) < 5:
            subprocess.Popen(make_executable, stdout=subprocess.PIPE, shell=True)
        else:
            subprocess.run(make_executable, stdout=subprocess.PIPE, shell=True)
    return driver._get_path(driver.browser.driver)<commit_msg>Using command module to give permission to chromedriver.<commit_after>import sys
import os
import subprocess
from .downloader import Downloader
from .browsers import CHROMEDRIVER, GECKODRIVER, IEDRIVER
from .commands import Commands


def download_chrome_driver(path_to_download="default", version="autodetect"):
    return download_driver(path_to_download, version, CHROMEDRIVER)


def download_gecko_driver(path_to_download="default", version="autodetect"):
    return download_driver(path_to_download, version, GECKODRIVER)


def download_ie_driver(path_to_download="default", version="autodetect"):
    return download_driver(path_to_download, version, IEDRIVER)


def download_driver(path_to_download, version, browser):
    driver = Downloader(browser)

    if version == "autodetect":
        driver_version = driver.browser.version_suported
    elif version == "latest":
        driver_version = driver.browser.version_latest
    else:
        driver_version = version

    file_name = driver.browser.file_name_zip
    file_name = file_name.replace('{version}', str(driver_version))

    download_url = "{}{}".format(driver.browser.base_url, file_name)
    download_url = download_url.replace("{version}", str(driver_version))

    if path_to_download == "default":

        driver.drivers_path += "{}{}{}".\
            format(str(driver.browser.driver), os.sep, str(driver_version))

        if not os.path.exists(driver.drivers_path):
            os.makedirs(driver.drivers_path)
        full_path = driver.drivers_path + os.sep + file_name
    else:
        full_path = path_to_download + os.sep + file_name

    if driver._check_driver_exists(full_path):
        return full_path

    driver._download_file(download_url, full_path)
    driver._unzip(full_path, driver.drivers_path, True)
    if sys.platform == "linux" and browser == CHROMEDRIVER:
        make_executable = "chmod +x {}{}{}".format(driver.drivers_path, os.sep, "chromedriver")
        Commands.run(make_executable)
    return driver._get_path(driver.browser.driver)
{'fraction_non_alphanumeric': 0.1071343920360275, 'fraction_numerical': 0.0009480919649205973, 'mean_word_length': 4.335018963337547, 'pattern_counts': {'":': 6, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 48, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6681100', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1305, 'n_words': 244}