|
11 | 11 |
|
12 | 12 | import os |
13 | 13 | import tempfile |
| 14 | +import time |
14 | 15 |
|
15 | 16 | from ds3 import ds3 |
16 | 17 |
|
|
30 | 31 |
|
31 | 32 | # create a dictionary to map our retrieved objects to temporary files |
32 | 33 | # if you want to keep the retreived files on disk, this is not necessary |
33 | | -tempFiles={} |
| 34 | +tempFiles = {} |
34 | 35 |
|
35 | 36 | # while we still have chunks to retrieve |
36 | 37 | while len(chunkIds) > 0: |
37 | 38 | # get a list of the available chunks that we can get |
38 | 39 | availableChunks = client.get_job_chunks_ready_for_client_processing_spectra_s3( |
39 | | - ds3.GetJobChunksReadyForClientProcessingSpectraS3Request(bulkGetResult.result['JobId'])) |
| 40 | + ds3.GetJobChunksReadyForClientProcessingSpectraS3Request(bulkGetResult.result['JobId'])) |
40 | 41 |
|
41 | 42 | chunks = availableChunks.result['ObjectsList'] |
42 | 43 |
|
|
55 | 56 | for obj in chunk['ObjectList']: |
56 | 57 | # if we haven't create a temporary file for this object yet, create one |
57 | 58 | if obj['Name'] not in list(tempFiles.keys()): |
58 | | - tempFiles[obj['Name']]=tempfile.mkstemp() |
59 | | - |
60 | | - # get the object |
61 | | - objectStream = open(tempFiles[obj['Name']][1], "wb") |
62 | | - client.get_object(ds3.GetObjectRequest(bucketName, |
63 | | - obj['Name'], |
64 | | - objectStream, |
65 | | - offset = int(obj['Offset']), |
66 | | - job = bulkGetResult.result['JobId'])) |
| 59 | + tempFiles[obj['Name']] = tempfile.mkstemp() |
| 60 | + |
| 61 | + # get the object |
| 62 | + objectStream = open(tempFiles[obj['Name']][1], "wb") |
| 63 | + client.get_object(ds3.GetObjectRequest(bucketName, |
| 64 | + obj['Name'], |
| 65 | + objectStream, |
| 66 | + offset=int(obj['Offset']), |
| 67 | + job=bulkGetResult.result['JobId'])) |
67 | 68 |
|
68 | 69 | # iterate over the temporary files, printing out their names, then closing and and removing them |
69 | 70 | for objName in list(tempFiles.keys()): |
|
0 commit comments