Rename to yasi, add icon
This commit is contained in:
61
src/yasi-daemon
Executable file
61
src/yasi-daemon
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Welcome to YaSID - The The Yasi System Installer Daemon!
|
||||
"""
|
||||
|
||||
from flask import Flask, request, session, redirect, \
|
||||
url_for, render_template, flash, Blueprint
|
||||
from waitress import serve
|
||||
import logging
|
||||
import dmm.lsblk as lsblk
|
||||
import importlib
|
||||
import yaml
|
||||
import sys
|
||||
|
||||
# configuration
|
||||
CONFIGFILE="/etc/yasi/yasi.yaml"
|
||||
|
||||
# import config
|
||||
global config
|
||||
config_contents = open(CONFIGFILE, "r")
|
||||
config = yaml.safe_load(config_contents)
|
||||
APPS = config['settings']['apps']
|
||||
DEV_MODE = config['settings']['devmode']
|
||||
|
||||
# create our application in flask
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(__name__)
|
||||
app.config['CONFIG'] = config
|
||||
app.app_context().push()
|
||||
config['settings']['menu'] = {}
|
||||
sys.path.append('/usr/share/yasi-daemon')
|
||||
|
||||
if DEV_MODE:
|
||||
print("Note: Starting in devmode!")
|
||||
DEBUG = True
|
||||
tracebacks = True
|
||||
|
||||
# Register blueprints here
|
||||
for APP in APPS.split(" "):
|
||||
print(f"Loading applet: {APP} ")
|
||||
# Dynamically import the blueprint module
|
||||
module = importlib.import_module(f"yasi_applets.{APP}")
|
||||
# Get the blueprint (bp) from the imported module
|
||||
bp = getattr(module, "bp")
|
||||
# Register the blueprint with the app
|
||||
app.register_blueprint(bp)
|
||||
|
||||
# configure logs
|
||||
# logging.basicConfig()
|
||||
logger = logging.getLogger('waitress')
|
||||
if DEV_MODE == "1":
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger.debug("logger set to DEBUG")
|
||||
|
||||
if __name__ == '__main__':
|
||||
serve(app,
|
||||
host='0.0.0.0',
|
||||
port=8080,
|
||||
url_scheme='http',
|
||||
expose_tracebacks=DEV_MODE)
|
||||
|
||||
Reference in New Issue
Block a user