From c0e5185fa6b079c02c0758599e087bb6f5c4d6d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Nar=C4=99bski?= Date: Wed, 10 Sep 2025 10:20:53 +0200 Subject: [PATCH] AvailabilityChecker: Remove hard requirement on tobii_research Now tobii_research [1][2] module does not need to be installed to be able to use mouse emulation. [1]: https://developer.tobiipro.com/python.html [2]: https://pypi.org/project/tobii-research/ This change removes 'import tobii_research as tr' from checkPythonEnvironment() method, and adjusts checkEyeTracker() and getEyeTrackerName() to work correctly even if tobii_research is not installed. Not tested yet. The problem with requiring tobii_research is that it requires specific Python version to be able to be installed: 3.8 or 3.10 [3][4][5] [3]: https://www.tobii.com/products/software/applications-and-developer-kits/tobii-pro-sdk [4]: https://developer.tobiipro.com/tobiiprosdk/platform-and-language.html [5]: https://codegrits.github.io/CodeGRITS/usage-guide/#python-environment --- src/main/java/utils/AvailabilityChecker.java | 29 ++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/main/java/utils/AvailabilityChecker.java b/src/main/java/utils/AvailabilityChecker.java index a47f51f..72af8a7 100644 --- a/src/main/java/utils/AvailabilityChecker.java +++ b/src/main/java/utils/AvailabilityChecker.java @@ -19,7 +19,6 @@ public class AvailabilityChecker { */ public static boolean checkPythonEnvironment(String pythonInterpreter) throws IOException, InterruptedException { String pythonScript = """ - import tobii_research as tr from screeninfo import get_monitors import pyautogui import time @@ -41,13 +40,17 @@ public static boolean checkPythonEnvironment(String pythonInterpreter) throws IO */ public static boolean checkEyeTracker(String pythonInterpreter) throws IOException, InterruptedException { String pythonScript = """ - import tobii_research as tr + try: + import tobii_research as tr - found_eyetrackers = tr.find_all_eyetrackers() - if found_eyetrackers == (): + found_eyetrackers = tr.find_all_eyetrackers() + if found_eyetrackers == (): + print('Not Found') + else: + print('Found') + + except ImportError: print('Not Found') - else: - print('Found') """; String line = runPythonScript(pythonInterpreter, pythonScript); @@ -62,13 +65,17 @@ public static boolean checkEyeTracker(String pythonInterpreter) throws IOExcepti */ public static String getEyeTrackerName(String pythonInterpreter) throws IOException, InterruptedException { String pythonScript = """ - import tobii_research as tr + try: + import tobii_research as tr - found_eyetrackers = tr.find_all_eyetrackers() - if found_eyetrackers == (): + found_eyetrackers = tr.find_all_eyetrackers() + if found_eyetrackers == (): + print('Not Found') + else: + print(found_eyetrackers[0].device_name) + + except ImportError: print('Not Found') - else: - print(found_eyetrackers[0].device_name) """; return runPythonScript(pythonInterpreter, pythonScript);