Python >= 3.6
Using pip
pip install -U git+https://github.com/d3b-center/d3b-utils-python.git@latest-release
from d3b_utils.requests_retry import Session
response = Session().get("https://www.foo.com")
The python requests library doesn't retry on connection errors unless you add your own custom transport adapter. Many connection errors are intermittent and self-correct, so we should definitely retry them.
Don't use the requests library directly. Use this instead.
from d3b_utils.s3_contents import fetch_bucket_obj_info
contents = fetch_bucket_obj_info("my_bucket")
from d3b_utils.s3_contents import fetch_bucket_obj_info
contents = fetch_bucket_obj_info(
"my_bucket",
search_prefixes=["source/pics/", "source/uploads/"]
)
from d3b_utils.s3_contents import fetch_bucket_obj_info
contents = fetch_bucket_obj_info(
"my_bucket",
drop_folders=True,
)
from d3b_utils.s3_contents import fetch_bucket_obj_info
contents = fetch_bucket_obj_info(
"my_bucket",
search_prefixes="source/pics/",
drop_folders=True,
output_filename="my_bucket_contents.tsv"
)
from d3b_utils.s3_contents import fetch_bucket_obj_info
contents = fetch_bucket_obj_info(
"my_bucket",
profile="user1"
)
from d3b_utils.s3_contents import fetch_bucket_obj_info
contents = fetch_bucket_obj_info(
"my_bucket",
all_versions=True
)
from d3b_utils.s3_contents import fetch_obj_list_info
contents = fetch_obj_list_info(
["s3://bucket1/path1", "bucket2/path2"],
profile="user1",
all_versions=False
)