-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating to include NetRC.jl for setup of package
- Loading branch information
1 parent
8bf28db
commit 94135c4
Showing
4 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
function setup(; | ||
login :: AbstractString = "", | ||
password :: AbstractString = "", | ||
overwrite :: Bool = false | ||
) | ||
|
||
fdodsrc = joinpath(homedir(),".dodsrc") | ||
if !isfile(fdodsrc) | ||
@info "$(modulelog()) - Setting up .dodsrc file for NASA OPeNDAP servers to point at cookie and .netrc directories ..." | ||
open(fdodsrc,"w") do f | ||
write(f,"HTTP.COOKIEJAR=$(joinpath(homedir(),".urs_cookies"))") | ||
write(f,"HTTP.NETRC=$(joinpath(homedir(),".netrc"))") | ||
end | ||
else | ||
if overwrite | ||
@warn "$(modulelog()) - .dodsrc file exists at $fdodsrc, overwriting again" | ||
open(fdodsrc,"w") do f | ||
write(f,"HTTP.COOKIEJAR=$(joinpath(homedir(),".urs_cookies"))") | ||
write(f,"HTTP.NETRC=$(joinpath(homedir(),".netrc"))") | ||
end | ||
else | ||
@info "$(modulelog()) - .dodsrc file exists at $fdodsrc" | ||
end | ||
end | ||
|
||
if !netrc_check() | ||
if login == "" && password == "" | ||
@warn "$(modulelog()) - .netrc file does not exist at $(netrc_file()), you need to setup the .netrc file in order for NASAPrecipitation.jl to work" | ||
end | ||
end | ||
|
||
if netrc_check() && !netrc_checkmachine(netrc_read(logging=false),machine="urs.earthdata.nasa.gov") | ||
if login == "" && password == "" | ||
@warn "$(modulelog()) - No existing machine urs.earthdata.nasa.gov in .netrc file, please setup login and password for this machine for NASAPrecipitation.jl to work" | ||
end | ||
end | ||
|
||
if login != "" && password != "" | ||
@info "$(modulelog()) - Setting up .netrc file containing login and password information for NASA OPeNDAP servers ..." | ||
netrc = netrc_read() | ||
if netrc_check() && netrc_checkmachine(netrc,machine="urs.earthdata.nasa.gov") | ||
netrc_modify!(netrc,machine="urs.earthdata.nasa.gov",login=login,password=password) | ||
else | ||
netrc_add!(netrc,machine="urs.earthdata.nasa.gov",login=login,password=password) | ||
end | ||
netrc_write(netrc) | ||
end | ||
|
||
end |
94135c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
Release Notes:
94135c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/63040
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: