Skip to content

Commit a0deac7

Browse files
committed
only download immutable files
1 parent 82a8926 commit a0deac7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

examples/01.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
# look for experiments that are timestamped
4141
for exp in experimentsApi.read_experiments(extended=f'timestamped:yes timestamped_at:>{date_from}'):
4242
for upload in uploadsApi.read_uploads('experiments', exp.id):
43-
# get and save binary file
44-
now = datetime.datetime.now()
45-
with open(f'{exp.id}-{exp.elabid}-{now.strftime("%Y-%m-%d_%H-%M-%S")}-timestamp-archive.zip', 'wb') as zipfile:
46-
# the _preload_content flag is necessary so the api_client doesn't try and deserialize the response
47-
zipfile.write(uploadsApi.read_upload('experiments', exp.id, upload.id, format='binary', _preload_content=False).data)
43+
# we only look at immutable uploads => timestamp archives
44+
if upload.immutable:
45+
now = datetime.datetime.now()
46+
# get and save binary file
47+
with open(f'{exp.id}-{exp.elabid}-{now.strftime("%Y-%m-%d_%H-%M-%S")}-timestamp-archive.zip', 'wb') as zipfile:
48+
# the _preload_content flag is necessary so the api_client doesn't try and deserialize the response
49+
zipfile.write(uploadsApi.read_upload('experiments', exp.id, upload.id, format='binary', _preload_content=False).data)
4850

0 commit comments

Comments
 (0)