add initial config
Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
@@ -2,12 +2,41 @@ import json
|
||||
import logging
|
||||
from logging.handlers import RotatingFileHandler
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from datalayer.item_monitor import ItemMonitor
|
||||
from datalayer.general_monitor import GeneralMonitor
|
||||
from managers.worker import Worker
|
||||
from managers.queue_manager import QueueManager
|
||||
|
||||
def initialize_config_files():
|
||||
"""
|
||||
Inicializa los archivos de configuración si no existen,
|
||||
copiando los archivos .sample correspondientes.
|
||||
"""
|
||||
base_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
config_files = [
|
||||
('config.yaml', 'config.sample.yaml'),
|
||||
('workers.json', 'workers.sample.json')
|
||||
]
|
||||
|
||||
for config_file, sample_file in config_files:
|
||||
config_path = os.path.join(base_dir, config_file)
|
||||
sample_path = os.path.join(base_dir, sample_file)
|
||||
|
||||
if not os.path.exists(config_path):
|
||||
if os.path.exists(sample_path):
|
||||
shutil.copy2(sample_path, config_path)
|
||||
print(f"✓ Archivo '{config_file}' creado desde '{sample_file}'")
|
||||
print(f" Por favor, edita '{config_file}' con tu configuración antes de continuar.")
|
||||
else:
|
||||
raise FileNotFoundError(
|
||||
f"No se encontró ni '{config_file}' ni '{sample_file}'. "
|
||||
f"Por favor, crea uno de estos archivos."
|
||||
)
|
||||
|
||||
def configure_logger():
|
||||
logging.getLogger("httpx").setLevel(logging.WARNING)
|
||||
|
||||
@@ -36,6 +65,7 @@ def parse_items_to_monitor():
|
||||
return items, general_args
|
||||
|
||||
if __name__ == "__main__":
|
||||
initialize_config_files()
|
||||
configure_logger()
|
||||
items, general_args = parse_items_to_monitor()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user