data download by python scripy

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
Posts: 7
Joined: Wed Mar 01, 2023 8:17 am America/New_York
Answers: 0

data download by python scripy

by joejoe03050709 » Wed Mar 01, 2023 9:21 am America/New_York

what is wrong about my operation?
E:\text>python -s -d .\ -t eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJBUFMgT0F1dGgyIEF1dGhlbnRpY2F0b3IiLCJpYXQiOjE2Nzc2Nzg3MDUsIm5iZiI6MTY3NzY3ODcwNSwiZXhwIjoxNjkzMjMwNzA1LCJ1aWQiOiJqb2Vqb2UwMzA1MDcwOSIsImVtYWlsX2FkZHJlc3MiOiIxMzYxMTc4NTg5QHFxLmNvbSIsInRva2VuQ3JlYXRvciI6ImpvZWpvZTAzMDUwNzA5In0.HUxRISDSBOps3jB-UKA-F0ieAi7n6NyVzggGPTDTQco
Traceback (most recent call last):
File "", line 143, in <module>
File "", line 138, in _main
return sync(args.source, args.destination, args.token)
File "", line 103, in sync
for f in files.content:
AttributeError: 'list' object has no attribute 'content'


User Services
User Services
Posts: 206
Joined: Mon Sep 30, 2019 8:33 am America/New_York
Answers: 1

Re: data download by python scripy

by LAADS_UserServices_M » Thu Mar 02, 2023 9:53 am America/New_York

We have a fix for this script that we are working on, but have not yet deployed to production. But you can make the following changes to fix it:

Replace line 97:

files = [ f for f in csv.DictReader(StringIO(geturl('%s.csv' % src, tok)), skipinitialspace=True) ]

files = {}

files['content'] = [ f for f in csv.DictReader(StringIO(geturl('%s.csv' % src, tok)), skipinitialspace=True) ]

and also replace line 107 (108 if above change is made)

for f in files.content:

for f in files['content']:

Finally, if you are using an Earthdata Login (EDL) token, you need to change the curl command in line 72 to

args = ['curl', '--fail', '-sS', '-L', '-b session', '--get', url]

The “-b session” option is necessary because Earthdata Login token causes several redirects for authentication, and “-b session” turns on the cookie handler to forward session cookies, which Earthdata needs as part of the oauth protocol.
LAADS User Services

To receive news from LAADS DAAC direct to your inbox, email with “subscribe” in the subject line.

Post Reply