_download_and_extract_in_various_ways(example_url_2, 'ubuntu') _download_and_extract_in_various_ways(example_url_1, 'raspbian') _try_extracting(prefix + '_tar_downloaded_with_curl.xz') _try_extracting(prefix + '_tar_downloaded_with_wget.xz') _try_extracting(prefix + '_tar_downloaded_with_requests.xz') With open(prefix + '_tar_downloaded_with_requests.xz', 'wb') as f:į.write(standard_download_ntent) Standard_download_request = requests.get(url) _try_extracting(prefix + '_tar_downloaded_with_copyfileobj.xz') With open(prefix + '_tar_downloaded_with_copyfileobj.xz', 'wb') as f:Ĭopyfileobj(copyfileobj_download_request.raw, f) # This would be `copyfileobj(tq, f)` if fully wrapped # Here I would insert `tqdm.wrapattr(copyfileobj_download_request.raw, "read", total=content_length) as tq:` ![]() Print('Downloading xz via copyfileobj from requests')Ĭopyfileobj_download_request = requests.get(url, stream=True)Ĭontent_length = int(copyfileobj_download_('content-length'))Ĭopyfileobj_download_ = partial(copyfileobj_download_, decode_content=True) Print('Also attempting use of command-line `ar` tool')ĭef _download_and_extract_in_various_ways(url, prefix): Print('Falling back to extracting via command-line `tar` tool') With tarfile.open(filename, mode='r:xz') as tf: ![]() See the sample code below where I try multiple approaches both for downloading and for extracting, from two different tars (just to check that I'm not testing against an actually malformed tar) - all of them fail: I cannot figure out how to download and extract an. Apologies for a really basic question, but I'm at my wits' end here.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |