def auth (usr, pwd, dhusAlt=None):
"""Globally install Basic Auth, and set site specific string constants."""
SITE["NAME"] = dhusAlt if dhusAlt is not None else "SciHub"
site,collspec = "https://scihub.copernicus.eu/", "producttype:S2MSI%s"
if SITE["NAME"]=="CODE-DE": site,collspec = "https://code-de.org/", "platformname:Sentinel-2"
SITE["BASE"] = site+"dhus/"
# pm=urllib2.HTTPPasswordMgrWithDefaultRealm()
# pm.add_password(None, SITE["BASE"], usr, pwd)
# urllib2.install_opener(urllib2.build_opener(urllib2.HTTPBasicAuthHandler(pm)))
#...does not work transparently in combination with proxy support => workaround: urlOpen().
import base64; SITE["AUTH"] = "Basic " + base64.b64encode("%s:%s" % (usr, pwd))
SITE["SEARCH"] = SITE["BASE"] + "search?format=xml&sortedby=beginposition&order=desc&rows=%d&q=%s" % (ROWSSTEP, collspec)
product = SITE["BASE"] + "odata/v1/Products('%s')/"
SITE["CHECKSUM"], SITE["SAFEZIP"], SITE["SAFEROOT"] = product+"Checksum/Value/$value", product+"$value", product+"Nodes('%s.SAFE')/"
评论列表
文章目录