Disable shutdown/reboot unless on Raspberry Pi
This commit is contained in:
parent
9fcef552cc
commit
02afe06655
2 changed files with 10 additions and 3 deletions
|
|
@ -3,7 +3,6 @@ Top-level representation of enabled actions
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from flask import Blueprint, url_for, jsonify
|
from flask import Blueprint, url_for, jsonify
|
||||||
from sys import platform
|
|
||||||
|
|
||||||
from openflexure_microscope.api.utilities import blueprint_for_module
|
from openflexure_microscope.api.utilities import blueprint_for_module
|
||||||
from openflexure_microscope.utilities import get_docstring, description_from_view
|
from openflexure_microscope.utilities import get_docstring, description_from_view
|
||||||
|
|
@ -41,12 +40,12 @@ _actions = {
|
||||||
"shutdown": {
|
"shutdown": {
|
||||||
"rule": "/system/shutdown/",
|
"rule": "/system/shutdown/",
|
||||||
"view_class": system.ShutdownAPI,
|
"view_class": system.ShutdownAPI,
|
||||||
"conditions": (platform == "linux"),
|
"conditions": system.is_raspberrypi(),
|
||||||
},
|
},
|
||||||
"reboot": {
|
"reboot": {
|
||||||
"rule": "/system/reboot/",
|
"rule": "/system/reboot/",
|
||||||
"view_class": system.RebootAPI,
|
"view_class": system.RebootAPI,
|
||||||
"conditions": (platform == "linux"),
|
"conditions": system.is_raspberrypi(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,16 @@
|
||||||
from openflexure_microscope.api.views import MicroscopeView
|
from openflexure_microscope.api.views import MicroscopeView
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import os
|
||||||
|
from sys import platform
|
||||||
|
|
||||||
|
|
||||||
|
def is_raspberrypi():
|
||||||
|
if (platform != "linux"):
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return (os.uname()[1] == 'raspberrypi')
|
||||||
|
|
||||||
class ShutdownAPI(MicroscopeView):
|
class ShutdownAPI(MicroscopeView):
|
||||||
"""
|
"""
|
||||||
Attempt to shutdown the device
|
Attempt to shutdown the device
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue