Skip to content

Commit

Permalink
examples: Use urllib3 in client example
Browse files Browse the repository at this point in the history
This is in order to not clash with theupdateframework#2762.

Signed-off-by: Jussi Kukkonen <[email protected]>
  • Loading branch information
jku committed Jan 27, 2025
1 parent 10703ac commit c145196
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions examples/client/client
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import traceback
from hashlib import sha256
from pathlib import Path

import requests
import urllib3

from tuf.api.exceptions import DownloadError, RepositoryError
from tuf.ngclient import Updater
Expand Down Expand Up @@ -41,13 +41,17 @@ def init_tofu(base_url: str) -> bool:
if not os.path.isdir(metadata_dir):
os.makedirs(metadata_dir)

data = requests.get(f"{base_url}/metadata/1.root.json").content
response = urllib3.request("GET", f"{base_url}/metadata/1.root.json")
if response.status != 200:
print(f"Failed to download initial root {base_url}/metadata/1.root.json")
return False

Updater(
metadata_dir=metadata_dir,
metadata_base_url=f"{base_url}/metadata/",
target_base_url=f"{base_url}/targets/",
target_dir=DOWNLOAD_DIR,
bootstrap=data,
bootstrap=response.data,
)

print(f"Trust-on-First-Use: Initialized new root in {metadata_dir}")
Expand Down

0 comments on commit c145196

Please sign in to comment.