diff options
author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2022-09-23 00:23:47 -0400 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2022-10-07 10:11:12 -0400 |
commit | 133901a396cf81aa1dcb35586e77a5a78475c4c7 (patch) | |
tree | 041c688fabadecc49d2927b231910d2811a05e43 /gnu/build/marionette.scm | |
parent | f24e0fc233950f9ac5ab6b4ac5653a278cae0383 (diff) | |
download | guix-133901a396cf81aa1dcb35586e77a5a78475c4c7.tar.gz |
marionette: Add a callback arguments to wait-for-screen-text.
* gnu/build/marionette.scm (wait-for-screen-text): New 'pre-action' and 'post-action' arguments. Update doc. Call the procedures before and after the OCR occurs, respectively.
Diffstat (limited to 'gnu/build/marionette.scm')
-rw-r--r-- | gnu/build/marionette.scm | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/gnu/build/marionette.scm b/gnu/build/marionette.scm index 6f373f87b6..f4b219e842 100644 --- a/gnu/build/marionette.scm +++ b/gnu/build/marionette.scm @@ -331,11 +331,15 @@ if it is not needed." (define* (wait-for-screen-text marionette predicate #:key (ocr "ocrad") - (timeout 30)) + (timeout 30) + pre-action + post-action) "Wait for TIMEOUT seconds or until the screen text on MARIONETTE matches PREDICATE, whichever comes first. Raise an error when TIMEOUT is exceeded. The error contains the recognized text along the preserved file name of the -screen dump, which is relative to the current working directory." +screen dump, which is relative to the current working directory. If +PRE-ACTION is provided, it should be a thunk to call before each OCR attempt. +Likewise for POST-ACTION, except it runs at the end of a successful OCR." (define start (car (gettimeofday))) @@ -353,7 +357,9 @@ screen dump, which is relative to the current working directory." (error "'wait-for-screen-text' timeout" 'ocr-text: last-text 'screendump: screendump-backup)) - (let* ((text screendump (marionette-screen-text marionette #:ocr ocr)) + (let* ((_ (and (procedure? pre-action) (pre-action))) + (text screendump (marionette-screen-text marionette #:ocr ocr)) + (_ (and (procedure? post-action) (post-action))) (result (predicate text))) (cond (result (delete-file screendump) |