#!/usr/bin/env python3 """ Dev LMS Startup Script ====================== This script provides an easy way to start the Dev LMS application. It handles dependency checking and provides helpful information. """ import subprocess import sys import os def check_dependencies(): """Check if required dependencies are installed""" required_packages = [ 'streamlit', 'streamlit_authenticator', 'PyPDF2', 'yaml', 'bcrypt' ] missing_packages = [] for package in required_packages: try: __import__(package.replace('-', '_')) except ImportError: missing_packages.append(package) return missing_packages def install_dependencies(): """Install missing dependencies""" print("Installing missing dependencies...") try: subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt']) print("āœ… Dependencies installed successfully!") return True except subprocess.CalledProcessError: print("āŒ Failed to install dependencies. Please install them manually:") print(" pip install -r requirements.txt") return False def main(): print("šŸš€ Dev LMS - Learning Management System") print("=" * 50) # Check if we're in the right directory if not os.path.exists('src/streamlit_app.py'): print("āŒ Error: Please run this script from the project root directory") print(" (where src/streamlit_app.py is located)") sys.exit(1) # Check dependencies print("šŸ” Checking dependencies...") missing = check_dependencies() if missing: print(f"āŒ Missing dependencies: {', '.join(missing)}") response = input("Would you like to install them now? (y/n): ") if response.lower() in ['y', 'yes']: if not install_dependencies(): sys.exit(1) else: print("Please install dependencies manually and try again.") sys.exit(1) else: print("āœ… All dependencies are installed!") print("\nšŸŽÆ Starting Dev LMS...") print("šŸ“– Default login credentials:") print(" - Admin: admin / admin123") print(" - Teacher: teacher / teacher123") print(" - Student: student / student123") print("\n🌐 The application will open in your browser at: http://localhost:8501") print("ā¹ļø Press Ctrl+C to stop the application") print("=" * 50) try: # Start the Streamlit app subprocess.run([ sys.executable, '-m', 'streamlit', 'run', 'src/streamlit_app.py', '--server.port=8501', '--server.headless=true' ]) except KeyboardInterrupt: print("\nšŸ‘‹ Dev LMS stopped. Goodbye!") except Exception as e: print(f"āŒ Error starting application: {e}") sys.exit(1) if __name__ == "__main__": main()