Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dodsrc and urs cookies files when creating netrc #492

Merged
merged 10 commits into from
Mar 28, 2024

Conversation

battistowx
Copy link
Collaborator

@battistowx battistowx commented Mar 14, 2024

This PR includes code that will also create a .urs_cookies and .dodsrc files when users persist their credentials to a .netrc file, and will copy the .dodsrc file based on the user operating system. It is based on code from this how-to, but adapted here to use pathlib: https://disc.gsfc.nasa.gov/information/howto?keywords=prerequisite&title=How%20to%20Generate%20Earthdata%20Prerequisite%20Files

I have tested this with poetry on both Linux/Windows, and it works great!


📚 Documentation preview 📚: https://earthaccess--492.org.readthedocs.build/en/492/

Copy link
Collaborator

@jhkennedy jhkennedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 looks pretty good; I can see the desire for the .urs_cookies and .dodsrc (OpenDAP) files.

As written, code will clobber (overwrite) any existing .urs_cookies and .dodsrc files, which I don't think is desirable, but I'll have to think more about how best to handle existing versions of these files...

I also left a couple of minor suggestions.

earthaccess/auth.py Outdated Show resolved Hide resolved
earthaccess/auth.py Outdated Show resolved Hide resolved
battistowx and others added 2 commits March 18, 2024 14:28
Co-authored-by: Joseph H Kennedy <[email protected]>
Co-authored-by: Joseph H Kennedy <[email protected]>
@battistowx
Copy link
Collaborator Author

Thank you for the reviewing and the suggestions @jhkennedy ! I added the suggested commits here. In terms of overwriting the existing dodsrc file, for Windows environments, you need to have additional copies of the dodsrc file in each working directory even if it exists in the root user folder. I'm not sure how long the information in the urs_cookies file is valid for, but I have not had any issues when overwriting it repeatedly, and this file is necessary for those who want to use wget/curl, so I have included it here for convenience.

Copy link
Collaborator

@jhkennedy jhkennedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@battistowx circling back to this.

I agree overwriting the .urs_cookies path is not likely a concern, but I don't think there's a benefit to doing so.

For ~/.dodsrc, I think there's actually a decent amount of risk because:

  1. there's a lot of configuration that can go into the ~/.dodsrc, e.g.:
  2. Users may want to specify alternate cookie and netrc files, e.g., Define user .netrc directory [Feature request] #480

How about we only create them if they don't exist?

earthaccess/auth.py Outdated Show resolved Hide resolved
Co-authored-by: Joseph H Kennedy <[email protected]>
@jhkennedy
Copy link
Collaborator

Woops! bad indent in my suggestion

@battistowx
Copy link
Collaborator Author

Woops! bad indent in my suggestion

No worries! Fixed them.

Copy link
Collaborator

@jhkennedy jhkennedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! :shipit:

@battistowx battistowx merged commit ff0c59a into main Mar 28, 2024
13 checks passed
@battistowx battistowx deleted the add_dodsrc_and_urs_cookies branch May 30, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants