Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Automatically download and install [chromedriver](https://chromedriver.chromium.
## Installation

```bash
pip install chromedriver-autoinstaller
pip install git+https://github.com/willnaoosmith/python-chromedriver-autoinstaller.git@master
```

## Usage
Expand Down
34 changes: 33 additions & 1 deletion chromedriver_autoinstaller/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def get_chrome_version():
platform, _ = get_platform_architecture()
if platform == "linux":
path = get_linux_executable_path()
with subprocess.Popen([path, "--version"], stdout=subprocess.PIPE) as proc:
with subprocess.Popen([path, "--version"], stdout=subprocess.PIPE, shell=True) as proc:
version = (
proc.stdout.read()
.decode("utf-8")
Expand All @@ -137,6 +137,7 @@ def get_chrome_version():
"--version",
],
stdout=subprocess.PIPE,
shell=True
)
version = (
process.communicate()[0]
Expand All @@ -145,8 +146,39 @@ def get_chrome_version():
.strip()
)
elif platform == "win":
process = subprocess.Popen(
[
"reg",
"query",
"HKEY_CURRENT_USER\\Software\\Google\\Chrome\\BLBeacon",
"/v",
"version",
],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
stdin=subprocess.DEVNULL,
shell=True
)
output = process.communicate()
if output and output[0] and len(output[0]) > 0:
version = output[0].decode("UTF-8").strip().split()[-1]
else:
process = subprocess.Popen(
[
"powershell",
"-command",
"$(Get-ItemProperty -Path Registry::HKEY_CURRENT_USER\\Software\\Google\\chrome\\BLBeacon).version",
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
shell=True
)
version = process.communicate()[0].decode("UTF-8").strip()

dirs = [f.name for f in os.scandir("C:\\Program Files\\Google\\Chrome\\Application") if f.is_dir() and re.match("^[0-9.]+$", f.name)]
version = max(dirs)

else:
return
return version
Expand Down