Open pchg opened 1 year ago
Thanks ! Unfortunately, I have no time to test it, and I can't accept merge requests like that. I am trying to find someone else at CNES to maintain this software...
All right, nothing urgent. I think that I will try the method of Mr @sgascoin in his pull request. Here it is:
alors ma pull request ?
(citation avec tous les droits d'auteur et toutes ces sortes de choses)
This pull request replaces the previous one "Add return code 2": https://github.com/olivierhagolle/theia_download/pull/31 When calling this script from a shell script, I bumped into some download errors, and some partially files were left as *tmp ; I wanted a way to check that the theia_download.py got executed fine, by using an exit code.
I added a return_code variable and a return_code_final variable, which I both first initialised to 0 quite early (to avoid some errors in case the curl line wasn't executed). Every time the curl call is made, its return code is assigned to return_code variable, and return_code_final is aggregated with return_code. If everything goes well, curl returns 0 and both variables' values stay at 0.
This concatenation makes the final return code quite undecipherable, but it is just supposed to raise something with a non-zero code for a calling script.
Finally, if that final return code is not zero (something went wrong), the program exits with that exit code. This way, a calling script can know that something went wrong.
Additionally, I also added a sys.exit(-1) at the very end, although the -1 may not be the best code to return. To be discussed; I just took example from the other sys.exit() calls in the program.
I also added a print message in case the unzipped product already exists in the current directory.