FileAutomation

Automation-first Python library for local file / directory / zip operations, HTTP downloads, and remote storage (Google Drive, S3, Azure Blob, Dropbox, SFTP). Actions are defined as JSON and dispatched through a central registry so they can be executed in-process, from disk, over a TCP socket, or over HTTP.

Architecture

Layered architecture with Facade + Registry + Command + Strategy patterns:

automation_file/
├── __init__.py                 # Public API facade (every name users import)
├── __main__.py                 # CLI entry (argparse dispatcher, subcommands + legacy flags)
├── exceptions.py               # Exception hierarchy (FileAutomationException base)
├── logging_config.py           # file_automation_logger (file + stderr handlers)
├── core/
│   ├── action_registry.py      # ActionRegistry — name -> callable (Registry + Command)
│   ├── action_executor.py      # ActionExecutor — runs JSON action lists (Facade + Template Method)
│   ├── callback_executor.py    # CallbackExecutor — trigger then callback composition
│   ├── package_loader.py       # PackageLoader — dynamically registers package members
│   ├── json_store.py           # Thread-safe read/write of JSON action files
│   ├── retry.py                # retry_on_transient — capped exponential back-off decorator
│   └── quota.py                # Quota — size + time budget guards
├── local/                      # Strategy modules — each file is a batch of pure operations
│   ├── file_ops.py
│   ├── dir_ops.py
│   ├── zip_ops.py
│   └── safe_paths.py           # safe_join / is_within — path traversal guard
├── remote/
│   ├── url_validator.py        # SSRF guard for outbound URLs
│   ├── http_download.py        # SSRF-validated HTTP download with size/timeout caps + retry
│   ├── google_drive/
│   │   ├── client.py           # GoogleDriveClient (Singleton Facade)
│   │   ├── delete_ops.py
│   │   ├── download_ops.py
│   │   ├── folder_ops.py
│   │   ├── search_ops.py
│   │   ├── share_ops.py
│   │   └── upload_ops.py
│   ├── s3/                     # S3 (boto3) — auto-registered in build_default_registry()
│   │   ├── client.py           # S3Client
│   │   ├── upload_ops.py
│   │   ├── download_ops.py
│   │   ├── delete_ops.py
│   │   └── list_ops.py
│   ├── azure_blob/             # Azure Blob — auto-registered in build_default_registry()
│   │   └── {client,upload,download,delete,list}_ops.py
│   ├── dropbox_api/            # Dropbox — auto-registered in build_default_registry()
│   │   └── {client,upload,download,delete,list}_ops.py
│   └── sftp/                   # SFTP (paramiko + RejectPolicy) — auto-registered in build_default_registry()
│       └── {client,upload,download,delete,list}_ops.py
├── server/
│   ├── tcp_server.py           # Loopback-only TCP server executing JSON actions (optional shared-secret auth)
│   └── http_server.py          # Loopback-only HTTP server (POST /actions, optional Bearer auth)
├── project/
│   ├── project_builder.py      # ProjectBuilder (Builder pattern)
│   └── templates.py            # Scaffolding templates
├── ui/                         # PySide6 GUI (required dep)
│   ├── launcher.py             # launch_ui(argv) — boots QApplication + MainWindow
│   ├── main_window.py          # MainWindow — tabbed control surface over every feature
│   ├── worker.py               # ActionWorker(QRunnable) + _WorkerSignals
│   ├── log_widget.py           # LogPanel — timestamped, read-only log stream
│   └── tabs/                   # One tab per domain: local / http / drive / s3 /
│                               #                    azure / dropbox / sftp /
│                               #                    JSON actions / servers
└── utils/
    └── file_discovery.py       # Recursive file listing by extension

Key design patterns in use:

Key types

Branching & CI

Development

python -m pip install -r dev_requirements.txt pytest pytest-cov
python -m pip install -e ".[dev]"       # ruff, mypy, pre-commit
python -m pytest tests/ -v --tb=short
ruff check automation_file/ tests/
ruff format --check automation_file/ tests/
mypy automation_file/
python -m automation_file --help

Testing:

Conventions

Security

All code must follow secure-by-default principles. Review every change against the checklist below.

General rules

Network requests (SSRF prevention)

Network requests (TLS)

Subprocess execution

TCP server

HTTP server

Path traversal

SFTP host verification

Reliability (retry / quota)

Google Drive

File I/O

Plugin / package loading

Secrets and credentials

Dependency security

Code quality (SonarQube / Codacy compliance)

All code must satisfy common static-analysis rules. Review every change against the checklist below.

Complexity & size

Exception handling

Pythonic correctness

Naming & style (PEP 8)

Duplication & dead code

Logging, printing, assertions

Hardcoded values & secrets

Boolean & return hygiene

Imports

Running the linter

Commit & PR rules