Yay for new bandwith usage limitation option for PiSi

This commit is contained in:
A. Murat Eren
2007-11-21 20:20:25 +00:00
parent eb98fcded3
commit 489153317a
2 changed files with 11 additions and 0 deletions
+2
View File
@@ -151,6 +151,8 @@ class Command(object):
default=False, help = _("Assume yes in all yes/no queries"))
group.add_option("-u", "--username", action="store")
group.add_option("-p", "--password", action="store")
group.add_option("-L", "--bandwidth-limit", action="store", default = 0,
help = _("Keep bandwidth usage under specified KB's"))
group.add_option("-v", "--verbose", action="store_true",
dest="verbose", default=False,
help=_("Detailed output"))
+9
View File
@@ -136,6 +136,7 @@ class Fetcher:
http_headers = self._get_http_headers(),
ftp_headers = self._get_ftp_headers(),
proxies = self._get_proxies(),
throttle = self._get_bandwith_limit(),
user_agent = 'PiSi Fetcher/' + pisi.__version__,
reget = 'check_timestamp')
@@ -178,6 +179,14 @@ class Fetcher:
return proxies
def _get_bandwith_limit(self):
bandwidth_limit = ctx.config.options.bandwidth_limit or ctx.config.values.general.bandwidth_limit
if bandwidth_limit:
ctx.ui.warning(_("Bandwidth usage is limited to %s KB/s") % bandwidth_limit)
return 1024 * int(bandwidth_limit)
else:
return 0
# helper function
def fetch_url(url, destdir, progress=None):