Commit 73dfc935 authored by shadMod's avatar shadMod 💬

added compile_download.CompileVersion() in init command to compile to compile downloads.toml

added debug option in init command to not write downloads.cache

added debug in uitwww.create_app() in run command
parent 898c0feb
# Source code of the Ubuntu-it website
# Copyright (C) 2015-2016 Pietro Albini <pietroalbini@ubuntu.com>
# Copyright (C) 2023 shadMod
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
......@@ -19,28 +20,31 @@ import os
import click
import uitwww
from scss.compiler import compile_file
from .constants import UITWWW_DIR, BASE_DIR
from .utils import ReverseProxied, GunicornInstance
from scss.compiler import compile_file
from .src.download.compile_download import CompileVersion
@click.group()
def cli():
""" Ubuntu-it website's command line utility """
"""Ubuntu-it website's command line utility"""
pass
@cli.command("run")
@click.argument("data")
@click.option("-g", "--gunicorn-config", default=None, help="Path to a"
"gunicorn config file")
@click.option(
"-g", "--gunicorn-config", default=None, help="Path to a gunicorn config file"
)
@click.option("-p", "--port", default=8000, help="Bind that port")
@click.option("--public", help="Make available to the public", is_flag=True)
@click.option("-w", "--workers", help="Number of workers to start", default=3)
@click.option("-d", "--debug", help="Enable debug mode", is_flag=True)
def run(data, gunicorn_config, port, public, workers, debug):
"""Run the application"""
app = uitwww.create_app(data)
app = uitwww.create_app(data, debug)
app.wsgi_app = ReverseProxied(app.wsgi_app)
host = "127.0.0.1"
......@@ -76,11 +80,19 @@ def run(data, gunicorn_config, port, public, workers, debug):
@cli.command("init")
@click.argument("data")
def init(data):
@click.option("-d", "--debug", help="Enable debug mode", is_flag=True)
def init(data, debug):
"""Initialize the data directory"""
print("Initializing data directory:", data)
data_path = os.path.expanduser(os.path.abspath(data))
uitwww.init_data_directory(data_path)
print("Initializing data directory:", data)
compiler = CompileVersion(
path_out=UITWWW_DIR + "/data/downloads.toml",
constants=UITWWW_DIR + "/src/download/assets/constants.json",
)
compiler.compile_download()
print("Compile download file")
uitwww.init_data_directory(data_path, debug)
print("Created data directory:", data)
@cli.command("build_scss")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment