From patchwork Fri Sep 23 05:00:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 42862 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8B53127BBEA; Fri, 23 Sep 2022 06:04:43 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 551EE27BBE9 for ; Fri, 23 Sep 2022 06:04:43 +0100 (BST) Received: from localhost ([::1]:45952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obari-0004E0-Fb for patchwork@mira.cbaines.net; Fri, 23 Sep 2022 01:04:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obapC-0003W2-J3 for guix-patches@gnu.org; Fri, 23 Sep 2022 01:02:09 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39963) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1obapC-00027v-Bd for guix-patches@gnu.org; Fri, 23 Sep 2022 01:02:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1obapC-00055a-6U for guix-patches@gnu.org; Fri, 23 Sep 2022 01:02:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58014] [PATCH 11/15] marionette: Add a callback arguments to wait-for-screen-text. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 23 Sep 2022 05:02:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58014 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58014@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58014-submit@debbugs.gnu.org id=B58014.166390930819441 (code B ref 58014); Fri, 23 Sep 2022 05:02:06 +0000 Received: (at 58014) by debbugs.gnu.org; 23 Sep 2022 05:01:48 +0000 Received: from localhost ([127.0.0.1]:39025 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obaou-00053V-Cu for submit@debbugs.gnu.org; Fri, 23 Sep 2022 01:01:48 -0400 Received: from mail-qv1-f48.google.com ([209.85.219.48]:45859) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obaos-00051T-L7 for 58014@debbugs.gnu.org; Fri, 23 Sep 2022 01:01:46 -0400 Received: by mail-qv1-f48.google.com with SMTP id mi14so8253264qvb.12 for <58014@debbugs.gnu.org>; Thu, 22 Sep 2022 22:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Au9ibFtg5LHvs398x3Sz0OKX1319Qsp45Mew591e/zY=; b=Q3UTHMAtyKZvJ1zK/LxJVdKS0UXQwCkNYbZNBHZ67z2xEunMfqUi7YnFxi8wEpXNWN ktndJcmj+qAT5NgPatWoi0pwxH7s9qf0y6xostoyLYidl98MVoWCCRMvttlUp20gLys1 Szrd4w71PTXNBjKtgSmPJBSVnHTKuXQAsdf13aEdTZs3b4U4ISayqXxN2zN5C1eDIFJs 5Z2WNs04dI2L0TvKHL4wadZPcuxM8Y1tqc1neKIYwZGw6xCy1gA7IedzywpOp2gIqQ5Y c6YbhmqeCb9/bb+VcdFrcEbTz26O2K07JgrRBhtlGLnE8PIBJ4R0YhIOdHDJZrjoPKcF h4bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Au9ibFtg5LHvs398x3Sz0OKX1319Qsp45Mew591e/zY=; b=Pcg+20wMR62czOImlTEA3C+rYVw6t7tiZ5s45D/oBt40xccanCsNLnjdjGrVca4nzV Z0Qx0Je303VlhZV87IuGt5ZYQvWU21ZnVIDvRzULWehkOW5MYKpy0R+44Lom2dz6smG1 /KT86VyjQhdyZyRW/Obxw39/yCbd2FVh5SEp3X8WReOQfBiE+LtlNqWW64IBPA0clXmq X0gTRTVPC6ELETE4Ovpo6DP0E4btWSC+jiRatWVuvI6c5G67uxfOfVS+FvnC5IF39eNw REBLKGhaPYtsjiSTygqB+gLZGQTp38XfmuA0nWuWaFjtR2Ck8Oqsm3/kokanqCuAZrRa V3MQ== X-Gm-Message-State: ACrzQf2Y7yb2l9i8Ga+joqxCI2Wvy2hQFP7TBBRItQPOa8xtOkQc6f6J WTouphG7bVeajWqpvwfsuwAGDpeP2WI= X-Google-Smtp-Source: AMsMyM7krg5N2kUZTWXn3lu/iWEx7E7mUPJ6/ofTO1AjcfV+inovwWBfHGSpXInm6VuJBw9XbbL8vw== X-Received: by 2002:a05:6214:c2a:b0:4ac:c5b7:e5cc with SMTP id a10-20020a0562140c2a00b004acc5b7e5ccmr5544530qvd.55.1663909306198; Thu, 22 Sep 2022 22:01:46 -0700 (PDT) Received: from localhost.localdomain ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id de4-20020a05620a370400b006bbb07ebd83sm5263534qkb.108.2022.09.22.22.01.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 22:01:45 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 23 Sep 2022 01:00:38 -0400 Message-Id: <20220923050042.29893-11-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220923050042.29893-1-maxim.cournoyer@gmail.com> References: <20220923050042.29893-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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. --- gnu/build/marionette.scm | 12 +++++++++--- 1 file 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 @@ (define image (string-append (tmpnam) ".ppm")) (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 @@ (define end (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)