Skip to main content

CLI utilities for QFieldCloud: upload to GCP, clean old files, and more

Project description

digistudio-qc-utils

CLI utilities for QFieldCloud: upload photos to Google Cloud Storage, clean old files, and more.

Features

  • Upload photos to GCP: Copy photos from QFieldCloud to a Google Cloud Storage bucket
  • Clean old photos: Remove photos older than a specified number of days from QFieldCloud
  • Flexible filtering: Use glob patterns to filter which files to process (default: *.jpg)
  • Dry-run mode: Test cleanup operations without actually deleting files
  • Progress reporting: See detailed progress and summary of operations

Installation

Requirements

  • Python 3.10 or higher
  • uv package manager

Install dependencies

uv sync

This will install the package in development mode with all dependencies.

Configuration

Environment Variables

Create a .env file or export these environment variables:

# QFieldCloud authentication (required for both commands)
export QFIELDCLOUD_USERNAME="your_username"
export QFIELDCLOUD_PASSWORD="your_password"

# Optional: QFieldCloud API URL (default: https://app.qfield.cloud/api/v1/)
export QFIELDCLOUD_URL="https://app.qfield.cloud/api/v1/"

# Alternative: use token authentication
export QFIELDCLOUD_TOKEN="your_token"

GCP Service Account

For the upload command, you need a GCP service account JSON file with permissions to write to Cloud Storage.

See .env.example for a complete list of environment variables.

Usage

Upload photos to GCP

Upload photos from QFieldCloud to a Google Cloud Storage bucket:

qc-to-gcp upload \
  --qc-project-id "your-qfield-project-id" \
  --gcp-bucket "your-gcs-bucket" \
  --gcp-bucket-directory "photos/2024" \
  --gcp-auth-file "path/to/service-account.json" \
  --qc-filter "*.jpg"

Options:

  • --qc-project-id: QFieldCloud project ID (required)
  • --gcp-bucket: GCP bucket name (required)
  • --gcp-bucket-directory: Directory path in bucket (required)
  • --gcp-auth-file: Path to GCP service account JSON file (required)
  • --qc-filter: File pattern to match (default: *.jpg)
  • --verbose, -v: Enable verbose logging

Features:

  • Intelligently compares file lists to skip existing files (only 2 API calls instead of N+1)
  • Handles subdirectories properly (DCIM/, files/, etc.)
  • Shows progress for each file
  • Provides detailed analysis summary before upload
  • Uses temporary storage for downloads

Clean old photos from QFieldCloud

Remove photos older than a specified number of days:

qc-clean \
  --qc-project-id "your-qfield-project-id" \
  --keep-days 15 \
  --qc-filter "*.jpg"

Options:

  • --qc-project-id: QFieldCloud project ID (required)
  • --keep-days: Keep files newer than this many days (default: 15)
  • --qc-filter: File pattern to match (default: *.jpg)
  • --dry-run: Show what would be deleted without actually deleting
  • --verbose, -v: Enable verbose logging and show detailed file list

Example with dry-run:

qc-clean \
  --qc-project-id "693d753d-2b71-44e1-892f-dd2e77852c4a" \
  --keep-days 30 \
  --qc-filter "*.jpg" \
  --dry-run

Development

Project structure

qc-utils/
├── src/qc_utils/
│   ├── __init__.py
│   ├── cli.py              # CLI entry points
│   ├── commands/
│   │   ├── clean.py        # Clean command implementation
│   │   └── upload.py       # Upload command implementation
│   └── core/
│       ├── filters.py      # File filtering utilities
│       ├── gcp_client.py   # GCP Storage client wrapper
│       └── qfield_client.py # QFieldCloud client wrapper
├── pyproject.toml
└── README.md

Run linting

uv run ruff check .
uv run ruff format .

Run type checking

uv run basedpyright

License

[Add your license here]

Credits

This tool replaces the historical bash/Python scripts with a modern CLI architecture.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

digistudio_qc_utils-0.3.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

digistudio_qc_utils-0.3.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file digistudio_qc_utils-0.3.0.tar.gz.

File metadata

  • Download URL: digistudio_qc_utils-0.3.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for digistudio_qc_utils-0.3.0.tar.gz
Algorithm Hash digest
SHA256 74f3f68b39841ec5f048f342a69f5706af0a4e50e0c8f58ac83d67fb402f252b
MD5 770277347f6b5d3e5889bf0464023f71
BLAKE2b-256 84967cecf2d25e16dccc215d2f90642345da8ef4dcac4460e60e25575b876900

See more details on using hashes here.

File details

Details for the file digistudio_qc_utils-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for digistudio_qc_utils-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bedd9200125dfc1d0b6595288adffc921aea1c46e4b9ef9c7b0ecf992a8c94b6
MD5 4327a37a9be3c8deea39e79298eba056
BLAKE2b-256 e39f84eb1f1ca8ee878b595020a9a78683e3a289548ba2d525922216cf76b586

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page