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

non interactive ww3_from_ftp.sh #603

Merged
merged 5 commits into from
Feb 9, 2022

Conversation

mickaelaccensi
Copy link
Collaborator

@mickaelaccensi mickaelaccensi commented Feb 8, 2022

Pull Request Summary

change default behavior to automatically download tar files and detect main directory
add options :
-h : print usage
-i : interactive mode
-k : keep tar files

add download option --no-check-certificate

Description

solve issue #578
the new way to use it is to add arguments in the command line :
cd WW3/model/bin/ww3_from_ftp.sh

Issue(s) addressed

fixes #578

Commit Message

non interactive ww3_from_ftp.sh

Check list

Testing

  • How were these changes tested?
    by running the bash script itself

add option --no-check-certificate
@mickaelaccensi mickaelaccensi self-assigned this Feb 8, 2022
@mickaelaccensi mickaelaccensi added the bin directory change With this PR something with the bin/build has changed label Feb 8, 2022
Copy link
Contributor

@aliabdolali aliabdolali left a comment

Choose a reason for hiding this comment

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

I tested that at my end, it worked as expected.

Copy link
Collaborator

@JessicaMeixner-NOAA JessicaMeixner-NOAA left a comment

Choose a reason for hiding this comment

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

I'm not opposed to this PR as is, but had some different thoughts when I originally made the issue #578 so thought I'd get your thoughts on that before we merge.

if [ $# -eq 3 ] ; then
interactive='n'
ww3dir=$1 # [ '../../']
wnew=$2 # ['y']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we combine this to just have one option?

interactive='y'
if [ $# -eq 3 ] ; then
interactive='n'
ww3dir=$1 # [ '../../']
Copy link
Collaborator

Choose a reason for hiding this comment

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

To be more consistent with other scripts should we update this to be pointing to the model directory instead of the top level directory?

#Get top level directory of ww3 from user:
echo -e "\n\n This script will download data from the ftp for WAVEWATCH III "
echo -e "Enter the relative path to the main/top level directory, this would "
echo -e "be '../../' if in the model/bin directory or '.' if already in the "
echo -e "top/main directory:"
read ww3dir
if [ "$interactive" = "n" ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is nice as it allows for previous functionality//backwards compatibility, but we're at a point where we're about to have some big changes and therefore are we willing to break this and just make this a script where you have to give it the model directory path and then you either keep things (optional, make an option) or the default is you do nothing and it doesn't keep things?

@mickaelaccensi
Copy link
Collaborator Author

let me know if this version fits better to your expectations :
it can either :
detect the model directory and remove tar (default)
use interactive mode (-i option)
detect the model directory and keep tar (-k option)

@JessicaMeixner-NOAA
Copy link
Collaborator

Okay, I did something wrong:

$ ./model/bin/ww3_from_ftp.sh model 
[ERROR] input argument not recognized
        use -i for interactive mode
        use -k to keep tar files

If we have -k for keeping the tar files, do we still need to have the "y y"? I thought that was the default behavior now.


model_dir=$(cd $(dirname $(dirname $0)) > /dev/null && pwd -P)
echo $model_dir

#Get top level directory of ww3 from user:
echo -e "\n\n This script will download data from the ftp for WAVEWATCH III "
echo -e "Enter the relative path to the main/top level directory, this would "
echo -e "be '../../' if in the model/bin directory or '.' if already in the "
echo -e "top/main directory:"
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're giving the path to the model directory, we should change this description or is this still the same?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@mickaelaccensi
Copy link
Collaborator Author

mickaelaccensi commented Feb 9, 2022

Okay, I did something wrong:

$ ./model/bin/ww3_from_ftp.sh model 
[ERROR] input argument not recognized
        use -i for interactive mode
        use -k to keep tar files

If we have -k for keeping the tar files, do we still need to have the "y y"? I thought that was the default behavior now.

you don't need anymore to specify the model directory since it is detected automatically
the only options available now are :
-i for interactive mode (old manner)
-k to force keeping tar files
-h to print usage

@mickaelaccensi
Copy link
Collaborator Author

I've added usage to make it clearer and I'm also updating the PR summary

@mickaelaccensi mickaelaccensi changed the title non iteractive ww3_from_ftp.sh non interactive ww3_from_ftp.sh Feb 9, 2022
correct option to keep tar files
@mickaelaccensi
Copy link
Collaborator Author

ok this version should be the final one unless you see something to change/improve

@JessicaMeixner-NOAA
Copy link
Collaborator

This is AWESOME!!! Thank you so much @mickaelaccensi

Copy link
Collaborator

@JessicaMeixner-NOAA JessicaMeixner-NOAA left a comment

Choose a reason for hiding this comment

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

The new usage and -h options are really nice. Great improvement! Thank you for implementing this update.

@JessicaMeixner-NOAA JessicaMeixner-NOAA merged commit b144324 into NOAA-EMC:develop Feb 9, 2022
aliabdolali pushed a commit that referenced this pull request Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bin directory change With this PR something with the bin/build has changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update ww3_from_ftp
3 participants