You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello and thanks for your immensely useful library!
I've found .get_file_contents() to be especially useful. Do you have any plans to make a way to download non-string type data. (i.e. contents for tarfiles?)
I'm a novice, but have tried tweaking .get_file_contents() to work on tarfiles.
The only difference with my code (at end of this messsage) is that
it makes a request (r) and returns r.raw
whereas your code, .get_file_contents():
returns r.text
I find that my code successfully writes .tar.gz archives most of the time, but is also prone to silent failure (e.g. occasionally writes archives that are corrupted)--for reasons that I do not understand. If you have any advice on how to download tar.gz files from Clarity, I would greatly appreciate it!
Hello and thanks for your immensely useful library!
I've found .get_file_contents() to be especially useful. Do you have any plans to make a way to download non-string type data. (i.e. contents for tarfiles?)
I'm a novice, but have tried tweaking .get_file_contents() to work on tarfiles.
The only difference with my code (at end of this messsage) is that
whereas your code, .get_file_contents():
I find that my code successfully writes .tar.gz archives most of the time, but is also prone to silent failure (e.g. occasionally writes archives that are corrupted)--for reasons that I do not understand. If you have any advice on how to download tar.gz files from Clarity, I would greatly appreciate it!
~Greg
The code:
from urllib.parse import urljoin
import tarfile
PATH_tgz = "example.tar.gz"
DIR_download = "./directory/"
make a request
r = API.request_session.get(URL, auth=(API.username, API.password), timeout=15, stream=True)
API.validate_response(r)
Write tgz and extract it
with open(PATH_tgz, 'wb') as f: f.write(r.raw.read())
FILE_tgz = tarfile.open(PATH_tgz)
FILE_tgz.extractall(DIR_download)
FILE_tgz.close()
The text was updated successfully, but these errors were encountered: