openflexure-microscope-server/openflexure_microscope/api/v2/blueprints/actions/system.py
2019-11-15 16:40:25 +00:00

33 lines
649 B
Python

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