|
||
---|---|---|
.doc | ||
.playwright-mcp | ||
app | ||
backup | ||
data | ||
scripts | ||
.dockerignore | ||
.env.example | ||
.gitignore | ||
Dockerfile | ||
MIGRATION-GUIDE.md | ||
README-Docker.md | ||
README.md | ||
check_complete_log.py | ||
check_db.py | ||
check_group_env.py | ||
check_log.py | ||
check_tables.py | ||
conda-environments.md | ||
conda-environments.yml | ||
debug_discovery.py | ||
demo_scriptsmanager_integration.py | ||
docker-compose.yml | ||
docker-manage.sh | ||
docker-sudo.sh | ||
example_script.py | ||
install-docker.sh | ||
migrate_execution_logs.py | ||
requirements-dev.txt | ||
requirements.txt | ||
scriptmanager.code-workspace | ||
simple_debug.py | ||
test_complete_integration.py | ||
test_hammer_browser.py | ||
test_hammer_calculations.py | ||
test_helper_functions.py | ||
test_language_switching.py | ||
test_model.py | ||
test_permissions.py | ||
verify-environments.sh | ||
verify_dashboard_changes.py | ||
verify_design_changes.py | ||
verify_group5.py | ||
verify_navbar_themes.py | ||
verify_sidel_logo.py |
README.md
ScriptsManager
A comprehensive web-based application for managing and executing Python scripts with multi-user support, conda environment integration, and real-time monitoring.
Features
- Multi-user support with role-based access control
- Multi-language interface (English, Spanish, Italian, French)
- Conda environment integration for isolated script execution
- Real-time log streaming with WebSocket connections
- Script parameter management with web forms
- Dark/Light theme support
- Responsive web interface with Bootstrap 5
- Script discovery and automatic registration
- Web interface support for scripts with UI components
- Project-based data isolation for multi-user environments
Requirements
- Python 3.8+
- Conda (for environment management)
- Modern web browser with WebSocket support
Installation
-
Clone or extract the project:
cd SIDELManagerScripts
-
Install Python dependencies:
pip install -r requirements.txt
-
Initialize the database:
python scripts/init_db.py
-
Create admin user (if not created by init_db):
python scripts/create_admin.py
Quick Start
-
Start the application:
python scripts/run_app.py
-
Open your browser and navigate to:
http://localhost:5000
-
Login with default admin credentials:
- Username:
admin
- Password:
admin123
- Important: Change the password after first login!
- Username:
-
Explore the dashboard and script groups
Project Structure
SIDELManagerScripts/
├── app/ # Main application package
│ ├── config/ # Configuration files
│ │ ├── config.py # App configuration
│ │ ├── database.py # Database setup
│ │ └── permissions.py # Role-based permissions
│ ├── models/ # Database models
│ │ ├── user.py # User and role models
│ │ └── script.py # Script and group models
│ ├── services/ # Business logic services
│ │ ├── conda_service.py # Conda environment management
│ │ ├── discovery_service.py # Script discovery and parsing
│ │ ├── script_executor.py # Script execution engine
│ │ ├── data_manager.py # Multi-user data isolation
│ │ ├── port_manager.py # Dynamic port allocation
│ │ └── translation_service.py # Multi-language support
│ ├── templates/ # HTML templates
│ │ ├── base.html # Base template
│ │ ├── login.html # Login page
│ │ ├── dashboard.html # Main dashboard
│ │ └── script_group.html # Script group view
│ ├── static/ # Static assets
│ │ ├── css/ # Stylesheets
│ │ ├── js/ # JavaScript files
│ │ └── translations/ # Language files
│ └── __init__.py # App factory
├── backend/ # Script groups directory
│ └── script_groups/ # Individual script collections
├── scripts/ # Utility scripts
│ ├── init_db.py # Database initialization
│ ├── create_admin.py # Admin user creation
│ └── run_app.py # Application runner
├── instance/ # Instance-specific files
├── logs/ # Application logs
├── requirements.txt # Python dependencies
├── requirements-dev.txt # Development dependencies
└── README.md # This file
Script Groups
Script groups are collections of related Python scripts stored in the app/backend/script_groups/
directory. Each group contains:
- metadata.json: Group configuration and script list
- Python scripts: The actual executable scripts
- Optional conda environment: Isolated execution environment
Creating Script Groups
- Create a new directory in
app/backend/script_groups/
- Add a
metadata.json
file with group configuration - Add your Python scripts with proper parameter headers
- Restart the application to discover new scripts
Example metadata.json:
{
"name": "data_processing",
"display_name": "Data Processing Tools",
"description": "Scripts for data analysis and processing",
"conda_env": "data_science",
"scripts": [
"data_analyzer.py",
"csv_processor.py"
]
}
Script Parameter Headers
Scripts can define parameters in their docstring headers:
"""
Script Name
Script description
Parameters:
- input_file: Input file path
- output_format: Output format (json/csv/xlsx)
Interface: Yes/No
"""
Configuration
Environment Variables
FLASK_ENV
: Application environment (development/production)SECRET_KEY
: Flask secret key for sessionsDATABASE_URL
: Database connection stringCONDA_PATH
: Path to conda executable
Database Configuration
The application uses SQLite by default. For production, configure PostgreSQL or MySQL in app/config/config.py
.
Conda Integration
The application automatically detects conda environments and can execute scripts in isolated environments. Ensure conda is installed and accessible in your PATH.
Multi-Language Support
The application supports multiple languages:
- English (en)
- Spanish (es)
- Italian (it)
- French (fr)
Language files are stored in app/static/translations/
and can be extended with additional languages.
Security Features
- Role-based access control (Admin, User, Viewer)
- Session management with secure cookies
- CSRF protection for forms
- Input validation for script parameters
- Process isolation for script execution
- Multi-user data separation
API Endpoints
The application provides REST API endpoints for:
- Script execution:
POST /api/scripts/run
- Log retrieval:
GET /api/scripts/{id}/logs
- Interface access:
GET /api/scripts/{id}/interface
- User management:
/api/users/*
- System status:
GET /api/status
WebSocket Events
Real-time updates are provided via WebSocket:
script_started
: Script execution beginsscript_completed
: Script execution finishesscript_failed
: Script execution failsscript_output
: Real-time log outputsystem_notification
: System messages
Development
Setting up Development Environment
-
Install development dependencies:
pip install -r requirements-dev.txt
-
Set Flask environment:
export FLASK_ENV=development
-
Enable debug mode:
export FLASK_DEBUG=1
Running Tests
python -m pytest tests/
Code Style
The project follows PEP 8 style guidelines. Use flake8 for linting:
flake8 app/
Deployment
Production Deployment
-
Set production environment:
export FLASK_ENV=production
-
Configure a production WSGI server (gunicorn):
pip install gunicorn gunicorn -w 4 -b 0.0.0.0:5000 "app:create_app()"
-
Set up a reverse proxy (nginx/Apache)
-
Configure SSL certificates
-
Set up monitoring and logging
Docker Deployment
A Dockerfile can be created for containerized deployment:
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["python", "scripts/run_app.py"]
Troubleshooting
Common Issues
- Database errors: Run
python scripts/init_db.py
to recreate database - Conda not found: Ensure conda is in your PATH
- Port conflicts: Check that port 5000 is available
- Permission errors: Ensure proper file permissions for script execution
Log Files
Application logs are stored in the logs/
directory:
app.log
: General application logsscripts.log
: Script execution logserrors.log
: Error logs
Debug Mode
Enable debug mode for detailed error messages:
export FLASK_DEBUG=1
python scripts/run_app.py
Support
For issues and questions:
- Check the troubleshooting section
- Review application logs
- Verify configuration settings
- Check script group metadata and permissions
License
This project is licensed under the MIT License. See LICENSE file for details.