|
|
import os |
|
|
import socket |
|
|
import config_creator |
|
|
|
|
|
def defineAmbiente(env): |
|
|
print("Estoy en define ambiente...") |
|
|
|
|
|
if local_check(): |
|
|
print("Entorno Local...") |
|
|
import bridges |
|
|
if env == 'prod': |
|
|
llave = bridges.llave_prod |
|
|
webhook = bridges.webhook_prod |
|
|
firestore = 'config_prod.json' |
|
|
|
|
|
else: |
|
|
llave = bridges.llave_sandbox |
|
|
webhook = bridges.webhook_sandbox |
|
|
firestore = 'config_dev.json' |
|
|
ga4Key = bridges.GA4_API_SECRET_TARGET |
|
|
ga4ID = bridges.GA4_MEASUREMENT_ID |
|
|
else: |
|
|
print("Entorno remoto listo...") |
|
|
if os.getenv("ambiente_stripe") == 'prod': |
|
|
print("Ambiente stripe es: ", os.getenv("ambiente_stripe")) |
|
|
llave = os.getenv("STRIPE_KEY_PROD") |
|
|
webhook = os.getenv("STRIPE_WEBHOOK_SECRET_PROD") |
|
|
config_creator.creaConfigFirestore('configuracion_prod') |
|
|
ga4Key = os.getenv("GA4_SECRET_PROD") |
|
|
ga4ID = os.getenv("GA4_ID_PROD") |
|
|
else: |
|
|
print("Ambiente stripe es: ", os.getenv("ambiente_stripe")) |
|
|
llave = os.getenv("STRIPE_KEY_SANDBOX") |
|
|
webhook = os.getenv("STRIPE_WEBHOOK_SECRET_SANDBOX") |
|
|
config_creator.creaConfigFirestore('configuracion_dev') |
|
|
ga4Key = os.getenv("GA4_SECRET_DEV") |
|
|
ga4ID = os.getenv("GA4_ID_DEV") |
|
|
|
|
|
return llave, webhook, ga4Key, ga4ID |
|
|
|
|
|
def local_check(): |
|
|
hostname = socket.gethostname() |
|
|
|
|
|
print("Hostname: ", hostname) |
|
|
|
|
|
if "r-moibe" in hostname: |
|
|
print("Ejecutando api en el servidor.") |
|
|
return False |
|
|
else: |
|
|
print("Ejecutando api en local.") |
|
|
return True |