And adjust for new as lt import

This commit is contained in:
Julian Stirling 2025-06-28 17:57:31 +01:00
parent 840ed7f20e
commit 52a80ef66b
17 changed files with 240 additions and 293 deletions

View file

@ -6,8 +6,7 @@ This module defines a Thing that can shut down or restart the host computer.
import subprocess
import os
from labthings_fastapi.thing import Thing
from labthings_fastapi.decorators import thing_action, thing_property
import labthings_fastapi as lt
from pydantic import BaseModel
@ -16,12 +15,12 @@ class CommandOutput(BaseModel):
error: str
class SystemControlThing(Thing):
class SystemControlThing(lt.Thing):
"""
Attempt to shutdown the device
"""
@thing_action
@lt.thing_action
def shutdown(self) -> CommandOutput:
"""
Attempt to shutdown the device
@ -35,14 +34,14 @@ class SystemControlThing(Thing):
out, err = p.communicate()
return CommandOutput(output=out, error=err)
@thing_property
@lt.thing_property
def is_raspberrypi() -> bool:
"""
Checks if we are running on a Raspberry Pi.
"""
return os.path.exists("/usr/bin/raspi-config")
@thing_action
@lt.thing_action
def reboot(self) -> CommandOutput:
"""Attempt to reboot the device"""
p = subprocess.Popen(