Skip to content

Commit a6a864c

Browse files
committed
Merge remote-tracking branch 'origin/main' into andrew/remove_unused_metas
2 parents c8d7882 + 530b66a commit a6a864c

File tree

10 files changed

+613
-386
lines changed

10 files changed

+613
-386
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ repos:
1818
- id: check-toml
1919
- id: debug-statements
2020
- repo: https://github.com/asottile/add-trailing-comma
21-
rev: v3.2.0
21+
rev: v4.0.0
2222
hooks:
2323
- id: add-trailing-comma
2424
- repo: https://github.com/astral-sh/ruff-pre-commit
2525
# Ruff version.
26-
rev: v0.13.3
26+
rev: v0.14.4
2727
hooks:
2828
# Run the linter.
2929
- id: ruff
@@ -48,7 +48,7 @@ repos:
4848
}\
4949
}"]
5050
- repo: https://github.com/rhysd/actionlint
51-
rev: v1.7.7
51+
rev: v1.7.8
5252
hooks:
5353
- id: actionlint
5454
name: Lint GitHub Actions workflow files
@@ -81,14 +81,14 @@ repos:
8181
entry: detect-secrets-hook
8282
args: ['']
8383
- repo: https://github.com/rvben/rumdl-pre-commit
84-
rev: v0.0.153 # Use the latest release tag
84+
rev: v0.0.173 # Use the latest release tag
8585
hooks:
8686
- id: rumdl
8787
# To only check (default):
8888
# args: []
8989
# To automatically fix issues:
9090
# args: [--fix]
9191
- repo: https://github.com/RobertCraigie/pyright-python
92-
rev: v1.1.406 # pin a tag; latest as of 2025-10-01
92+
rev: v1.1.407 # pin a tag; latest as of 2025-10-01
9393
hooks:
9494
- id: pyright

CHANGELOG.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
- Remove site directory
2+
- Improve error messaging
3+
- Organize functions internally
4+
- Improve choreo_diagnose
5+
- Add Roadmap
6+
- Bump logistro dependency
27
v1.2.0
38
- Delete zipfile after downloading
49
- Upgrade logistro to reduce sideeffects

ROADMAP.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Roadmap
2+
3+
- [ ] Working on better diagnostic information
4+
- [ ] Explain to user when their system has security restrictions
5+
- [ ] Eliminate synchronous API: it's unused, hard to maintain, and nearly
6+
worthless
7+
- [ ] Diagnose function should collect a JSON and then print that
8+
- [ ] Allow user to build and send their own JSONS
9+
- [ ] Get serialization out of the lock
10+
- [ ]
11+
- [ ] Support Firefox
12+
- [ ] Support LadyBird (!)
13+
- [ ] Test against multiple docker containers
14+
- [ ] Do browser-rolling tests
15+
- [ ] Do documentation
16+
- [ ] Browser Open/Close Status/PipeCheck status should happen at broker level
17+
- [ ] Broker should probably be opening browser and running watchdog...

choreographer/browser_async.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,11 @@ def run() -> subprocess.Popen[bytes] | subprocess.Popen[str]: # depends on args
169169
"The browser seemed to close immediately after starting.",
170170
"You can set the `logging.Logger` level lower to see more output.",
171171
"You may try installing a known working copy of Chrome by running ",
172-
"`$ choreo_get_chrome`. It may be your copy auto-updated.",
172+
"`$ choreo_get_chrome`."
173+
""
174+
"It may be your browser auto-updated and will now work upon "
175+
"restart. The browser we tried to start is located at "
176+
f"{self._browser_impl.path}.",
173177
) from e
174178

175179
async def __aenter__(self) -> Self:

choreographer/browsers/_interface_type.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@
1515
class BrowserImplInterface(Protocol):
1616
"""Defines the basic interface of a channel."""
1717

18+
path: str | Path | None
19+
"""The OS path to the operating system."""
20+
21+
@classmethod
22+
def find_browser(
23+
cls,
24+
*,
25+
skip_local: bool,
26+
skip_typical: bool = False,
27+
) -> str | None: ...
28+
29+
### Tries to find a working copy of itself, using our OS methods
30+
### as well as its own methods. See the Chromium implementation.
31+
1832
@classmethod
1933
def logger_parser(
2034
cls,

choreographer/browsers/chromium.py

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,6 @@ def _is_exe(path: str | Path) -> bool:
4242
return False
4343

4444

45-
def _find_a_chromium_based_browser(
46-
*,
47-
skip_local: bool,
48-
skip_typical: bool = False,
49-
) -> str | None:
50-
for name, browser_data in chromium_based_browsers.items():
51-
_logger.debug(f"Looking for a {name} browser.")
52-
path = get_browser_path(
53-
executable_names=browser_data.exe_names,
54-
skip_local=skip_local,
55-
ms_prog_id=browser_data.ms_prog_id,
56-
)
57-
if not path and not skip_typical:
58-
for candidate in browser_data.typical_paths:
59-
if _is_exe(candidate):
60-
path = candidate
61-
break
62-
if path:
63-
return path
64-
return None
65-
66-
6745
_logs_parser_regex = re.compile(r"\d*:\d*:\d*\/\d*\.\d*:")
6846

6947

@@ -91,6 +69,30 @@ class Chromium:
9169
tmp_dir: TmpDirectory
9270
"""A reference to a temporary directory object the chromium needs to store data."""
9371

72+
@classmethod
73+
def find_browser(
74+
cls,
75+
*,
76+
skip_local: bool,
77+
skip_typical: bool = False,
78+
) -> str | None:
79+
"""Find a chromium based browser."""
80+
for name, browser_data in chromium_based_browsers.items():
81+
_logger.debug(f"Looking for a {name} browser.")
82+
path = get_browser_path(
83+
executable_names=browser_data.exe_names,
84+
skip_local=skip_local,
85+
ms_prog_id=browser_data.ms_prog_id,
86+
)
87+
if not path and not skip_typical:
88+
for candidate in browser_data.typical_paths:
89+
if _is_exe(candidate):
90+
path = candidate
91+
break
92+
if path:
93+
return path
94+
return None
95+
9496
@classmethod
9597
def logger_parser(
9698
cls,
@@ -197,11 +199,12 @@ def __init__(
197199
)
198200

199201
if not self.path:
200-
self.path = _find_a_chromium_based_browser(skip_local=self.skip_local)
202+
self.path = Chromium.find_browser(skip_local=self.skip_local)
201203
if not self.path:
202204
raise ChromeNotFoundError(
203-
"Browser not found. You can use get_chrome(), "
204-
"please see documentation.",
205+
"Browser not found. You can use get_chrome() or "
206+
"choreo_get_chrome from bash. please see documentation. "
207+
f"Local copy ignored: {self.skip_local}.",
205208
)
206209
_logger.info(f"Found chromium path: {self.path}")
207210

choreographer/cli/_cli_utils_no_qa.py

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@
2828

2929

3030
def diagnose() -> None:
31-
logistro.getLogger().setLevel(6)
32-
logistro.getLogger().error("Test")
31+
logistro.betterConfig(level=1)
3332
from choreographer import Browser, BrowserSync
34-
from choreographer.browsers.chromium import _find_a_chromium_based_browser
33+
from choreographer.browsers.chromium import Chromium
3534
from choreographer.utils._which import browser_which
3635

3736
parser = argparse.ArgumentParser(
@@ -52,42 +51,52 @@ def diagnose() -> None:
5251
print(platform.release())
5352
print(platform.version())
5453
print(platform.uname())
54+
print("*".center(50, "*"))
5555
print("BROWSER:".center(50, "*"))
5656
try:
57-
print("Found local: {browser_which(verify_local=True)}")
57+
print(f"Found local: {browser_which([], verify_local=True)}")
5858
except RuntimeError:
5959
print("Didn't find local.")
60-
browser_path = _find_a_chromium_based_browser(skip_local=True)
60+
browser_path = Chromium.find_browser(skip_local=True)
6161
print(browser_path)
62+
print("*".center(50, "*"))
6263
print("BROWSER_INIT_CHECK (DEPS)".center(50, "*"))
6364
if not browser_path:
6465
print("No browser, found can't check for deps.")
6566
else:
6667
b = Browser()
6768
b._browser_impl.pre_open()
6869
cli = b._browser_impl.get_cli()
69-
env = b._browser_impl.get_env()
70+
env = b._browser_impl.get_env() # noqa: F841
71+
args = b._browser_impl.get_popen_args()
7072
b._browser_impl.clean()
7173
del b
72-
print("cli:")
74+
print("*** cli:")
7375
for arg in cli:
74-
print(arg)
75-
print("env:")
76-
for k, v in env.items():
77-
print(f"{k}:{v}")
76+
print(" " * 8 + str(arg))
77+
78+
# potential security issue
79+
# print("*** env:")
80+
# for k, v in env.items():
81+
# print(" " * 8 + f"{k}:{v}")
82+
83+
print("*** Popen args:")
84+
for k, v in args.items():
85+
print(" " * 8 + f"{k}:{v}")
86+
print("*".center(50, "*"))
7887
print("VERSION INFO:".center(50, "*"))
7988
try:
80-
print("PIP:".center(25, "*"))
89+
print("pip:".center(25, "*"))
8190
print(subprocess.check_output([sys.executable, "-m", "pip", "freeze"]).decode())
8291
except Exception as e:
8392
print(f"Error w/ pip: {e}")
8493
try:
85-
print("UV:".center(25, "*"))
94+
print("uv:".center(25, "*"))
8695
print(subprocess.check_output(["uv", "pip", "freeze"]).decode())
8796
except Exception as e:
8897
print(f"Error w/ uv: {e}")
8998
try:
90-
print("GIT:".center(25, "*"))
99+
print("git:".center(25, "*"))
91100
print(
92101
subprocess.check_output(
93102
["git", "describe", "--tags", "--long", "--always"],
@@ -99,18 +108,10 @@ def diagnose() -> None:
99108
print(sys.version)
100109
print(sys.version_info)
101110
print("Done with version info.".center(50, "*"))
111+
102112
if run:
103-
try:
104-
print("Skipping sync test...")
105-
# print("Sync Test Headless".center(50, "*"))
106-
# browser = BrowserSync(headless=headless)
107-
# browser.open()
108-
# time.sleep(3)
109-
# browser.close()
110-
except Exception as e:
111-
fail.append(("Sync test headless", e))
112-
finally:
113-
print("Done with sync test headless".center(50, "*"))
113+
print("*".center(50, "*"))
114+
print("Actual Run Tests".center(50, "*"))
114115

115116
async def test_headless() -> None:
116117
browser = await Browser(headless=headless)
@@ -141,5 +142,7 @@ async def test_headless() -> None:
141142
except Exception:
142143
print("Couldn't print traceback for:")
143144
print(str(exception))
144-
raise Exception("There was an exception, see above.")
145+
raise Exception(
146+
"There was an exception during full async run, see above.",
147+
)
145148
print("Thank you! Please share these results with us!")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ maintainers = [
2626
{name = "Andrew Pikul", email = "ajpikul@gmail.com"},
2727
]
2828
dependencies = [
29-
"logistro>=2.0.0",
29+
"logistro>=2.0.1",
3030
"simplejson>=3.19.3",
3131
]
3232

tests/test_browser_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55

66
import pytest
7-
from choreographer.browsers.chromium import _find_a_chromium_based_browser
7+
from choreographer.browsers import chromium
88

99

1010
def test_internal(tmp_path):
@@ -23,7 +23,7 @@ def test_internal(tmp_path):
2323
paths.append(p)
2424

2525
for _p, _n in zip(paths, names):
26-
_r = _find_a_chromium_based_browser(skip_local=True, skip_typical=True)
26+
_r = chromium.Chromium.find_browser(skip_local=True, skip_typical=True)
2727
assert _r
2828
assert Path(_r).stem == _n
2929
_p.unlink()

0 commit comments

Comments
 (0)