|
14 | 14 |
|
15 | 15 | import logistro |
16 | 16 |
|
17 | | -from choreographer.cli.defaults import default_download_path |
| 17 | +from choreographer.cli.defaults import default_download_path, old_download_path |
18 | 18 |
|
19 | 19 | _logger = logistro.getLogger(__name__) |
20 | 20 |
|
@@ -42,36 +42,44 @@ def get_google_supported_platform_string() -> str | None: |
42 | 42 | return platform_string |
43 | 43 |
|
44 | 44 |
|
45 | | -def get_chrome_download_path() -> Path | None: |
| 45 | +def get_chrome_download_path( |
| 46 | + root=default_download_path, |
| 47 | + *, |
| 48 | + mkdir=True, |
| 49 | +) -> Path | None: |
46 | 50 | _chrome_platform_detected = get_google_supported_platform_string() |
47 | 51 |
|
48 | 52 | if not _chrome_platform_detected: |
49 | 53 | return None |
50 | 54 |
|
51 | | - _default_exe_path = default_download_path |
52 | | - _default_exe_path.mkdir(parents=True, exist_ok=True) |
| 55 | + _default_exe_path = root |
| 56 | + if mkdir: |
| 57 | + _default_exe_path.mkdir(parents=True, exist_ok=True) |
53 | 58 |
|
54 | 59 | if platform.system().startswith("Linux"): |
55 | | - _default_exe_path = ( |
56 | | - default_download_path / f"chrome-{_chrome_platform_detected}" / "chrome" |
57 | | - ) |
| 60 | + _default_exe_path /= f"chrome-{_chrome_platform_detected}/chrome" |
58 | 61 | elif platform.system().startswith("Darwin"): |
59 | | - _default_exe_path = ( |
60 | | - default_download_path |
61 | | - / f"chrome-{_chrome_platform_detected}" |
62 | | - / "Google Chrome for Testing.app" |
63 | | - / "Contents" |
64 | | - / "MacOS" |
65 | | - / "Google Chrome for Testing" |
| 62 | + _default_exe_path /= ( |
| 63 | + f"chrome-{_chrome_platform_detected}" |
| 64 | + "/Google Chrome for Testing.app" |
| 65 | + "/Contents" |
| 66 | + "/MacOS" |
| 67 | + "/Google Chrome for Testing" |
66 | 68 | ) |
67 | 69 | elif platform.system().startswith("Win"): |
68 | | - _default_exe_path = ( |
69 | | - default_download_path / f"chrome-{_chrome_platform_detected}" / "chrome.exe" |
70 | | - ) |
| 70 | + _default_exe_path /= f"chrome-{_chrome_platform_detected}/chrome.exe" |
71 | 71 |
|
72 | 72 | return _default_exe_path |
73 | 73 |
|
74 | 74 |
|
| 75 | +# can remove this and it's default after some time - 2025/11/29 |
| 76 | +def get_old_chrome_download_path(): |
| 77 | + return get_chrome_download_path( |
| 78 | + root=old_download_path, |
| 79 | + mkdir=False, |
| 80 | + ) |
| 81 | + |
| 82 | + |
75 | 83 | # https://stackoverflow.com/questions/39296101/python-zipfile-removes-execute-permissions-from-binaries |
76 | 84 | class _ZipFilePermissions(zipfile.ZipFile): |
77 | 85 | def _extract_member(self, member, targetpath, pwd): # type: ignore [no-untyped-def] |
|
0 commit comments