From 3efd20dbcea34eb91840fc0696a7ef35ecb4fdd5 Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Mon, 6 Feb 2006 12:59:05 +0000 Subject: [PATCH] =?UTF-8?q?=20http,=20https=20ve=20ftp=20i=C3=A7in=20proxy?= =?UTF-8?q?=20deste=C4=9Fi=20(#863)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pisi/configfile.py | 3 +++ pisi/fetcher.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/pisi/configfile.py b/pisi/configfile.py index 2156396e..4bc498ac 100644 --- a/pisi/configfile.py +++ b/pisi/configfile.py @@ -59,6 +59,9 @@ class GeneralDefaults: autoclean = False distribution = "Pardus" distribution_release = "0.1" + http_proxy = os.getenv("HTTP_PROXY") or None + https_proxy = os.getenv("HTTPS_PROXY") or None + ftp_proxy = os.getenv("FTP_PROXY") or None class BuildDefaults: """Default values for [build] section""" diff --git a/pisi/fetcher.py b/pisi/fetcher.py index 3b18145d..54023fcc 100644 --- a/pisi/fetcher.py +++ b/pisi/fetcher.py @@ -211,6 +211,25 @@ class Fetcher: urllib2.install_opener(opener) request.add_header('Range', 'bytes=%d-' % self.exist_size) + proxy_handler = None + + if ctx.config.values.general.http_proxy and self.url.scheme() == "http": + http_proxy = ctx.config.values.general.http_proxy + proxy_handler = urllib2.ProxyHandler({URI(http_proxy).scheme(): http_proxy}) + + elif ctx.config.values.general.https_proxy and self.url.scheme() == "https": + https_proxy = ctx.config.values.general.https_proxy + proxy_handler = urllib2.ProxyHandler({URI(https_proxy): https_proxy}) + + elif ctx.config.values.general.ftp_proxy and self.url.scheme() == "ftp": + ftp_proxy = ctx.config.values.general.ftp_proxy + proxy_handler = urllib2.ProxyHandler({URI(http_proxy): ftp_proxy}) + + if proxy_handler: + ctx.ui.info(_("Proxy configuration has been found for '%s' protocol") % self.url.scheme()) + opener = urllib2.build_opener(proxy_handler) + urllib2.install_opener(opener) + return request def err (self, error):