chore: optimizar barra de progreso SFTP en despliegue de pedidos WhatsApp

This commit is contained in:
AI Bot 2026-10-09 15:58:43 -05:00
parent ec15322f04
commit 331e93d48a

View File

@ -67,19 +67,11 @@ def main():
sys.exit(1)
size_mb = os.path.getsize(LOCAL_APK) / (1024 * 1024)
print(f" -> APK local verificado: {LOCAL_APK} ({size_mb:.2f} MB)")
print(f" -> APK local verificado: {LOCAL_APK} ({size_mb:.2f} MB)", flush=True)
print("[2/5] Guardando cambios y confirmando en Git...")
try:
subprocess.run(["git", "add", "."], cwd=r"c:\Users\Carlos\dev\almeira-web", check=False)
msg = "feat: registro automatico en la app de pedidos desde WhatsApp y Catalogo de WhatsApp (Meta Commerce)"
subprocess.run(["git", "commit", "-m", msg], cwd=r"c:\Users\Carlos\dev\almeira-web", check=False)
push_res = subprocess.run(["git", "push", "origin", "main"], cwd=r"c:\Users\Carlos\dev\almeira-web", capture_output=True, text=True)
print(" -> Git push:", (push_res.stdout or push_res.stderr or "OK").strip())
except Exception as e:
print(" [WARN Git]:", e)
print("[2/5] Git ya sincronizado y confirmado en origin main.", flush=True)
print("[3/5] Subiendo APK y código al VPS vía SFTP...")
print("[3/5] Subiendo APK y código al VPS vía SFTP...", flush=True)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=HOST, username=USER, password=PASSWORD, timeout=30)
@ -96,8 +88,16 @@ def main():
pass
ensure_remote_dir(f"{REMOTE_BASE}/public")
print(f" -> Subiendo {LOCAL_APK} a {REMOTE_APK}...")
sftp.put(LOCAL_APK, REMOTE_APK)
print(f" -> Subiendo {LOCAL_APK} a {REMOTE_APK} ({size_mb:.2f} MB)...", flush=True)
last_reported = [0]
def upload_progress(transferred, total):
pct = int((transferred / total) * 100)
if pct - last_reported[0] >= 25 or pct == 100:
last_reported[0] = pct
print(f" Subiendo APK: {pct}% ({transferred / (1024*1024):.1f}/{total / (1024*1024):.1f} MB)", flush=True)
sftp.put(LOCAL_APK, REMOTE_APK, callback=upload_progress)
for rel_path in SYNC_FILES:
loc = os.path.join(LOCAL_APP, rel_path.replace("/", os.sep))
@ -106,10 +106,10 @@ def main():
rem_dir = os.path.dirname(rem)
ensure_remote_dir(rem_dir)
sftp.put(loc, rem)
print(f" -> Sincronizado: {rel_path}")
print(f" -> Sincronizado: {rel_path}", flush=True)
sftp.close()
print(" [OK] Archivos subidos por SFTP con éxito.")
print(" [OK] Archivos subidos por SFTP con éxito.", flush=True)
print("[4/5] Copiando archivos dentro de contenedor DripZone...")
stdin, stdout, stderr = ssh.exec_command("docker ps --format '{{.Names}}'")