python-tuf/examples/client_example
Kairo de Araujo 9b4fcdb564 Added lint, rst to md, output
- Added the lint to examples
- README format moved from Restructuredtext to Markdown
- Removed the [INFO] and [ERROR] from output, to avoid confundint with
  logging structure

Signed-off-by: Kairo de Araujo <kdearaujo@vmware.com>
2021-12-03 19:58:33 +01:00
..
1.root.json WIP: TUF Python Client Example/Tutorial 2021-12-03 19:57:53 +01:00
client_example.py Added lint, rst to md, output 2021-12-03 19:58:33 +01:00
README.md Added lint, rst to md, output 2021-12-03 19:58:33 +01:00

Python Client Example

Introduction

Python Client Example, using python-tuf.

For information about installing python-tuf, please refer to the Installation documentation.

Preparing

To have the example working in your machine, clone the python-tuf in your system.

$ git clone git@github.com:theupdateframework/python-tuf.git

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:

  1. Initialize the Client

    $ ./client_example.py --init
    

    This action is to create the client infrastructure properly.

    This infrastructure consists in:

    • Metadata repository
    • Download folder for targets
    • Bootstrap 1.root.json
  2. Download the file1.txt

    $ ./client_example.py download file1.txt
    Top-level metadata is refreshed.
    Target info gotten.
    File downloaded available in ./downloads/file2.txt.
    
  3. Download a not available file_na.txt

    $ ./client_example.py download file_na.txt
    Top-level metadata is refreshed.
    Target info gotten.
    Target file not found.
    
  4. Download again file1.txt

    $ ./client_example.py download file1.txt
    Top-level metadata is refreshed.
    Target info gotten.
    File is already available in ./downloads/file1.txt.