The official QFieldCloud SDK and CLI.
Project description
The official QFieldCloud SDK and CLI
qfieldcloud-sdk
is the official client to connect to QFieldCloud API either as a python module, or directly from the command line.
Install
pip install qfieldcloud-sdk
Module usage
import qfieldcloud_sdk
import requests
client = qfieldcloud_sdk.Client(
url="https://app.qfield.cloud/api/v1/",
username="user1",
password="pass1",
)
try:
projects = client.projects()
except requests.HttpRequest:
print("Oops!")
CLI usage
The official QFieldCloud CLI tool.
Usage
qfieldcloud-cli [OPTIONS] COMMAND [ARGS]...
Examples
# logs in user "user" with password "pass"
qfieldcloud-cli login user pass
# gets the projects of user "user" with password "pass" at "https://localhost/api/v1/"
qfieldcloud-cli -u user -p pass -U https://localhost/api/v1/ list-projects
# gets the projects of user authenticated with token `QFIELDCLOUD_TOKEN` at "https://localhost/api/v1/" as JSON
export QFIELDCLOUD_URL=https://localhost/api/v1/
export QFIELDCLOUD_TOKEN=017478ee2464440cb8d3e98080df5e5a
qfieldcloud-cli --json list-projects
Global options overview
-U, --url TEXT URL to the QFieldCloud API endpoint. If not
passed, gets the value from QFIELDCLOUD_URL
environment variable. Default:
https://app.qfield.cloud/api/v1/
-u, --username TEXT Username or email.
-p, --password TEXT
-t, --token TEXT Session token.
--json / --human Output the result as newline formatted json. Default: False
--verify-ssl / --no-verify-ssl Verify SSL. Default: True
--help Show this message and exit.
Environment variables can be used instead of passing some common global options.
QFIELDCLOUD_API
- QFieldCloud API endpoint URLQFIELDCLOUD_USERNAME
- QFieldCloud username or email. NeedQFIELDCLOUD_PASSWORD
to be set.QFIELDCLOUD_PASSWORD
- Password. NeedsQFIELDCLOUD_USERNAME
to be set.QFIELDCLOUD_TOKEN
- Token that can be used instead of passing username and password. It can be obtained by runningqfieldcloud-cli login
.
Commands overview
login Login to QFieldCloud.
logout Logout and expire the token.
list-projects List QFieldCloud projects.
list-files List QFieldCloud project files.
create-project Creates a new empty QFieldCloud project.
upload-files Upload files to a QFieldCloud project.
download-files Download QFieldCloud project files.
package-trigger Initiate project packaging for QField.
package-status Check project packaging status.
package-download Download packaged QFieldCloud project files.
login
Login to QFieldCloud.
qfieldcloud-cli login [OPTIONS] USERNAME PASSWORD
logout
Logout from QFieldCloud.
qfieldcloud-cli logout
list-projects
List QFieldCloud projects.
qfieldcloud-cli list-projects [OPTIONS]
Options:
--include-public / --no-public Includes the public project in the list. Default: False
list-files
List QFieldCloud project files.
qfieldcloud-cli list-files [OPTIONS] PROJECT_ID
create-project
Creates a new empty QFieldCloud project.
qfieldcloud-cli create-project [OPTIONS] NAME
Options:
--owner TEXT Owner of the project. If omitted, the current
user is the owner.
--description TEXT Description of the project.
--is-public / --is-private Mark the project as public.
upload-files
Upload files to a QFieldCloud project.
qfieldcloud-cli upload-files [OPTIONS] PROJECT_ID PROJECT_PATH
Options:
--filter TEXT Do not upload the whole project, but only
the files which match the glob.
--exit-on-error / --no-exit-on-error
If any project file upload fails stop
uploading the rest. Default: False
download-files
Download QFieldCloud project files.
qfieldcloud-cli download-files [OPTIONS] PROJECT_ID LOCAL_DIR
Options:
--filter TEXT Do not download the whole project, but only
the files which match the glob.
--exit-on-error / --no-exit-on-error
If any project file downloads fails stop
downloading the rest. Default: False
download-files
Download packaged QFieldCloud project files.
qfieldcloud-cli package-download [OPTIONS] PROJECT_ID LOCAL_DIR
Options:
--filter TEXT Do not download the whole packaged project,
but only the files which match the glob.
--exit-on-error / --no-exit-on-error
If any packaged file downloads fails stop
downloading the rest. Default: False
package-trigger
Initiate project packaging for QField.
qfieldcloud-cli package-trigger PROJECT_ID
package-status
Check project packaging status.
qfieldcloud-cli package-status PROJECT_ID
Development
Contributions are more than welcome!
Code style
Code style done with precommit.
pip install pre-commit
# install pre-commit hook
pre-commit install
Cloning the project
One time action to clone and setup:
git clone https://github.com/opengisch/qfieldcloud-sdk-python
cd qfieldcloud-sdk-python
# install dev dependencies
python3 -m pip install pipenv
pipenv install --dev
pipenv shell
pipenv install -e . --dev
pre-commit install
To run CLI interface for development purposes execute:
python src/bin/qfieldcloud-cli
Building the package
Run:
python3 -m build
Then install on your system:
python3 -m pip install dist/qfieldcloud_sdk-dev-py3-none-any.whl --force-reinstall
Voila!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for qfieldcloud_sdk-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65384ce37c1c5e446d21fab8a224b5298834eb6a5ac75a9e34035a5f6a3192cf |
|
MD5 | 72d19b444226247899fa2a3964cc63ba |
|
BLAKE2b-256 | 3fe446f21ae19bb68112d3e6647e453afe40e05978061427214d75325663887b |