Skip to content

Commit 4fd5012

Browse files
committed
PEP8
1 parent 8c850e8 commit 4fd5012

2 files changed

Lines changed: 35 additions & 25 deletions

File tree

setup.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,5 @@
3131
package_dir={"": "src"},
3232
packages=setuptools.find_packages(where="src"),
3333
python_requires=">=3.6",
34-
entry_points={
35-
"console_scripts": [
36-
"qfieldcloud-cli = bin.qfieldcloud_cli:cli"
37-
]
38-
},
34+
entry_points={"console_scripts": ["qfieldcloud-cli = bin.qfieldcloud_cli:cli"]},
3935
)

src/bin/qfieldcloud_cli.py

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ class OutputFormat(Enum):
2121
def print_json(data):
2222
print(json.dumps(data, sort_keys=True, indent=2))
2323

24+
2425
def log(*msgs):
2526
print(*msgs, file=sys.stderr)
2627

28+
2729
class OrderedGroup(click.Group):
2830
def __init__(self, name=None, commands=None, **attrs):
2931
super(OrderedGroup, self).__init__(name, commands, **attrs)
@@ -86,26 +88,26 @@ def cli(
8688
):
8789
"""The official QFieldCloud CLI tool. Allows interaction with the QFieldCloud server API.
8890
89-
Environment:
91+
Environment:
9092
91-
Environment variables can be used instead of passing some common global options.
93+
Environment variables can be used instead of passing some common global options.
9294
93-
QFIELDCLOUD_API - QFieldCloud API endpoint URL
95+
QFIELDCLOUD_API - QFieldCloud API endpoint URL
9496
95-
QFIELDCLOUD_USERNAME - QFieldCloud username or email. Requires `QFIELDCLOUD_PASSWORD` to be set.
97+
QFIELDCLOUD_USERNAME - QFieldCloud username or email. Requires `QFIELDCLOUD_PASSWORD` to be set.
9698
97-
QFIELDCLOUD_PASSWORD - Password. Requires `QFIELDCLOUD_USERNAME` to be set.
99+
QFIELDCLOUD_PASSWORD - Password. Requires `QFIELDCLOUD_USERNAME` to be set.
98100
99-
QFIELDCLOUD_TOKEN - Token that can be used instead of passing username and password. It can be obtained by running `qfieldcloud-cli login`.
101+
QFIELDCLOUD_TOKEN - Token that can be used instead of passing username and password. It can be obtained by running `qfieldcloud-cli login`.
100102
101-
QFIELDCLOUD_VERIFY_SSL - When set to `0` has the same effect as passing `--no-verify-ssl`.
103+
QFIELDCLOUD_VERIFY_SSL - When set to `0` has the same effect as passing `--no-verify-ssl`.
102104
103105
104-
Examples:
106+
Examples:
105107
106-
qfieldcloud-cli login user pass
108+
qfieldcloud-cli login user pass
107109
108-
qfieldcloud-cli -u user -p pass -U https://localhost/api/v1/ list-projects
110+
qfieldcloud-cli -u user -p pass -U https://localhost/api/v1/ list-projects
109111
"""
110112
ctx.ensure_object(dict)
111113
ctx.obj["client"] = sdk.Client(url, verify_ssl, token=token)
@@ -135,7 +137,7 @@ def login(ctx, username, password) -> None:
135137
"Put the token in your in the environment using the following code, "
136138
"so you do not need to write your username and password again:"
137139
)
138-
if platform.system() == 'Windows':
140+
if platform.system() == "Windows":
139141
log(f'set QFIELDCLOUD_TOKEN={user_data["token"]}')
140142
else:
141143
log(f'export QFIELDCLOUD_TOKEN="{user_data["token"]}"')
@@ -146,7 +148,7 @@ def login(ctx, username, password) -> None:
146148
def logout(ctx):
147149
"""Logout and expire the token."""
148150

149-
log(f'Log out…')
151+
log(f"Log out…")
150152

151153
payload = ctx.obj["client"].logout()
152154

@@ -206,7 +208,11 @@ def list_files(ctx, project_id):
206208

207209
@cli.command()
208210
@click.argument("name")
209-
@click.option("--owner", "owner", help="Owner of the project. If omitted, the current user is the owner.")
211+
@click.option(
212+
"--owner",
213+
"owner",
214+
help="Owner of the project. If omitted, the current user is the owner.",
215+
)
210216
@click.option("--description", "description", help="Description of the project.")
211217
@click.option(
212218
"--is-public/--is-private", "is_public", help="Mark the project as public."
@@ -321,9 +327,7 @@ def download_files(ctx, project_id, local_dir, filter_glob, throw_on_error):
321327
log(f"Downloaded {count} file(s).")
322328
else:
323329
if filter_glob:
324-
log(
325-
f"No files to download for project {project_id} at {filter_glob}"
326-
)
330+
log(f"No files to download for project {project_id} at {filter_glob}")
327331
else:
328332
log(f"No files to download for project {project_id}")
329333

@@ -346,9 +350,15 @@ def delete_files(ctx, project_id, paths, throw_on_error):
346350
if ctx.obj["format_json"]:
347351
print_json(paths_result)
348352

353+
349354
@cli.command()
350355
@click.argument("project_id")
351-
@click.option("--type", "job_type", type=sdk.JobTypes, help="Job type. One of package, delta_apply or process_projectfile.")
356+
@click.option(
357+
"--type",
358+
"job_type",
359+
type=sdk.JobTypes,
360+
help="Job type. One of package, delta_apply or process_projectfile.",
361+
)
352362
@click.pass_context
353363
def list_jobs(ctx, project_id, job_type):
354364
"""List project jobs."""
@@ -361,7 +371,9 @@ def list_jobs(ctx, project_id, job_type):
361371
print_json(jobs)
362372
else:
363373
for job in jobs:
364-
log(f'Job "{job["id"]}" of project "{project_id}" is of type "{job["type"]}" and has status "{job["status"]}".')
374+
log(
375+
f'Job "{job["id"]}" of project "{project_id}" is of type "{job["type"]}" and has status "{job["status"]}".'
376+
)
365377

366378

367379
@cli.command()
@@ -383,7 +395,9 @@ def job_trigger(ctx, project_id, job_type, force):
383395
if ctx.obj["format_json"]:
384396
print_json(status)
385397
else:
386-
log(f'Job of type "{job_type}" triggered for project "{project_id}": {status["id"]}')
398+
log(
399+
f'Job of type "{job_type}" triggered for project "{project_id}": {status["id"]}'
400+
)
387401

388402

389403
@cli.command()
@@ -417,7 +431,7 @@ def package_latest(ctx, project_id):
417431
else:
418432
log(f'Packaging status for {project_id}: {status["status"]}')
419433
if status["layers"] is None:
420-
if status["status"] == 'failed':
434+
if status["status"] == "failed":
421435
log("Packaging have never been triggered on this project. Please run:")
422436
log(f"qfieldcloud-cli job-trigger {project_id} package")
423437
return

0 commit comments

Comments
 (0)