Ver Fonte

Remove manage module and update related configs

Librellium há 2 meses atrás
pai
commit
92b0da82d5
4 ficheiros alterados com 1 adições e 88 exclusões
  1. 1 1
      alembic.ini
  2. 0 4
      anonflow/database/migrations/env.py
  3. 0 2
      docker-compose.yml
  4. 0 81
      manage.py

+ 1 - 1
alembic.ini

@@ -84,7 +84,7 @@ path_separator = os
 # database URL.  This is consumed by the user-maintained env.py script only.
 # other means of configuring database URLs may be customized within the env.py
 # file.
-sqlalchemy.url = driver://user:pass@localhost/dbname
+# sqlalchemy.url = driver://user:pass@localhost/dbname
 
 
 [post_write_hooks]

+ 0 - 4
anonflow/database/migrations/env.py

@@ -1,12 +1,8 @@
-import sys
 from logging.config import fileConfig
-from pathlib import Path
 
 from alembic import context
 from sqlalchemy import engine_from_config, pool
 
-sys.path.append(str(Path(__file__).parent.parent.parent))
-
 from anonflow import paths
 from anonflow.database.base import Base
 

+ 0 - 2
docker-compose.yml

@@ -4,8 +4,6 @@ services:
     build:
       context: .
       dockerfile: Dockerfile
-    labels:
-      org.opencontainers.image.version: "${VERSION:?VERSION is not set. Use 'python manage.py deploy'}"
     volumes:
       - ./rules/:/app/rules/
       - ./config.yml:/app/config.yml

+ 0 - 81
manage.py

@@ -1,81 +0,0 @@
-import argparse
-import os
-import shutil
-import subprocess
-import sys
-
-from anonflow import __version_str__, paths
-
-def check_cmd(cmd: str):
-    return shutil.which(cmd) is not None
-
-def check_translations():
-    mo_files, po_files = set(), set()
-    for root, dirs, files in os.walk(paths.TRANSLATIONS_DIR):
-        for file in files:
-            if file.endswith(".mo"):
-                mo_files.add(file[:-3])
-            if file.endswith(".po"):
-                po_files.add(file[:-3])
-
-    return mo_files == po_files
-
-def compile_translations():
-    if not check_cmd("pybabel"):
-        raise RuntimeError("pybabel not found.")
-
-    subprocess.run(["pybabel", "compile", "-d", paths.TRANSLATIONS_DIR], check=True)
-    print("Translations compilation done.")
-
-def make_migrations():
-    if not check_cmd("alembic"):
-        raise RuntimeError("alembic not found.")
-
-    subprocess.run(["alembic", "revision", "--autogenerate"], check=True)
-
-def migrate(revision: str):
-    if not check_cmd("alembic"):
-        raise RuntimeError("alembic not found.")
-
-    subprocess.run(["alembic", "upgrade", revision], check=True)
-
-def main():
-    os.environ["VERSION"] = __version_str__
-
-    parser = argparse.ArgumentParser(description="Anonflow project manager")
-    subparsers = parser.add_subparsers(dest="command", required=True)
-
-    subparsers.add_parser("start", help="Run the application locally")
-
-    deploy_parser = subparsers.add_parser("deploy", help="Build and manage containers via docker compose")
-    deploy_parser.add_argument("docker_args", nargs=argparse.REMAINDER, help="Additional docker compose commands")
-
-    subparsers.add_parser("makemigrations", help="Generate new Alembic migration")
-    migrate_parser = subparsers.add_parser("migrate", help="Apply all Alembic migrations")
-    migrate_parser.add_argument("revision", nargs="?", default="head", help="Revision to upgrade to (default: head)")
-
-    args = parser.parse_args()
-
-    try:
-        if not check_translations():
-            compile_translations()
-
-        if args.command == "start":
-            print("Running 'python -m anonflow'")
-            subprocess.run([sys.executable, "-m", "anonflow"], check=True)
-        elif args.command == "deploy":
-            if not args.docker_args:
-                print("Running 'docker compose up --build'")
-                subprocess.run(["docker", "compose", "up", "--build"])
-            else:
-                print(f"Running 'docker compose {' '.join(args.docker_args)}'")
-                subprocess.run(["docker", "compose"] + args.docker_args)
-        elif args.command == "makemigrations":
-            make_migrations()
-        elif args.command == "migrate":
-            migrate(args.revision)
-    except KeyboardInterrupt:
-        pass
-
-if __name__ == "__main__":
-    main()