How daozhang66/python_runner works
Python Runner is a Flutter Android app for organizing and editing Python scripts, running them in an interactive terminal, managing packages across two Python runtimes, and inspecting script network activity. The main workflow starts in the script workspace or editor, passes execution requests through the Flutter execution layer and native bridge, then runs them through Chaquopy or the Linux-like environment and streams output back to the console. Separate branches cover project files, package management, request overrides and inspection, and diagnostics. README capabilities supplement the sampled runtime excerpts; wiring for unsampled Flutter and Android components is shown only where documented or supported by the repository structure.
Main entry points: ScriptExecutionController.kt Script execution · script_workspace_controller.dart Workspace controller · pages Script pages · script_editor_page.dart Code editor
Components 32
App interface
- Flutter app
lib/main.dart - Script pages
lib/features/scripts/presentation/pages - Code editor
lib/features/scripts/presentation/pages/script_editor_page.dart - Run console
lib/features/console/presentation/pages/run_console_page.dart
Script workspace
- Workspace controller
lib/features/scripts/application/script_workspace_controller.dart - Script repository
lib/features/scripts/application/script_repository.dart - Project service
lib/services/script_project_service.dart - Project files
android/app/src/main/kotlin/com/daozhang/py/ScriptProjectStore.kt
Execution runtime
- Execution repository
lib/features/console/application/execution_repository.dart - Execution state
lib/providers/execution_provider.dart - Native bridge
lib/services/native_bridge.dart - Android channel entry
android/app/src/main/kotlin/com/daozhang/py/MainActivity.kt - Script execution
android/app/src/main/kotlin/com/daozhang/py/ScriptExecutionController.kt - Runtime manager
lib/runtime/runtime_manager.dart - Chaquopy backend
lib/runtime/chaquopy_backend.dart - Linux-like backend
lib/runtime/linux_like_backend.dart - Linux environment
android/app/src/main/kotlin/com/daozhang/py/LinuxLikeRuntimeManager.kt - Python runner
android/app/src/main/python/script_runner.py - Foreground service
android/app/src/main/kotlin/com/daozhang/py/PythonForegroundService.kt
Runtime packages
- Package manager UI
lib/pages/package_manager_page.dart - Package controller
lib/features/packages/application/package_controller.dart - Chaquopy packages
android/app/src/main/kotlin/com/daozhang/py/ChaquopyPackageController.kt - Linux-like packages
android/app/src/main/kotlin/com/daozhang/py/LinuxLikePackageController.kt
Network diagnostics
- Network inspector
lib/pages/network_inspector_page.dart - Inspector repository
lib/features/network/application/network_inspector_repository.dart - Request store
lib/services/http_inspector_store.dart - HTTP debug hook
android/app/src/main/python/http_debug_hook.py - Override config
lib/services/request_override_config.dart - App logs
lib/pages/app_logs_page.dart - App database
lib/services/database_service.dart
Other components
- App user
- Package index
Connections 35
- App user → Flutter app: uses
- Flutter app → Script pages: opens
- Script pages → Workspace controller: manages scripts
- Workspace controller → Script repository: loads and saves
- Workspace controller → Project service: manages projects
- Project service → Project files: accesses project files
- Script pages → Code editor: edits scripts
- Code editor → Workspace controller: saves and runs
- Code editor → Run console: opens execution
- Run console → Execution state: controls run
- Execution state → Execution repository: requests execution
- Execution repository → Native bridge: sends commands
- Native bridge → Android channel entry: invokes channel
- Android channel entry → Script execution: dispatches execution
- Script execution → Runtime manager: selects runtime
- Runtime manager → Chaquopy backend: runs with
- Runtime manager → Linux-like backend: runs with
- Linux-like backend → Linux environment: uses environment
- Script execution → Python runner: executes script
- Script execution → Foreground service: starts service
- Script execution → Execution state: streams results
- App user → Package manager UI: manages packages
- Package manager UI → Package controller: submits package actions
- Package controller → Chaquopy packages: dispatches Chaquopy
- Package controller → Linux-like packages: dispatches Linux-like
- Chaquopy packages → Package index: installs packages
- Linux-like packages → Package index: installs packages
- App user → Network inspector: inspects requests
- Network inspector → Inspector repository: queries records
- Inspector repository → Request store: reads records
- Python runner → HTTP debug hook: initializes hook
- HTTP debug hook → Request store: emits request records
- Override config → HTTP debug hook: configures overrides
- App user → App logs: views diagnostics
- App logs → App database: reads logs