craftbeerpi4-pione/cbpi/controller/system_controller.py
avollkopf d5ed315034 integrated system_controller into http_system endpoint
moved restart and shutdown procedure to system_controller
-> works currently only under linux with systemctl
2021-08-12 18:09:15 +02:00

29 lines
562 B
Python

import logging
import os
import aiohttp
class SystemController:
def __init__(self, cbpi):
self.cbpi = cbpi
self.service = cbpi.actor
self.logger = logging.getLogger(__name__)
self.cbpi.app.on_startup.append(self.check_for_update)
async def check_for_update(self, app):
pass
async def restart(self):
logging.info("RESTART")
os.system('systemctl reboot')
pass
async def shutdown(self):
logging.info("SHUTDOWN")
os.system('systemctl poweroff')
pass