Spaces:
Sleeping
Sleeping
| #!/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() |