Spaces:
Running
Running
| """ | |
| Deployment Script for ProVerBs Landing Page | |
| Deploys to Solomon7890/ProVerbS_LaW_mAiN_PAgE | |
| """ | |
| import subprocess | |
| import sys | |
| import os | |
| def print_banner(): | |
| print("="*60) | |
| print("π ProVerBs Legal AI - Landing Page Deployment") | |
| print("="*60) | |
| print() | |
| def check_login(): | |
| """Check if user is logged in to Hugging Face""" | |
| print("π Checking Hugging Face authentication...") | |
| try: | |
| result = subprocess.run(['huggingface-cli', 'whoami'], | |
| capture_output=True, text=True) | |
| if result.returncode == 0: | |
| username = result.stdout.strip().split('\n')[0].replace('username: ', '') | |
| print(f" β Logged in as: {username}") | |
| return username | |
| else: | |
| print(" β Not logged in") | |
| return None | |
| except Exception as e: | |
| print(f" β Error: {e}") | |
| return None | |
| def login_hf(): | |
| """Login to Hugging Face""" | |
| print("\nπ Please login to Hugging Face...") | |
| print("Token: https://huggingface.co/settings/tokens\n") | |
| try: | |
| subprocess.run(['huggingface-cli', 'login']) | |
| return check_login() | |
| except Exception as e: | |
| print(f"β Login failed: {e}") | |
| return None | |
| def deploy_space(): | |
| """Deploy to the Space""" | |
| space_name = "Solomon7890/ProVerbS_LaW_mAiN_PAgE" | |
| print(f"\nπ€ Deploying to: {space_name}") | |
| print("="*60) | |
| try: | |
| # Check if git is initialized | |
| if not os.path.exists('.git'): | |
| print("π¦ Initializing git repository...") | |
| subprocess.run(['git', 'init'], check=True) | |
| # Add remote if not exists | |
| print("π Setting up remote...") | |
| subprocess.run( | |
| ['git', 'remote', 'add', 'space', f'https://huggingface.co/spaces/{space_name}'], | |
| capture_output=True | |
| ) | |
| # Set remote URL (in case it already exists) | |
| subprocess.run( | |
| ['git', 'remote', 'set-url', 'space', f'https://huggingface.co/spaces/{space_name}'], | |
| capture_output=True | |
| ) | |
| # Replace app.py with enhanced version | |
| print("π Updating app.py with enhanced version...") | |
| if os.path.exists('enhanced_app.py'): | |
| import shutil | |
| shutil.copy('enhanced_app.py', 'app.py') | |
| print(" β Enhanced app.py deployed") | |
| # Add files | |
| print("π Adding files...") | |
| subprocess.run(['git', 'add', 'app.py', 'README.md', '.gitattributes'], check=True) | |
| # Commit | |
| print("πΎ Creating commit...") | |
| subprocess.run( | |
| ['git', 'commit', '-m', 'Deploy enhanced ProVerBs Legal AI landing page'], | |
| capture_output=True | |
| ) | |
| # Push | |
| print("π Pushing to Hugging Face...") | |
| result = subprocess.run( | |
| ['git', 'push', 'space', 'main', '-f'], | |
| capture_output=True, | |
| text=True | |
| ) | |
| if result.returncode != 0: | |
| # Try master branch | |
| result = subprocess.run( | |
| ['git', 'push', 'space', 'master', '-f'], | |
| capture_output=True, | |
| text=True | |
| ) | |
| if "Everything up-to-date" in result.stderr or result.returncode == 0: | |
| print(" β Deployment successful!") | |
| return True | |
| else: | |
| print(" β οΈ Push completed with warnings") | |
| return True | |
| except Exception as e: | |
| print(f" β Error: {e}") | |
| return False | |
| def main(): | |
| print_banner() | |
| # Check login | |
| username = check_login() | |
| if not username: | |
| username = login_hf() | |
| if not username: | |
| print("\nβ Deployment cancelled - login required") | |
| return | |
| # Confirm deployment | |
| space_url = "https://huggingface.co/spaces/Solomon7890/ProVerbS_LaW_mAiN_PAgE" | |
| print(f"\nπ Deployment Target:") | |
| print(f" Space: Solomon7890/ProVerbS_LaW_mAiN_PAgE") | |
| print(f" URL: {space_url}") | |
| print() | |
| confirm = input("Deploy enhanced landing page now? (y/n): ").strip().lower() | |
| if confirm != 'y': | |
| print("\nβ Deployment cancelled") | |
| return | |
| # Deploy | |
| if deploy_space(): | |
| print("\n" + "="*60) | |
| print("β DEPLOYMENT SUCCESSFUL!") | |
| print("="*60) | |
| print() | |
| print(f"π Your Space is available at:") | |
| print(f" {space_url}") | |
| print() | |
| print("β³ The Space is now building. This may take 2-3 minutes.") | |
| print() | |
| print("π Next steps:") | |
| print(" 1. Visit your Space URL") | |
| print(" 2. Wait for the build to complete") | |
| print(" 3. Test all features") | |
| print(" 4. Share with your audience!") | |
| print() | |
| print("="*60) | |
| else: | |
| print("\nβ Deployment failed. Please check the errors above.") | |
| if __name__ == "__main__": | |
| try: | |
| main() | |
| except KeyboardInterrupt: | |
| print("\n\nβ Deployment cancelled by user") | |
| except Exception as e: | |
| print(f"\n\nβ Unexpected error: {e}") | |