landsatxplore icon indicating copy to clipboard operation
landsatxplore copied to clipboard

Download does not seem to work

Open henrykironde opened this issue 2 years ago • 12 comments

landsatxplore download -u $username -p $password LC09_L1TP_035038_20220707_20220707_02_T1

It looks like the login is not working when downloading but works fine when searching.

Traceback (most recent call last):
  File "/opt/miniconda3/envs/retriever3.8/bin/landsatxplore", line 8, in <module>
    sys.exit(cli())
  File "/opt/miniconda3/envs/retriever3.8/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/opt/miniconda3/envs/retriever3.8/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/opt/miniconda3/envs/retriever3.8/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/miniconda3/envs/retriever3.8/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/miniconda3/envs/retriever3.8/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/opt/miniconda3/envs/retriever3.8/lib/python3.8/site-packages/landsatxplore/cli.py", line 157, in download
    ee = EarthExplorer(username, password)
  File "/opt/miniconda3/envs/retriever3.8/lib/python3.8/site-packages/landsatxplore/earthexplorer.py", line 55, in __init__
    self.login(username, password)
  File "/opt/miniconda3/envs/retriever3.8/lib/python3.8/site-packages/landsatxplore/earthexplorer.py", line 66, in login
    csrf, ncform = _get_tokens(rsp.text)
  File "/opt/miniconda3/envs/retriever3.8/lib/python3.8/site-packages/landsatxplore/earthexplorer.py", line 39, in _get_tokens
    ncform = re.findall(r'name="__ncforminfo" value="(.+?)"', body)[0]
IndexError: list index out of range

henrykironde avatar Jul 14 '22 18:07 henrykironde

Also I have just noticed this, There is a scheduled system outage for Thursday, July 14, 2022, from 6:00 PM CDT to 8:00 PM CDT. Downloads may be intermittent during this time.

from the website https://earthexplorer.usgs.gov

henrykironde avatar Jul 14 '22 19:07 henrykironde

Same issue here! Any chance they changed something during the system maintenance?

jeronimoluza avatar Jul 21 '22 17:07 jeronimoluza

I believe so. They always change the platform, and it always results in backwards compatibility issues. This is true for the API they provide,

the usgs-machine-to-machine-API, which now fails with the same error.

INPUT_PARAMETER_INVALID -  Scene list does not contain any valid scenes

henrykironde avatar Jul 21 '22 22:07 henrykironde

An update on this: there are some changes on the scene list at https://earthexplorer.usgs.gov/order/index/. You need to sign in. It looks like you will need to order them from the website. The Machine-to-Machine (M2M) API doesn't seem updated. Hope it's not more manual work than it is currently.

henrykironde avatar Jul 21 '22 23:07 henrykironde

hi,Did you solve the problem?

qk1997 avatar Aug 15 '22 02:08 qk1997

hi,Did you solve the problem?

ghost avatar Aug 17 '22 08:08 ghost

Not yet solved

henrykironde avatar Aug 22 '22 13:08 henrykironde

This is a crucial problem that makes this beautiful tool literally unusable. Any suggestion by the developer @yannforget?

ahsouri avatar Sep 13 '22 19:09 ahsouri

I have the same problem.

legendjslc avatar Oct 31 '22 09:10 legendjslc

I think just remove ncform in function get_token, it will work. def _get_tokens(body): """Getcsrf_tokenand__ncforminfo.""" csrf = re.findall(r'name="csrf" value="(.+?)"', body)[0] ncform = re.findall(r'name="__ncforminfo" value="(.+?)"', body)[0]

legendjslc avatar Oct 31 '22 09:10 legendjslc

I think just remove ncform in function get_token, it will work. def _get_tokens(body): """Getcsrf_tokenand__ncforminfo.""" csrf = re.findall(r'name="csrf" value="(.+?)"', body)[0] ncform = re.findall(r'name="__ncforminfo" value="(.+?)"', body)[0]

yes it works!

just change function _get_tokens to:

def _get_tokens(body):
    """Get `csrf_token` and `__ncforminfo`."""
    csrf = re.findall(r'name="csrf" value="(.+?)"', body)[0]
    # ncform = re.findall(r'name="__ncforminfo" value="(.+?)"', body)[0]

    if not csrf:
        raise EarthExplorerError("EE: login failed (csrf token not found).")
    # if not ncform:
    #     raise EarthExplorerError("EE: login failed (ncforminfo not found).")

    ncform = None
    return csrf, ncform

now I am able to download successfully.

but why is this?

haozhen315 avatar Nov 04 '22 13:11 haozhen315

Hi, I encountered the same issue today. It seems this issue is fixed by @jcintasr PR https://github.com/yannforget/landsatxplore/pull/75.

tvoirand avatar Nov 25 '22 15:11 tvoirand