machine: add webcamd to the list of allowed services
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
bb3eb27b3d
commit
6c994f6c9c
|
@ -6,6 +6,8 @@
|
||||||
import logging
|
import logging
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
|
|
||||||
|
ALLOWED_SERVICES = ["moonraker", "klipper", "webcamd"]
|
||||||
|
|
||||||
class Machine:
|
class Machine:
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.server = config.get_server()
|
self.server = config.get_server()
|
||||||
|
@ -43,11 +45,11 @@ class Machine:
|
||||||
await self._execute_cmd(f'sudo systemctl restart {service_name}')
|
await self._execute_cmd(f'sudo systemctl restart {service_name}')
|
||||||
|
|
||||||
async def _handle_service_restart(self, web_request):
|
async def _handle_service_restart(self, web_request):
|
||||||
name = web_request.get('service')
|
name = web_request.get('service').lower()
|
||||||
if name == "klipper":
|
if name == "moonraker":
|
||||||
await self.restart_service(name)
|
|
||||||
elif name == "moonraker":
|
|
||||||
IOLoop.current().spawn_callback(self.restart_service, name)
|
IOLoop.current().spawn_callback(self.restart_service, name)
|
||||||
|
elif name in ALLOWED_SERVICES:
|
||||||
|
await self.restart_service(name)
|
||||||
else:
|
else:
|
||||||
raise self.server.error(
|
raise self.server.error(
|
||||||
f"Invalid argument recevied for 'name': {name}")
|
f"Invalid argument recevied for 'name': {name}")
|
||||||
|
|
Loading…
Reference in New Issue