Skip to content

trading_agent.doctor.checks.chrome_check

Checks that Google Chrome is installed for the browser tools.

Typical usage example:

result = ChromeCheck().run()

ChromeCheck

Bases: DoctorCheck

Checks for the google-chrome program.

run

run()

Looks for google-chrome and asks it for its version.

Returns:

Type Description
CheckResult

OK when Chrome is installed, failed otherwise.

Source code in src/trading_agent/doctor/checks/chrome_check.py
def run(self) -> doctor_check.CheckResult:
    """Looks for google-chrome and asks it for its version.

    Returns:
        doctor_check.CheckResult: OK when Chrome is installed, failed otherwise.
    """
    chrome_path = shutil.which('google-chrome')
    if chrome_path is None:
        return doctor_check.CheckResult(
            doctor_check.CheckStatus.FAILED,
            'google-chrome is not on PATH.',
        )
    completed = subprocess.run(
        [
            chrome_path,
            '--version',
        ],
        capture_output=True,
        text=True,
        timeout=_TIMEOUT_SECONDS,
        check=False,
    )
    return doctor_check.CheckResult(
        doctor_check.CheckStatus.OK,
        completed.stdout.strip(),
    )