Skip to content

Commit 9c1d652

Browse files
authored
Update install.py (#369)
Updating to Check Location of Firefox Install
1 parent 09dd87a commit 9c1d652

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

install.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,16 @@ def _get_latest_compatible_release(releases):
123123
if firefox_version in release["supported"]:
124124
return release
125125
return None
126-
126+
def _get_firefox_version(bin="firefox"):
127+
try:
128+
ver_string = check_output([bin, "--version"], encoding="UTF-8")
129+
return ver_string[ver_string.rindex(" ")+1:].strip()
130+
except FileNotFoundError:
131+
default_path = str(DEFAULT_FIREFOX_INSTALL.joinpath("firefox"))
132+
if bin != default_path: # Avoid infinite recursion
133+
return _get_firefox_version(default_path)
134+
else:
135+
raise Exception("Firefox binary not found. Please ensure Firefox is installed and the path is correct.")
127136

128137
def backup_profile(src):
129138
dest = f"{src}-backup-{datetime.today().strftime('%Y-%m-%d-%H-%M-%S')}"

0 commit comments

Comments
 (0)