corrigindo upload
This commit is contained in:
1 parent
d2a68fa744
commit
1c37cc4b80
13 files changed
+6848492
-979754
No files matched your search
Executable → Regular
BIN
Binary file not shown.
Binary file not shown.
@@ -12,6 +12,8 @@ import re
|
||||
import unicodedata
|
||||
import csv
|
||||
import psutil
|
||||
import glob
|
||||
import json
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# Importando seus módulos locais
|
||||
@@ -384,6 +386,38 @@ def process_single_file(args):
|
||||
|
||||
return result
|
||||
|
||||
def rebuild_all_yamls():
|
||||
"""Lê todos os JSONs individuais e reconstrói APENAS os arquivos necessários (JSON e YAML leve)."""
|
||||
logging.info("Reconstruindo all.json e all_leve.yml a partir dos projetos individuais...")
|
||||
all_data = []
|
||||
|
||||
# Busca todos os arquivos .json na pasta de metadados
|
||||
json_files = glob.glob(os.path.join(METADATA_FOLDER, "*.json"))
|
||||
|
||||
for j_file in json_files:
|
||||
filename = os.path.basename(j_file)
|
||||
if filename in ["all.json", "samples-manifest.json", "mmp-manifest.json", "dependency_report.json"]:
|
||||
continue
|
||||
|
||||
try:
|
||||
with open(j_file, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
all_data.append(data)
|
||||
except Exception as e:
|
||||
logging.error(f"Erro ao ler {j_file} para agregar: {e}")
|
||||
|
||||
if all_data:
|
||||
# 1. Salva o JSON completo (A biblioteca JSON é nativa e MUITO mais eficiente em RAM)
|
||||
save_to_json(all_data, os.path.join(METADATA_FOLDER, "all.json"))
|
||||
|
||||
# 2. Transforma o 'elefante' num 'camundongo' ANTES de passar pro YAML
|
||||
dados_leves = create_lightweight_dataset(all_data)
|
||||
|
||||
# 3. Salva APENAS a versão leve para o Jekyll (Isso não vai estourar a memória)
|
||||
save_to_yaml(dados_leves, os.path.join(DATA_FOLDER, "all_leve.yml"))
|
||||
|
||||
logging.info(f"Arquivos agregados (all.json / all_leve.yml) atualizados com {len(all_data)} projetos!")
|
||||
|
||||
|
||||
def main_parallel():
|
||||
logger, log_file_path = setup_logger()
|
||||
|
||||
@@ -28,7 +28,7 @@ from flask_login import (
|
||||
from flask_admin import Admin, AdminIndexView, expose
|
||||
from flask_admin.contrib.sqla import ModelView
|
||||
|
||||
from main import process_single_file, generate_manifests, slugify
|
||||
from main import process_single_file, generate_manifests, slugify, rebuild_all_yamls
|
||||
from utils import (
|
||||
ALLOWED_EXTENSIONS,
|
||||
ALLOWED_SAMPLE_EXTENSIONS,
|
||||
@@ -174,13 +174,16 @@ def allowed_sample(filename):
|
||||
and filename.rsplit(".", 1)[1].lower() in ALLOWED_SAMPLE_EXTENSIONS
|
||||
)
|
||||
|
||||
|
||||
def run_jekyll_build():
|
||||
RUBY_BIN_PATH = "/usr/bin/ruby3.2"
|
||||
BUNDLE_PATH = "/nethome/jotachina/projetos/mmpSearch/vendor/bundle/ruby/3.2.0/bin/bundle"
|
||||
|
||||
BUNDLE_PATH = (
|
||||
"/nethome/jotachina/projetos/mmpSearch/vendor/bundle/ruby/3.2.0/bin/bundle"
|
||||
)
|
||||
|
||||
env_vars = os.environ.copy()
|
||||
env_vars["PATH"] = f"{RUBY_BIN_PATH}:{env_vars.get('PATH', '')}"
|
||||
|
||||
|
||||
command = [
|
||||
BUNDLE_PATH,
|
||||
"exec",
|
||||
@@ -189,7 +192,7 @@ def run_jekyll_build():
|
||||
"--destination",
|
||||
"/var/www/html/trens/mmpSearch/",
|
||||
]
|
||||
|
||||
|
||||
logging.info("⏳ Aguardando liberação para iniciar build do Jekyll...")
|
||||
with JEKYLL_LOCK:
|
||||
logging.info("🔨 Iniciando build do Jekyll (Travando a fila)...")
|
||||
@@ -200,11 +203,13 @@ def run_jekyll_build():
|
||||
env=env_vars,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True
|
||||
check=True,
|
||||
)
|
||||
logging.info("✅ Jekyll Build concluído com sucesso!")
|
||||
except subprocess.CalledProcessError as e:
|
||||
logging.error(f"❌ ERRO FATAL no Jekyll Build (Code {e.returncode}):\n{e.stderr}")
|
||||
logging.error(
|
||||
f"❌ ERRO FATAL no Jekyll Build (Code {e.returncode}):\n{e.stderr}"
|
||||
)
|
||||
except Exception as e:
|
||||
logging.error(f"❌ Erro inesperado ao chamar Jekyll: {e}")
|
||||
|
||||
@@ -331,11 +336,14 @@ def update_xml_paths_exact(mmp_filename, replacements):
|
||||
print(f"Erro crítico ao editar XML: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def run_heavy_tasks_in_background():
|
||||
logging.info("--- [BACKGROUND] Iniciando tarefas assíncronas ---")
|
||||
try:
|
||||
generate_manifests(SRC_MMPSEARCH)
|
||||
|
||||
# ---> ATUALIZA OS ARQUIVOS "ALL" AQUI <---
|
||||
rebuild_all_yamls()
|
||||
|
||||
run_jekyll_build()
|
||||
logging.info("--- [BACKGROUND] Todas as tarefas concluídas ---")
|
||||
except Exception as e:
|
||||
|
||||
Reference in new issue
Block a user