From 3574361f2ef0b7fc79d3b64560c54e76cd6ab5c9 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Fri, 17 Nov 2023 14:33:32 +0300 Subject: [PATCH] [#104] s3local: Use default HTTP client instead of requests `requests` lib is not default, so it can be unavailable. Signed-off-by: Dmitrii Stepanov --- scenarios/preset/resolve_containers_in_preset.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scenarios/preset/resolve_containers_in_preset.py b/scenarios/preset/resolve_containers_in_preset.py index 78e292c..086c7ec 100755 --- a/scenarios/preset/resolve_containers_in_preset.py +++ b/scenarios/preset/resolve_containers_in_preset.py @@ -2,7 +2,8 @@ import argparse import json -import requests +import http.client +import ssl parser = argparse.ArgumentParser() parser.add_argument('--endpoint', help='Endpoint of the S3 gateway') @@ -16,10 +17,13 @@ def main(): preset = json.loads(preset_text) + conn = http.client.HTTPSConnection(args.endpoint, context = ssl._create_unverified_context()) containers = [] for bucket in preset.get('buckets'): - resp = requests.head(f'{args.endpoint}/{bucket}', verify=False) - containers.append(resp.headers['X-Container-Id']) + conn.request("HEAD", f'/{bucket}') + response = conn.getresponse() + containers.append(response.getheader('X-Container-Id')) + response.read() preset['containers'] = containers with open(args.preset_file, 'w+') as f: