From cfc16a7145ea78fb1e5514087e2f764e837a4e02 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 3 Aug 2011 23:42:00 +0200 Subject: [PATCH] Add support for http proxies. --- examples/pakfire.conf | 7 +++++++ pakfire/downloader.py | 9 ++++++--- pakfire/repository/remote.py | 1 + po/pakfire.pot | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/pakfire.conf b/examples/pakfire.conf index 79e1a8f7e..6e1b5e54e 100644 --- a/examples/pakfire.conf +++ b/examples/pakfire.conf @@ -5,6 +5,13 @@ logfile = /var/log/pakfire.log +# Pakfire can use a HTTP proxy for all downloads. +# Authentication can be used like this: +# http://foo:bar@192.168.180.1:800 +# If no proxy setting is configured, Pakfire will +# use the environment settings. +# http_proxy = http://192.168.180.1:800 + # You can throttle the download bandwidth with this # parameter. Unit: bytes per second. # bandwidth_throttle = 10240 diff --git a/pakfire/downloader.py b/pakfire/downloader.py index b5d61d027..7369ddb39 100644 --- a/pakfire/downloader.py +++ b/pakfire/downloader.py @@ -14,15 +14,13 @@ class PakfireGrabber(URLGrabber): """ Class to make some modifications on the urlgrabber configuration. """ - # XXX add proxy, throttle things here - def __init__(self, pakfire, *args, **kwargs): kwargs.update({ "quote" : 0, "user_agent" : "pakfire/%s" % PAKFIRE_VERSION, }) - # Get Pakfire configuration + # Set throttle setting. bandwidth_throttle = pakfire.config.get("bandwidth_throttle") if bandwidth_throttle: try: @@ -33,6 +31,11 @@ class PakfireGrabber(URLGrabber): kwargs.update({ "throttle" : bandwidth_throttle }) + # Configure HTTP proxy. + http_proxy = pakfire.config.get("http_proxy") + if http_proxy: + kwargs.update({ "proxies" : { "http" : http_proxy }}) + URLGrabber.__init__(self, *args, **kwargs) diff --git a/pakfire/repository/remote.py b/pakfire/repository/remote.py index 4805b2eca..09fd7c5af 100644 --- a/pakfire/repository/remote.py +++ b/pakfire/repository/remote.py @@ -86,6 +86,7 @@ class RepositorySolv(base.RepositoryFactory): # Get a package grabber and add mirror download capabilities to it. grabber = downloader.PackageDownloader( + self.pakfire, text=text + os.path.basename(filename), ) grabber = self.mirrors.group(grabber) diff --git a/po/pakfire.pot b/po/pakfire.pot index 7ef03bc77..dadf0239b 100644 --- a/po/pakfire.pot +++ b/po/pakfire.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-08-03 23:16+0200\n" +"POT-Creation-Date: 2011-08-03 23:34+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" -- 2.39.5