Drafted actions routes
This commit is contained in:
parent
6581612312
commit
d79fd55301
8 changed files with 360 additions and 25 deletions
|
|
@ -0,0 +1,33 @@
|
|||
from openflexure_microscope.api.views import MicroscopeView
|
||||
|
||||
from flask import jsonify
|
||||
|
||||
import subprocess
|
||||
import logging
|
||||
|
||||
|
||||
# TODO: Make robust against different host OS
|
||||
class ShutdownAPI(MicroscopeView):
|
||||
def post(self):
|
||||
"""
|
||||
Attempt to shutdown the device
|
||||
|
||||
.. :quickref: Actions; Shutdown
|
||||
|
||||
"""
|
||||
subprocess.Popen(['shutdown', '-h', 'now'])
|
||||
|
||||
return '', 202
|
||||
|
||||
|
||||
class RebootAPI(MicroscopeView):
|
||||
def post(self):
|
||||
"""
|
||||
Attempt to shutdown the device
|
||||
|
||||
.. :quickref: Actions; Shutdown
|
||||
|
||||
"""
|
||||
subprocess.Popen(['sudo', 'shutdown', '-r', 'now'])
|
||||
|
||||
return '', 202
|
||||
Loading…
Add table
Add a link
Reference in a new issue