olivierhagolle / theia_download

To download products provided by Theia land data center : https://theia.cnes.fr
45 stars 23 forks source link

Add return code #27

Closed pchg closed 1 year ago

pchg commented 2 years ago

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, through an exit code.

Therefore I added a ret variable (for return) that I first initialised to 0 quite early (to avoid some errors in case the curl line wasn't executed) and I assigned the return code from the curl call to it. Finally, if that return code is not zero (something went wrong), I exit the program 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.

pchg commented 2 years ago

By taking example from the message displayed by these lines (lines 350-351):

        elif file_exists:
            print("%s already exists" % prod)

I added another similar message, in case unzipped files exist.

pchg commented 1 year ago

There were bugs induced by these modifications: therefore I cancel this pull request, I'll make another one shortly.