mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
To highlight TUF ngclient exceptions. Signed-off-by: Kairo de Araujo <kdearaujo@vmware.com> |
||
|---|---|---|
| .. | ||
| 1.root.json | ||
| client_example.py | ||
| README.md | ||
Python Client Example
Introduction
Python Client Example, using python-tuf.
This Python Client Example implements the following actions:
- Client Infrastructure Initialization
- Download target files from TUF Repository
Repository
This example demonstrates how to use the python-tuf to build a client
application.
The repository will use static files.
The static files are available in the python-tuf source code repository in
tests/repository_data/repository.
Run the repository using the Python3 built-in HTTP module, and keep this session running.
$ python3 -m http.server -d tests/repository_data/repository
Serving HTTP on :: port 8000 (http://[::]:8000/) ...
Client Example
The Client Example source code is available entirely in this source code repository.
How to use the Client Example:
-
Initialize the Client (optional)
$ ./client_example.py --initThis action is to create the client infrastructure properly.
This infrastructure consists in:
- Metadata repository
- Download folder for targets
- Bootstrap 1.root.json
-
Download the
file1.txtTarget file1.txt information fetched Cached target file1.txt verified Target is available in ./downloads/file1.txt -
Download a not available
file_na.txt$ ./client_example.py download file_na.txt Target file_na.txt information fetched Target file_na.txt not found -
Download again
file1.txt$ ./client_example.py download file1.txt Target file1.txt information fetched Cached target file1.txt verified Target is already available in ./downloads/file1.txt