41 lines
747 B
Python
41 lines
747 B
Python
from openflexure_microscope.api.views import MicroscopeView
|
|
|
|
import subprocess
|
|
|
|
|
|
class ShutdownAPI(MicroscopeView):
|
|
"""
|
|
Attempt to shutdown the device
|
|
|
|
Allowed methods:
|
|
POST
|
|
"""
|
|
def post(self):
|
|
"""
|
|
Attempt to shutdown the device
|
|
|
|
.. :quickref: Actions; Shutdown
|
|
|
|
"""
|
|
subprocess.Popen(["shutdown", "-h", "now"])
|
|
|
|
return "{}", 201
|
|
|
|
|
|
class RebootAPI(MicroscopeView):
|
|
"""
|
|
Attempt to reboot the device
|
|
|
|
Allowed methods:
|
|
POST
|
|
"""
|
|
def post(self):
|
|
"""
|
|
Attempt to shutdown the device
|
|
|
|
.. :quickref: Actions; Shutdown
|
|
|
|
"""
|
|
subprocess.Popen(["sudo", "shutdown", "-r", "now"])
|
|
|
|
return "{}", 201
|