summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/fetch2/perforce.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch2/perforce.py b/bitbake/lib/bb/fetch2/perforce.py
index f57c2a4f52..83128cdeba 100644
--- a/bitbake/lib/bb/fetch2/perforce.py
+++ b/bitbake/lib/bb/fetch2/perforce.py
@@ -17,6 +17,36 @@ from bb.fetch2 import FetchError
17from bb.fetch2 import logger 17from bb.fetch2 import logger
18from bb.fetch2 import runfetchcmd 18from bb.fetch2 import runfetchcmd
19 19
20class PerforceProgressHandler (bb.progress.BasicProgressHandler):
21 """
22 Implements basic progress information for perforce, based on the number of
23 files to be downloaded.
24
25 The p4 print command will print one line per file, therefore it can be used
26 to "count" the number of files already completed and give an indication of
27 the progress.
28 """
29 def __init__(self, d, num_files):
30 self._num_files = num_files
31 self._count = 0
32 super(PerforceProgressHandler, self).__init__(d)
33
34 # Send an initial progress event so the bar gets shown
35 self._fire_progress(-1)
36
37 def write(self, string):
38 self._count = self._count + 1
39
40 percent = int(100.0 * float(self._count) / float(self._num_files))
41
42 # In case something goes wrong, we try to preserve our sanity
43 if percent > 100:
44 percent = 100
45
46 self.update(percent)
47
48 super(PerforceProgressHandler, self).write(string)
49
20class Perforce(FetchMethod): 50class Perforce(FetchMethod):
21 """ Class to fetch from perforce repositories """ 51 """ Class to fetch from perforce repositories """
22 def supports(self, ud, d): 52 def supports(self, ud, d):
@@ -150,10 +180,12 @@ class Perforce(FetchMethod):
150 bb.utils.remove(ud.pkgdir, True) 180 bb.utils.remove(ud.pkgdir, True)
151 bb.utils.mkdirhier(ud.pkgdir) 181 bb.utils.mkdirhier(ud.pkgdir)
152 182
183 progresshandler = PerforceProgressHandler(d, len(filelist))
184
153 for afile in filelist: 185 for afile in filelist:
154 p4fetchcmd = self._buildp4command(ud, d, 'print', afile) 186 p4fetchcmd = self._buildp4command(ud, d, 'print', afile)
155 bb.fetch2.check_network_access(d, p4fetchcmd, ud.url) 187 bb.fetch2.check_network_access(d, p4fetchcmd, ud.url)
156 runfetchcmd(p4fetchcmd, d, workdir=ud.pkgdir) 188 runfetchcmd(p4fetchcmd, d, workdir=ud.pkgdir, log=progresshandler)
157 189
158 runfetchcmd('tar -czf %s p4' % (ud.localpath), d, cleanup=[ud.localpath], workdir=ud.pkgdir) 190 runfetchcmd('tar -czf %s p4' % (ud.localpath), d, cleanup=[ud.localpath], workdir=ud.pkgdir)
159 191