douyinWEB/scripts/_clean_pve_nomad_android.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-04 22:42:40 -05:00

83 lines
2.9 KiB
Python

# -*- coding: utf-8 -*-
"""Clean nomadLifeApp2 Android build artifacts and Gradle caches on PVE Ubuntu."""
import sys, paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=30, allow_agent=False, look_for_keys=False)
script = r'''
set -euo pipefail
HOME_DIR=/home/eric
PROJ=/home/eric/projects/nomadLifeApp2
echo '===== BEFORE ====='
df -h /
du -sh "$HOME_DIR" "$PROJ" "$HOME_DIR/.gradle" 2>/dev/null || true
du -sh "$PROJ/android" "$PROJ/android/app/build" "$PROJ/node_modules" 2>/dev/null || true
echo
echo '===== CLEAN ====='
# Gradle user cache
rm -rf "$HOME_DIR/.gradle/caches" \
"$HOME_DIR/.gradle/daemon" \
"$HOME_DIR/.gradle/native" \
"$HOME_DIR/.gradle/workers" \
"$HOME_DIR/.gradle/.tmp" 2>/dev/null || true
echo cleaned ~/.gradle caches
# Project Android build outputs
if [ -d "$PROJ/android" ]; then
rm -rf "$PROJ/android/app/build" \
"$PROJ/android/build" \
"$PROJ/android/.gradle" \
"$PROJ/android/app/.cxx" \
"$PROJ/android/.cxx" 2>/dev/null || true
echo cleaned project android build/.gradle/.cxx
fi
# Expo / RN native build intermediates under node_modules (regenerable)
if [ -d "$PROJ/node_modules" ]; then
find "$PROJ/node_modules" -type d \( \
-name build -o -name .cxx -o -name intermediates -o -name obj \
\) -prune -print 2>/dev/null | head -5
# Count then delete
n=$(find "$PROJ/node_modules" -type d \( -path '*/android/build' -o -path '*/android/.cxx' -o -path '*/cxx/Debug/*' \) 2>/dev/null | wc -l)
echo "node_modules android build dirs ~$n (removing)"
find "$PROJ/node_modules" -type d -path '*/android/build' -prune -exec rm -rf {} + 2>/dev/null || true
find "$PROJ/node_modules" -type d -path '*/android/.cxx' -prune -exec rm -rf {} + 2>/dev/null || true
find "$PROJ/node_modules" -type d -path '*/intermediates/cxx/*' -prune -exec rm -rf {} + 2>/dev/null || true
find "$PROJ/node_modules" -type d -path '*/cmake/debug/obj' -prune -exec rm -rf {} + 2>/dev/null || true
echo cleaned node_modules native build intermediates
fi
# Expo export / metro caches if present
rm -rf "$PROJ/.expo" "$HOME_DIR/.expo" "$HOME_DIR/.cache/metro"* 2>/dev/null || true
# Android SDK build-cache if any under home
rm -rf "$HOME_DIR/.android/build-cache" 2>/dev/null || true
sync
echo
echo '===== AFTER ====='
df -h /
du -sh "$HOME_DIR" "$PROJ" "$HOME_DIR/.gradle" 2>/dev/null || true
du -sh "$PROJ/android" "$PROJ/node_modules" 2>/dev/null || true
echo DONE
'''
sftp = c.open_sftp()
with sftp.file("/tmp/_clean_nomad_android.sh", "w") as f:
f.write(script)
sftp.chmod("/tmp/_clean_nomad_android.sh", 0o755)
sftp.close()
_, o, e = c.exec_command("bash /tmp/_clean_nomad_android.sh", timeout=300)
print(o.read().decode("utf-8", "replace"))
err = e.read().decode("utf-8", "replace")
if err.strip():
print("STDERR", err[-2000:])
c.close()