Skip to content

Commit d34aad4

Browse files
committed
examples: Use urllib3 in client example
This is in order to not clash with #2762. Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent 228850e commit d34aad4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: examples/client/client

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import traceback
1212
from hashlib import sha256
1313
from pathlib import Path
1414

15-
import requests
15+
import urllib3
1616

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

44-
data = requests.get(f"{base_url}/metadata/1.root.json").content
44+
response = urllib3.request("GET", f"{base_url}/metadata/1.root.json")
45+
if response.status != 200:
46+
print(f"Failed to download initial root {base_url}/metadata/1.root.json")
47+
return False
48+
4549
Updater(
4650
metadata_dir=metadata_dir,
4751
metadata_base_url=f"{base_url}/metadata/",
4852
target_base_url=f"{base_url}/targets/",
4953
target_dir=DOWNLOAD_DIR,
50-
bootstrap=data,
54+
bootstrap=response.data,
5155
)
5256

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

0 commit comments

Comments
 (0)