From 39866626dccb5366969c549d9c24aab7f3d62ed6 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Fri, 10 Jan 2020 20:02:36 +0000 Subject: [PATCH] Use LabThings decorators --- .../api/v2/views/actions/system.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/openflexure_microscope/api/v2/views/actions/system.py b/openflexure_microscope/api/v2/views/actions/system.py index b148de7d..82b67b92 100644 --- a/openflexure_microscope/api/v2/views/actions/system.py +++ b/openflexure_microscope/api/v2/views/actions/system.py @@ -3,6 +3,11 @@ import subprocess import os from sys import platform +from openflexure_microscope.common.flask_labthings.decorators import ( + ThingAction, + doc_response, +) + def is_raspberrypi(raise_on_errors=False): """ @@ -12,34 +17,32 @@ def is_raspberrypi(raise_on_errors=False): return os.path.exists("/usr/bin/raspi-config") +@ThingAction class ShutdownAPI(Resource): """ Attempt to shutdown the device """ + @doc_response(201) def post(self): """ Attempt to shutdown the device - - .. :quickref: Actions; Shutdown - """ subprocess.Popen(["sudo", "shutdown", "-h", "now"]) return "{}", 201 +@ThingAction class RebootAPI(Resource): """ Attempt to reboot the device """ + @doc_response(201) def post(self): """ - Attempt to shutdown the device - - .. :quickref: Actions; Shutdown - + Attempt to reboot the device """ subprocess.Popen(["sudo", "shutdown", "-r", "now"])