Bundle JS into a compact format

Run file checks on startup
Fix visual bugs in Sass
This commit is contained in:
Michał Gdula 2023-03-10 11:10:43 +00:00
parent e3a0eaf60b
commit e6d289ed64
16 changed files with 283 additions and 221 deletions

View file

@ -5,6 +5,7 @@ Runs when the app detects that there is no user directory
import os
import sys
import platformdirs
import logging
import yaml
USER_DIR = platformdirs.user_config_dir('onlylegs')
@ -18,6 +19,8 @@ class SetupApp:
Main setup function
"""
print("Running setup...")
self.requires_restart = False
if not os.path.exists(USER_DIR):
self.make_dir()
@ -25,6 +28,13 @@ class SetupApp:
self.make_env()
if not os.path.exists(os.path.join(USER_DIR, 'conf.yml')):
self.make_yaml()
self.logging_config()
if self.requires_restart:
print("WARNING: You need to restart and edit the config files before running the app again!")
print("You can find the config files at:", USER_DIR)
sys.exit()
def make_dir(self):
"""
@ -37,7 +47,7 @@ class SetupApp:
print("Created user directory at:", USER_DIR)
except Exception as err:
print("Error creating user directory:", err)
sys.exit(1) # exit with error code
sys.exit(1)
def make_env(self):
"""
@ -55,7 +65,7 @@ class SetupApp:
print("Error creating environment variables:", err)
sys.exit(1)
print("Generated default .env file. EDIT IT BEFORE RUNNING THE APP AGAIN!")
print("Generated default .env file, please edit!")
def make_yaml(self):
"""
@ -95,4 +105,19 @@ class SetupApp:
print("Error creating default gallery config:", err)
sys.exit(1)
print("Generated default YAML config. EDIT IT BEFORE RUNNING THE APP AGAIN!")
print("Generated default YAML config, please edit!")
def logging_config(self):
LOGS_PATH = os.path.join(platformdirs.user_config_dir('onlylegs'), 'logs')
if not os.path.isdir(LOGS_PATH):
os.mkdir(LOGS_PATH)
print("Created logs directory at:", LOGS_PATH)
logging.getLogger('werkzeug').disabled = True
logging.basicConfig(
filename=os.path.join(LOGS_PATH, 'only.log'),
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S',
format='%(asctime)s %(levelname)s %(name)s %(threadName)s : %(message)s',
encoding='utf-8')