Commit 0544bf6d authored by Commandre Benjamin's avatar Commandre Benjamin
Browse files

Ajout request proxy

1 merge request!1Develop
Showing with 9 additions and 3 deletions
+9 -3
...@@ -299,10 +299,17 @@ class Archive(): ...@@ -299,10 +299,17 @@ class Archive():
# The token is only valid for two hours. If your connection is slow # The token is only valid for two hours. If your connection is slow
# or if you are downloading lots of products # or if you are downloading lots of products
#============================================================= #=============================================================
proxyDict = {
"http" : "{0}".format(self._proxy_enabled.proxy), \
"https" : "{0}".format(self._proxy_enabled.proxy), \
"ftp" : "{0}".format(self._proxy_enabled.proxy) \
}
url = "{0}/services/authenticate/".format(self.server) url = "{0}/services/authenticate/".format(self.server)
payload = {'ident' : "{0}".format(user_theia), 'pass' : "{0}".format(password_theia)} payload = {'ident' : "{0}".format(user_theia), 'pass' : "{0}".format(password_theia)}
reponse = requests.post(url, data=payload) reponse = requests.post(url, data=payload, proxies=proxyDict)
try: try:
self.logger.debug(reponse.json()) self.logger.debug(reponse.json())
...@@ -322,13 +329,12 @@ class Archive(): ...@@ -322,13 +329,12 @@ class Archive():
if not os.path.exists(self.list_archive[d][1]): if not os.path.exists(self.list_archive[d][1]):
self.logger.info("Téléchargement : {0}".format(os.path.basename(self.list_archive[d][1]))) self.logger.info("Téléchargement : {0}".format(os.path.basename(self.list_archive[d][1])))
url = "{0}/{1}/collections/{2}/{3}/download/?issuerId=theia".format(self.server, self.resto, self._captor, self.list_archive[d][2]) url = "{0}/{1}/collections/{2}/{3}/download/?issuerId=theia".format(self.server, self.resto, self._captor, self.list_archive[d][2])
reponse = requests.get(url, headers=head) reponse = requests.get(url, headers=head, proxies=proxyDict)
with (open(self.list_archive[d][1], "wb")) as fichier : with (open(self.list_archive[d][1], "wb")) as fichier :
fichier.write(reponse.content) fichier.write(reponse.content)
self.logger.info("All images have been downloaded !") self.logger.info("All images have been downloaded !")
sys.exit(1)
def decompress(self): def decompress(self):
""" """
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment