'Status for Sentinel-2 Products always returns False (0) even when they should return True (1)

I'm trying to use python to check if Satellite Image Products from Sentinel-2 are 'online' or 'offline' on the ESA servers. I'm using GNU Wget to achieve this.

As seen in the documentation (https://scihub.copernicus.eu/userguide/DataRestoration), you can use the following URI to see if a product for a certain UUID is online or offline:

https://scihub.copernicus.eu/dhus/odata/v1/Products('98ca202b-2155-4181-be88-4358b2cbaaa0')/Online/$value

The part between the parenthesis is the UUID. When just manually using this link, it works as expected and returns true (1) for online products and false (0) for offline products.

I have the following code:

import subprocess

def IsOnline(UUID):
   wget_command = "wget --no-check-certificate --continue" + " --user={}".format(USERNAME) + " --password={}".format(PASSWORD)
   URI = "https://scihub.copernicus.eu/dhus/odata/v1/Products('{0}')/Online/$value".format(UUID)
   wget_cmd = wget_command + ' "' + URI + '"'

   return subprocess.call(wget_cmd)

IsOnline(UUID)

UUID which should be online = '586bafc4-cfe2-4918-85e1-fe03090952ad'

UUID which should be offline = '85fb6b2a-6559-4025-821f-b72573f339c6'

Unfortunately, everything, even online UUID's return False (0). Does someone know how to solve this?



Solution 1:[1]

Does someone know how to solve this?

Note that subprocess.call does return returncode of command, generally 0 denotes that command was executed without errors. If it so wget should create file, which you should be able to inspect in order to determine what was API response. Please check if this is case, if yes you might use -O to inform wget how downloaded file should be named e.g.:

wget -O example.html https://www.example.com

which should made reading it in python easy.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Daweo