Page 1 of 1

data download by python scripy

Posted: Wed Mar 01, 2023 9:21 am America/New_York
by joejoe03050709
what is wrong about my operation?
E:\text>python laads-data-download.py -s https://ladsweb.modaps.eosdis.nasa.gov/archive/orders/501923090/ -d .\ -t eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJBUFMgT0F1dGgyIEF1dGhlbnRpY2F0b3IiLCJpYXQiOjE2Nzc2Nzg3MDUsIm5iZiI6MTY3NzY3ODcwNSwiZXhwIjoxNjkzMjMwNzA1LCJ1aWQiOiJqb2Vqb2UwMzA1MDcwOSIsImVtYWlsX2FkZHJlc3MiOiIxMzYxMTc4NTg5QHFxLmNvbSIsInRva2VuQ3JlYXRvciI6ImpvZWpvZTAzMDUwNzA5In0.HUxRISDSBOps3jB-UKA-F0ieAi7n6NyVzggGPTDTQco
Traceback (most recent call last):
File "laads-data-download.py", line 143, in <module>
sys.exit(_main(sys.argv))
File "laads-data-download.py", line 138, in _main
return sync(args.source, args.destination, args.token)
File "laads-data-download.py", line 103, in sync
for f in files.content:
AttributeError: 'list' object has no attribute 'content'

Re: data download by python scripy

Posted: Thu Mar 02, 2023 9:53 am America/New_York
by LAADS_UserServices_M
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) ]

with
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:

with
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.