31 lines
846 B
Python
31 lines
846 B
Python
from flask import Flask
|
|
from flask import render_template
|
|
|
|
import os
|
|
import logging
|
|
import subprocess
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
SERVICES = ["snapclient", "micro_assist", "mopidy", "rhasspy", "snapclient", "snapserver", "wake_assist", "vosk_assist"]
|
|
|
|
@app.route("/")
|
|
def services():
|
|
services_status = {}
|
|
for service_name in SERVICES:
|
|
services_status[service_name] = get_status(service_name)
|
|
|
|
print(services_status)
|
|
|
|
return render_template('index.html', services_status=services_status)
|
|
|
|
|
|
def get_status(service_name):
|
|
command = "/usr/bin/systemctl --user is-active {service_name}".format(service_name=service_name)
|
|
|
|
logging.info('Running %s', command)
|
|
status = subprocess.run(["systemctl","--user","is-active", service_name], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
|
|
|
|
return status
|