""" 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}")