summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/wget.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/fetch2/wget.py')
-rw-r--r--bitbake/lib/bb/fetch2/wget.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
index 6cb22aeee9..6b60d9b16b 100644
--- a/bitbake/lib/bb/fetch2/wget.py
+++ b/bitbake/lib/bb/fetch2/wget.py
@@ -31,6 +31,7 @@ import subprocess
31import os 31import os
32import logging 32import logging
33import bb 33import bb
34import bb.progress
34import urllib.request, urllib.parse, urllib.error 35import urllib.request, urllib.parse, urllib.error
35from bb import data 36from bb import data
36from bb.fetch2 import FetchMethod 37from bb.fetch2 import FetchMethod
@@ -41,6 +42,27 @@ from bb.utils import export_proxies
41from bs4 import BeautifulSoup 42from bs4 import BeautifulSoup
42from bs4 import SoupStrainer 43from bs4 import SoupStrainer
43 44
45class WgetProgressHandler(bb.progress.LineFilterProgressHandler):
46 """
47 Extract progress information from wget output.
48 Note: relies on --progress=dot (with -v or without -q/-nv) being
49 specified on the wget command line.
50 """
51 def __init__(self, d):
52 super(WgetProgressHandler, self).__init__(d)
53 # Send an initial progress event so the bar gets shown
54 self._fire_progress(0)
55
56 def writeline(self, line):
57 percs = re.findall(r'(\d+)%\s+([\d.]+[A-Z])', line)
58 if percs:
59 progress = int(percs[-1][0])
60 rate = percs[-1][1] + '/s'
61 self.update(progress, rate)
62 return False
63 return True
64
65
44class Wget(FetchMethod): 66class Wget(FetchMethod):
45 """Class to fetch urls via 'wget'""" 67 """Class to fetch urls via 'wget'"""
46 def supports(self, ud, d): 68 def supports(self, ud, d):
@@ -66,13 +88,15 @@ class Wget(FetchMethod):
66 if not ud.localfile: 88 if not ud.localfile:
67 ud.localfile = data.expand(urllib.parse.unquote(ud.host + ud.path).replace("/", "."), d) 89 ud.localfile = data.expand(urllib.parse.unquote(ud.host + ud.path).replace("/", "."), d)
68 90
69 self.basecmd = d.getVar("FETCHCMD_wget", True) or "/usr/bin/env wget -t 2 -T 30 -nv --passive-ftp --no-check-certificate" 91 self.basecmd = d.getVar("FETCHCMD_wget", True) or "/usr/bin/env wget -t 2 -T 30 --passive-ftp --no-check-certificate"
70 92
71 def _runwget(self, ud, d, command, quiet): 93 def _runwget(self, ud, d, command, quiet):
72 94
95 progresshandler = WgetProgressHandler(d)
96
73 logger.debug(2, "Fetching %s using command '%s'" % (ud.url, command)) 97 logger.debug(2, "Fetching %s using command '%s'" % (ud.url, command))
74 bb.fetch2.check_network_access(d, command) 98 bb.fetch2.check_network_access(d, command)
75 runfetchcmd(command, d, quiet) 99 runfetchcmd(command + ' --progress=dot -v', d, quiet, log=progresshandler)
76 100
77 def download(self, ud, d): 101 def download(self, ud, d):
78 """Fetch urls""" 102 """Fetch urls"""