Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request replaces the previous one "Add return code 2":
#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.