def __iter__(self):
     totalsize = len(self.data)
     for offset in range(0, totalsize, self.chunksize):
         transferred = min(offset + self.chunksize, totalsize)
         if not self.check_only:
             DownloadHelper.progress(totalsize, transferred,
                                     self.start)
         yield self.data[offset:transferred]
Exemplo n.º 2
0
 def test_progress(self, total, downloaded, output, monkeypatch):
     """
     Test that progress of a download is shown correctly. Test the case when size parameters are passed as integers.
     """
     buf = io.StringIO()
     monkeypatch.setattr('sys.stdout', buf)
     monkeypatch.setattr('time.time', lambda: 10.0)
     DownloadHelper.progress(total, downloaded, 0.0)
     assert buf.getvalue() == output
Exemplo n.º 3
0
 def test_progress(self, total, downloaded, output, monkeypatch):
     """
     Test that progress of a download is shown correctly. Test the case when size parameters are passed as integers.
     """
     buf = StringIO()
     monkeypatch.setattr('sys.stdout', buf)
     monkeypatch.setattr('time.time', lambda: 10.0)
     DownloadHelper.progress(total, downloaded, 0.0)
     assert buf.getvalue() == output
 def run(self):
     if self.check_only:
         return
     n = 0
     start = time.time()
     while not self.stop_event.is_set():
         DownloadHelper.progress(-1,
                                 n * 256 * 1024,
                                 start,
                                 show_size=False)
         n += 1
         self.stop_event.wait(self.interval)
 def __iter__(self):
     if self.uploaded:
         # ensure the progressbar is shown only once (HTTPSPNEGOAuth causes second request)
         yield self.data
     else:
         totalsize = len(self.data)
         for offset in range(0, totalsize, self.chunksize):
             transferred = min(offset + self.chunksize, totalsize)
             if not self.check_only:
                 DownloadHelper.progress(totalsize, transferred,
                                         self.start)
             yield self.data[offset:transferred]
         self.uploaded = True
Exemplo n.º 6
0
 def progress(uploaded, total, chunksize, t1, t2):  # pylint: disable=unused-argument
     DownloadHelper.progress(total, uploaded, upload_start)
Exemplo n.º 7
0
 def progress(uploaded, total, chunksize, t1, t2):  # pylint: disable=unused-argument
     DownloadHelper.progress(total, uploaded, upload_start)