machine: add webcamd to the list of allowed services

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-02-27 20:05:22 -05:00
parent bb3eb27b3d
commit 6c994f6c9c
1 changed files with 6 additions and 4 deletions

View File

@ -6,6 +6,8 @@
import logging
from tornado.ioloop import IOLoop
ALLOWED_SERVICES = ["moonraker", "klipper", "webcamd"]
class Machine:
def __init__(self, config):
self.server = config.get_server()
@ -43,11 +45,11 @@ class Machine:
await self._execute_cmd(f'sudo systemctl restart {service_name}')
async def _handle_service_restart(self, web_request):
name = web_request.get('service')
if name == "klipper":
await self.restart_service(name)
elif name == "moonraker":
name = web_request.get('service').lower()
if name == "moonraker":
IOLoop.current().spawn_callback(self.restart_service, name)
elif name in ALLOWED_SERVICES:
await self.restart_service(name)
else:
raise self.server.error(
f"Invalid argument recevied for 'name': {name}")