Modul fusion_hat._utils
- fusion_hat._utils.retry(times: int = 5)[Quellcode]
Retry-Dekorator, der bei Auftreten eines Fehlers die angegebene Anzahl von Wiederholungen ausführt
- Parameter:
times (int, optional) – Anzahl der Wiederholungen. Standard ist 5.
- Rückgabe:
Wrapper-Funktion
- Rückgabetyp:
function
- fusion_hat._utils.command_exists(cmd: str) bool[Quellcode]
Prüft, ob ein Befehl existiert
- Parameter:
cmd (str) – Zu prüfender Befehl
- Rückgabe:
True, wenn er existiert
- Rückgabetyp:
bool
- fusion_hat._utils.run_command(cmd: str, timeout: float | None = None) tuple[Quellcode]
Führt einen Befehl aus und gibt Status und Ausgabe zurück
- Parameter:
cmd (str) – Auszuführender Befehl
timeout (float | None) – timeout in seconds, None for no timeout
- Rückgabe:
status, output. On timeout, returns (124, „timed out after Ns“)
- Rückgabetyp:
tuple
- fusion_hat._utils.is_installed(cmd: str) bool[Quellcode]
Prüft, ob ein Befehl installiert ist
- Parameter:
cmd (str) – Zu prüfender Befehl
- Rückgabe:
True, wenn installiert
- Rückgabetyp:
bool
- fusion_hat._utils.mapping(x: float, in_min: float, in_max: float, out_min: float, out_max: float) float[Quellcode]
Ordnet einen Wert von einem Bereich einem anderen Bereich zu
- Parameter:
x (float) – Zu zuordnender Wert
in_min (float) – Eingangs-Minimum
in_max (float) – Eingangs-Maximum
out_min (float) – Ausgangs-Minimum
out_max (float) – Ausgangs-Maximum
- Rückgabe:
Zugeordneter Wert
- Rückgabetyp:
float
- fusion_hat._utils.get_ip(ifaces: list = ['wlan0', 'eth0']) str[Quellcode]
IP-Adresse abrufen
- Parameter:
ifaces (list, optional) – Zu prüfende Schnittstellen, Standard ist [‚wlan0‘, ‚eth0‘]
- Rückgabe:
IP-Adresse oder False, wenn nicht gefunden
- Rückgabetyp:
str/False
- fusion_hat._utils.get_username() str[Quellcode]
Benutzernamen abrufen
- Rückgabe:
Benutzername
- Rückgabetyp:
str
- fusion_hat._utils.constrain(value: float, min_value: float, max_value: float) float[Quellcode]
Begrenzt einen Wert auf einen Bereich
- Parameter:
value (float) – Zu begrenzender Wert
min_value (float) – Minimalwert
max_value (float) – Maximalwert
- Rückgabe:
Begrenzter Wert
- Rückgabetyp:
float