Added basic thing description to root
This commit is contained in:
parent
d52453849c
commit
f2af359b8b
24 changed files with 677 additions and 183 deletions
46
openflexure_microscope/api/v2/views/actions/system.py
Normal file
46
openflexure_microscope/api/v2/views/actions/system.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
from openflexure_microscope.common.labthings.resource import Resource
|
||||
import subprocess
|
||||
import os
|
||||
from sys import platform
|
||||
|
||||
|
||||
def is_raspberrypi(raise_on_errors=False):
|
||||
"""
|
||||
Checks if Raspberry Pi.
|
||||
"""
|
||||
# I mean, if it works, it works...
|
||||
return os.path.exists("/usr/bin/raspi-config")
|
||||
|
||||
|
||||
class ShutdownAPI(Resource):
|
||||
"""
|
||||
Attempt to shutdown the device
|
||||
"""
|
||||
|
||||
def post(self):
|
||||
"""
|
||||
Attempt to shutdown the device
|
||||
|
||||
.. :quickref: Actions; Shutdown
|
||||
|
||||
"""
|
||||
subprocess.Popen(["sudo", "shutdown", "-h", "now"])
|
||||
|
||||
return "{}", 201
|
||||
|
||||
|
||||
class RebootAPI(Resource):
|
||||
"""
|
||||
Attempt to reboot the device
|
||||
"""
|
||||
|
||||
def post(self):
|
||||
"""
|
||||
Attempt to shutdown the device
|
||||
|
||||
.. :quickref: Actions; Shutdown
|
||||
|
||||
"""
|
||||
subprocess.Popen(["sudo", "shutdown", "-r", "now"])
|
||||
|
||||
return "{}", 201
|
||||
Loading…
Add table
Add a link
Reference in a new issue