Repository navigation
Tesseract setup helpers, multi-click, drag pacing and Windows key names for Jeffrey_RPA - #491
Merged
Merged
Conversation
…ing pytesseract Jeffrey_RPA imported pytesseract itself to list languages and probe the engine, and wrote pytesseract's tesseract_cmd global directly, giving that global a second writer outside this package. find_tesseract_cmd, set_tessdata_dir, ocr_languages and ocr_status answer those questions here, with ocr_languages keeping "no language data" ([]) apart from "cannot ask" (None), and TesseractBackend.set_cmd stays the only writer. AC_ocr_status / AC_ocr_languages and the matching MCP tools and Script Builder entries expose the same checks to action files.
Jeffrey_RPA built a double-click from two click_mouse calls and its own sleep. click_mouse(clicks=, interval=) resolves the point once, clicks it clicks times with interval seconds between, and refuses a bool, float or non-finite value before any click. The defaults are the old single click and record the same action as before. AC_click_mouse, the ac_click_mouse MCP tool, the MCP fake backend and the Script Builder take both parameters. macOS apps read a click count the osx backend never sets, so there the clicks stay separate single clicks; that is documented and recorded in Progress.md.
…d drag_path The two drags carried identical copies of the same loop. Both now call tween_drag._drag_through; behaviour is unchanged, which the existing drag tests confirm, so the pacing and release changes that follow touch one place.
Apps that judge a drag by the pointer's motion read the library's drags, which moved as fast as events could be sent, as clicks, so Jeffrey_RPA kept its own loop. The shared drag sequence now takes step_delay_s (after each move) and settle_s (on the start before the press, after it and before the release); both default to 0 and leave the event sequence as it was. When a step raised, the button used to be released at the end of the path, completing a drop the drag never reached. The release now runs in a finally at the last point the pointer reached, and a failing cleanup release is logged rather than raised over the original error, the same pattern hotkey and type_keyboard use.
… interval keys The typing contract checks the whole package; the dict literal was inferred as holding only the keycode and coordinate types, so adding clicks and interval to it failed there on every target platform.
…ey aliases, and look keys up by canonical name Jeffrey_RPA kept its own alias table and a table of keys the library could not name (the OEM keys, browser_home, and launch_app2, which only existed upper-case), converting names to codes before every call. The Windows table now has those keys under the same names and codes, plus the aliases (ctrl, alt, enter, esc, win, pgup, numpad0, plus, ...), kept in one keyboard_key_aliases map that every platform publishes. keyboard_key_name(keycode) answers with the canonical name and never an alias, so adding an alias cannot change the key names a recorder writes; for every code the old table named it returns what a shortest-lower-case lookup returned before any alias existed.
Not up to standards ⛔
|
One condition per assert and bare fixture decorators in the new tests, a single exception-raising call inside pytest.raises, one extend for the two new Script Builder entries, PEP 604 unions on the changed signatures, and a justified NOSONAR where TesseractBackend.version() deliberately turns pytesseract's SystemExit into OCRBackendNotAvailableError.
|
Member
Author
|
Merged into |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Four groups of public API so Jeffrey_RPA can drop the desktop-automation code it hand-rolls in
JeffreyRPA/_gui_control.py. One commit per group, plus a refactor commit that comes before the drag change and a typing fix for the click change.1. Tesseract setup helpers (
utils/ocr/tesseract_setup.py, exported from the facade)find_tesseract_cmd() -> Optional[str]: looks in$TESSERACT_CMD, thenPATH, then the installers' default folders. It only looks.set_tessdata_dir(path) -> Optional[str]: resolves the path, requires a directory and setsTESSDATA_PREFIX.Noneclears it.ocr_languages() -> Optional[List[str]]: the sorted language codes.[]means the engine answered and has no language data;Nonemeans the engine could not be asked. It is never cached.ocr_status() -> OCRStatus(ok, reason):reasonis one ofready,missing_package,missing_engine,engine_unusableorno_language_data.TesseractBackend.cmd,version()andlanguages().version()catches theSystemExitthat pytesseract raises for a version string it cannot parse.pytesseract.pytesseract.tesseract_cmditself, soTesseractBackend.set_cmdstays the only writer.AC_ocr_status/AC_ocr_languages, as MCP tools and in the Script Builder.2. Multi-click
click_mouse(mouse_keycode, x=None, y=None, clicks=1, interval=0.0): every click lands on the same point,intervalseconds apart.clicks, or a NaN, infinite or negativeinterval.Progress.md.3. Drag pacing
tween_draganddrag_pathgainstep_delay_sandsettle_s, both 0 by default, which leaves the event sequence unchanged.finallyat the last point the pointer reached. It used to be released at the end of the path. A cleanup release that fails is logged instead of raised over the original error, the same patternhotkeyandtype_keyboarduse.4. Windows key table
browser_home, a lower-caselaunch_app2(LAUNCH_APP2stays) and the common aliases.keyboard_key_aliasesmap, which every platform publishes; it is empty off Windows.keyboard_key_name(keycode)returns the canonical name and never an alias. For every code the old table named, it returns the name a shortest-lower-case lookup gave before any alias existed. This is pinned for every code in the table.Checks run locally
utils/ci_annotations, which this branch does not touch; it fails the same way with the local mypy 2.1.Notes