Yay for new bandwith usage limitation option for PiSi
This commit is contained in:
@@ -151,6 +151,8 @@ class Command(object):
|
|||||||
default=False, help = _("Assume yes in all yes/no queries"))
|
default=False, help = _("Assume yes in all yes/no queries"))
|
||||||
group.add_option("-u", "--username", action="store")
|
group.add_option("-u", "--username", action="store")
|
||||||
group.add_option("-p", "--password", 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",
|
group.add_option("-v", "--verbose", action="store_true",
|
||||||
dest="verbose", default=False,
|
dest="verbose", default=False,
|
||||||
help=_("Detailed output"))
|
help=_("Detailed output"))
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ class Fetcher:
|
|||||||
http_headers = self._get_http_headers(),
|
http_headers = self._get_http_headers(),
|
||||||
ftp_headers = self._get_ftp_headers(),
|
ftp_headers = self._get_ftp_headers(),
|
||||||
proxies = self._get_proxies(),
|
proxies = self._get_proxies(),
|
||||||
|
throttle = self._get_bandwith_limit(),
|
||||||
user_agent = 'PiSi Fetcher/' + pisi.__version__,
|
user_agent = 'PiSi Fetcher/' + pisi.__version__,
|
||||||
reget = 'check_timestamp')
|
reget = 'check_timestamp')
|
||||||
|
|
||||||
@@ -178,6 +179,14 @@ class Fetcher:
|
|||||||
|
|
||||||
return proxies
|
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
|
# helper function
|
||||||
def fetch_url(url, destdir, progress=None):
|
def fetch_url(url, destdir, progress=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user