Spaces:
Sleeping
Sleeping
File size: 1,807 Bytes
c7dc4b9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | import re
import subprocess
import sys
def main():
glassui_path = "glassui.html"
dashboard_path = "dashboard.html"
# Read the New Design
try:
with open(glassui_path, 'r', encoding='utf-8') as f:
glassui_content = f.read()
except FileNotFoundError:
print(f"Error: Could not find '{glassui_path}'.")
sys.exit(1)
# The Safety Scan (Crucial)
required_ids = [
"dropZone",
"fileInput",
"browseBtn",
"startBtn",
"deployBtn",
"jsonOutput",
"copyBtn",
"downloadBtn"
]
for element_id in required_ids:
# Check if id="element_id" or id='element_id' exists
pattern = rf'id\s*=\s*[\'"]{element_id}[\'"]'
if not re.search(pattern, glassui_content):
print(f"⚠️ WARNING: Missing ID {element_id}")
# Overwrite
try:
with open(dashboard_path, 'w', encoding='utf-8') as f:
f.write(glassui_content)
print(f"Successfully copied '{glassui_path}' to '{dashboard_path}'.")
except Exception as e:
print(f"Error overwriting '{dashboard_path}': {e}")
sys.exit(1)
# Deploy
print("Deploying to Hugging Face...")
git_commands = [
["git", "add", "dashboard.html"],
["git", "commit", "-m", "UI Update: Apply responsive Glassmorphism design from Stitch"],
["git", "push", "space", "clean_deploy:main"]
]
for cmd in git_commands:
print(f"Running: {' '.join(cmd)}")
# Use encoding='utf-8' as strictly requested
result = subprocess.run(cmd, text=True, encoding='utf-8')
if result.returncode != 0:
print(f"Command failed: {' '.join(cmd)}")
if __name__ == "__main__":
main()
|