Skip to content

Prepare undetectedchrome

prepare_undetectedchrome

Download chromedriver and apply undetected-chromedriver patch to be called from other languages like VBA return location via INI-file

ParamsClass

params_inifile: str | None = None class-attribute instance-attribute

executeMain(params: ParamsClass) -> None

main routine to download/initialize CloakBrowser and return informationv ia INI-fiel to caller

Parameters:

Name Type Description Default
params

parameter dataclass filled via CLI

required
Source code in src\utils_msoffice\prepare_undetectedchrome.py
def executeMain(params: ParamsClass) -> None:
    """
        main routine to download/initialize CloakBrowser and return informationv ia INI-fiel to caller

        Args:
            params (): parameter dataclass filled via CLI
        """

    # determine ini file for parameters calling cloakbrowser externally
    if params.params_inifile is None:
        params.params_inifile = os.path.join(tempfile.gettempdir(), "undetectedchrome.ini")

    patcher = Patcher()
    patcher.auto()

    # determine content of ini file
    config = configparser.ConfigParser()
    config.add_section("undetectedchrome")
    config["undetectedchrome"]["binary_path"] = patcher.executable_path

    # write back ini file
    with open(params.params_inifile, 'w') as configfile:
        config.write(configfile)

executeStandaloneTest() -> None

execute standalone test

Source code in src\utils_msoffice\prepare_undetectedchrome.py
def executeStandaloneTest() -> None:
    """
    execute standalone test
    """

    paramsparser = ParamsClass()
    params = paramsparser.parse_args()
    executeMain(params)

executeVBAcallee() -> None

callee from VBA (or other language via CLI)

Source code in src\utils_msoffice\prepare_undetectedchrome.py
def executeVBAcallee() -> None:
    """
    callee from VBA (or other language via CLI)
    """

    Utils.log_cli_args()
    paramsparser = ParamsClass(explicit_bool=True)
    params = paramsparser.parse_args()
    Utils.log_cli_params(params)

    executeMain(params)