aboutsummaryrefslogtreecommitdiff
path: root/tests/acceptance/tesseract_utils.py
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>2020-10-21 12:33:25 +0200
committerPhilippe Mathieu-Daudé <philmd@redhat.com>2021-02-08 12:37:33 +0100
commit162127f29f2a5a628ecea79d4718d3a51b1bffac (patch)
treea1f41dc44919052cd95b536b3d49ee297c641f58 /tests/acceptance/tesseract_utils.py
parent5b19cb63d9dfda41b412373b8c9fe14641bcab60 (diff)
downloadqemu-162127f29f2a5a628ecea79d4718d3a51b1bffac.zip
qemu-162127f29f2a5a628ecea79d4718d3a51b1bffac.tar.gz
qemu-162127f29f2a5a628ecea79d4718d3a51b1bffac.tar.bz2
tests/acceptance: Extract tesseract_available() helper in new namespace
We are going to reuse tesseract_available(). Extract it to a new 'tesseract_utils' namespace. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20201021105035.2477784-4-f4bug@amsat.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'tests/acceptance/tesseract_utils.py')
-rw-r--r--tests/acceptance/tesseract_utils.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/acceptance/tesseract_utils.py b/tests/acceptance/tesseract_utils.py
new file mode 100644
index 0000000..acd6e8c
--- /dev/null
+++ b/tests/acceptance/tesseract_utils.py
@@ -0,0 +1,28 @@
+# ...
+#
+# Copyright (c) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later. See the COPYING file in the top-level directory.
+
+import re
+
+from avocado.utils.path import find_command, CmdNotFoundError
+
+def tesseract_available(expected_version):
+ try:
+ find_command('tesseract')
+ except CmdNotFoundError:
+ return False
+ res = process.run('tesseract --version')
+ try:
+ version = res.stdout_text.split()[1]
+ except IndexError:
+ version = res.stderr_text.split()[1]
+ return int(version.split('.')[0]) == expected_version
+
+ match = re.match(r'tesseract\s(\d)', res)
+ if match is None:
+ return False
+ # now this is guaranteed to be a digit
+ return int(match.groups()[0]) == expected_version