# Python wrapper of realtime script # Copyright 2026 Hannes Diethelm # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import subprocess REALTIME="@REALTIME@" def verify_info() -> tuple[bool, str]: #Checks if system is realtime compatible cmd = [REALTIME, "verify"] ret = subprocess.run(cmd, stdin=subprocess.DEVNULL, capture_output=True, text=True) if ret.returncode != 0 and ret.returncode != 1: raise RuntimeError("cmd \"" + " ".join(cmd) + "\" failed with status " + str(ret.returncode)) return ret.returncode==0, ret.stdout.rstrip(); def verify() -> bool: ret, _ = verify_info(); return ret; def status() -> bool: #Status: realtime core running (rtapi_app running or kernel modules active) #Note: rtapi_app running does not mean realtime compatibility! cmd = [REALTIME, "status"] ret = subprocess.run(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL) if ret.returncode != 0 and ret.returncode != 1: raise RuntimeError("cmd \"" + " ".join(cmd) + "\" failed with status " + str(ret.returncode)) return ret.returncode==0;