Skip to content

Commit 83e8c0d

Browse files
authored
Merge pull request #1 from opengisch/no_ssl_verify
Added a global argument to skip SSL checks
2 parents fbb97d8 + 919bafc commit 83e8c0d

4 files changed

Lines changed: 30 additions & 18 deletions

File tree

.github/workflows/deploy_to_pypi.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ jobs:
2222
if: startsWith(github.ref, 'refs/tags/v')
2323
run: >-
2424
sed -i "s/= dev/= ${{ steps.v.outputs.VERSION }}/" setup.cfg
25-
25+
2626
- name: Install pypa/build
2727
run: >-
2828
python -m
2929
pip install
3030
build
3131
--user
32-
32+
3333
- name: Build a binary wheel and a source tarball
3434
run: >-
3535
python -m
@@ -38,7 +38,7 @@ jobs:
3838
--wheel
3939
--outdir dist/
4040
.
41-
41+
4242
- name: 🚀 Upload Release Asset
4343
if: startsWith(github.ref, 'refs/tags/v')
4444
uses: actions/upload-release-asset@v1

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,16 @@ qfieldcloud-cli --json list-projects
5252
### Global options overview
5353

5454
```
55-
-U, --url TEXT URL to the QFieldCloud API endpoint. If not passed,
56-
gets the value from QFIELDCLOUD_URL environment
57-
variable. Default: https://app.qfield.cloud/api/v1/
58-
59-
-u, --username TEXT Username or email.
55+
-U, --url TEXT URL to the QFieldCloud API endpoint. If not
56+
passed, gets the value from QFIELDCLOUD_URL
57+
environment variable. Default:
58+
https://app.qfield.cloud/api/v1/
59+
-u, --username TEXT Username or email.
6060
-p, --password TEXT
61-
-t, --token TEXT Session token.
62-
--json / --human Output the result as newline formatted json.
63-
--help Show this message and exit.
61+
-t, --token TEXT Session token.
62+
--json / --human Output the result as newline formatted json. Default: False
63+
--verify-ssl / --no-verify-ssl Verify SSL. Default: True
64+
--help Show this message and exit.
6465
```
6566

6667
Environment variables can be used instead of passing some common global options.
@@ -95,7 +96,7 @@ List QFieldCloud projects.
9596
qfieldcloud-cli list-projects [OPTIONS]
9697
9798
Options:
98-
--include-public / --no-public Includes the public project in the list.
99+
--include-public / --no-public Includes the public project in the list. Default: False
99100
```
100101

101102
#### list-files
@@ -119,7 +120,7 @@ Options:
119120
120121
--exit-on-error / --no-exit-on-error
121122
If any project file download fails stop
122-
downloading the rest.
123+
downloading the rest. Default: False
123124
```
124125

125126
## Development

src/bin/qfieldcloud-cli

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@ class OrderedGroup(click.Group):
5050
"-t", "--token", envvar="QFIELDCLOUD_TOKEN", type=str, help="Session token."
5151
)
5252
@click.option(
53-
"--json/--human", "format_json", help="Output the result as newline formatted json."
53+
"--json/--human",
54+
"format_json",
55+
help="Output the result as newline formatted json. Default: False",
56+
)
57+
@click.option(
58+
"--verify-ssl/--no-verify-ssl",
59+
"verify_ssl",
60+
default=True,
61+
help="Verify SSL. Default: True",
5462
)
5563
@click.pass_context
5664
def cli(
@@ -60,6 +68,7 @@ def cli(
6068
password: str,
6169
token: str,
6270
format_json: bool,
71+
verify_ssl: bool,
6372
):
6473
"""The official QFieldCloud CLI tool.
6574
@@ -70,7 +79,7 @@ def cli(
7079
qfieldcloud-cli -u user -p pass -U https://localhost/api/v1/ list-projects
7180
"""
7281
ctx.ensure_object(dict)
73-
ctx.obj["client"] = sdk.Client(url)
82+
ctx.obj["client"] = sdk.Client(url, verify_ssl)
7483
ctx.obj["format_json"] = format_json
7584
ctx.obj["token"] = token
7685

@@ -105,7 +114,7 @@ def login(ctx, username, password) -> None:
105114
@click.option(
106115
"--include-public/--no-public",
107116
default=False,
108-
help="Includes the public project in the list.",
117+
help="Includes the public project in the list. Default: False",
109118
)
110119
@click.pass_context
111120
def list_projects(ctx, username, include_public):
@@ -153,7 +162,7 @@ def list_files(ctx, project_id):
153162
)
154163
@click.option(
155164
"--exit-on-error/--no-exit-on-error",
156-
help="If any project file download fails stop downloading the rest.",
165+
help="If any project file download fails stop downloading the rest. Default: False",
157166
)
158167
@click.pass_context
159168
def download_files(ctx, project_id, local_dir, subdir, exit_on_error):

src/qfieldcloud_sdk/sdk.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ class DownloadStatus(Enum):
1414

1515

1616
class Client:
17-
def __init__(self, url: Optional[str]) -> None:
17+
def __init__(self, url: Optional[str], verify_ssl: bool = True) -> None:
1818
"""Prepares a new client. If the `url` is not provided, uses `QFIELDCLOUD_URL` from the environment."""
1919
self.url = url or os.environ.get("QFIELDCLOUD_URL", "")
2020
self.token = None
21+
self.verify_ssl = verify_ssl
2122

2223
if not self.url:
2324
raise Exception(
@@ -157,6 +158,7 @@ def _request(
157158
headers=headers_copy,
158159
files=files,
159160
stream=stream,
161+
verify=self.verify_ssl,
160162
# redirects from POST requests automagically turn into GET requests, so better forbid redirects
161163
allow_redirects=(method != "POST"),
162164
)

0 commit comments

Comments
 (0)