Skip to content

Commit

Permalink
Update earthaccess/auth.py
Browse files Browse the repository at this point in the history
Co-authored-by: Joseph H Kennedy <[email protected]>
  • Loading branch information
battistowx and jhkennedy authored Mar 28, 2024
1 parent 467cf36 commit dcb2adb
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions earthaccess/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,18 +372,22 @@ def _persist_user_credentials(self, username: str, password: str) -> bool:
my_netrc = Netrc(str(netrc_path))
my_netrc["urs.earthdata.nasa.gov"] = {"login": username, "password": password}
my_netrc.save()

# Create and write .urs_cookies file
urs_cookies_file = Path.home() / ".urs_cookies"
urs_cookies_file.write_text("")
urs_cookies_path = Path.home() / ".urs_cookies"
if not usr_cookies_path.exists():
urs_cookies_path.write_text("")

# Create and write to .dodsrc file
dodsrc_file = Path.home() / ".dodsrc"
dodsrc_contents = f"HTTP.COOKIEJAR={urs_cookies_file}\nHTTP.NETRC={netrc_path}"
dodsrc_file.write_text(dodsrc_contents)

if platform.system() == "Windows":
shutil.copy2(dodsrc_file, Path.cwd())
dodsrc_path = Path.home() / ".dodsrc"
if not dodsrc_path.exists():
dodsrc_contents = f"HTTP.COOKIEJAR={urs_cookies_file}\nHTTP.NETRC={netrc_path}"
dodsrc_path.write_text(dodsrc_contents)


if platform.system() == "Windows":

Check failure on line 386 in earthaccess/auth.py

View workflow job for this annotation

GitHub Actions / check-with-ruff

Ruff (E999)

earthaccess/auth.py:386:8: E999 SyntaxError: unindent does not match any outer indentation level
local_dodsrc_path = Path.cwd() / dodsrc_path.name
if not local_dodsrc_path.exists():
shutil.copy2(dodsrc_path, local_dodsrc_path)


return True

Expand Down

0 comments on commit dcb2adb

Please sign in to comment.