Esempio n. 1
0
 def update_progress(self, datalen):
     self.current += datalen
     if self.total > 1024 and self.current:
         howmuch = int((self.current * 100) / self.total)
         if self.last_output is None or howmuch - self.last_output >= 10:
             self.last_output = howmuch
             elapsed = time.time() - self.start
             velocity = self.current / elapsed
             cur = self.current
             tot = self.total
             for (order, unit) in [(1024, 'KiB'), (1024 * 1024, 'MiB'),
                                   (1024 * 1024 * 1024, 'GiB')]:
                 if tot / order < 100:
                     break
             cur /= order
             tot /= order
             units = unit
             estimate = self.total / velocity
             left = estimate - elapsed
             print(
                 '%s - %.1f of %.1f %s (%ds remaining)' %
                 (util.pretty_progress(howmuch, 5), cur, tot, units, left))
             if self.current == self.total:
                 print('%0.2f MiB/s' % (self.total /
                                        (1024.0 * 1024) / elapsed))
Esempio n. 2
0
 def update_progress(self, datalen):
     self.current += datalen
     if self.total > 1024 and self.current:
         howmuch = int((self.current * 100) / self.total)
         if self.last_output is None or howmuch - self.last_output >= 10:
             self.last_output = howmuch
             elapsed = time.time() - self.start
             velocity = self.current / elapsed
             cur = self.current
             tot = self.total
             for (order, unit) in [(1024, 'KiB'), (1024 * 1024, 'MiB'), (1024 * 1024 * 1024, 'GiB')]:
                 if tot / order < 100:
                     break
             cur /= order
             tot /= order
             units = unit
             estimate = self.total / velocity
             left = estimate - elapsed
             print('%s - %.1f of %.1f %s (%ds remaining)' % (util.pretty_progress(howmuch, 5), cur, tot, units, left))
             if self.current == self.total:
                 print('%0.2f MiB/s' % (self.total / (1024.0 * 1024) / elapsed))
Esempio n. 3
0
def _progress(percent, tag, message):
    print(util.pretty_progress(percent), message)
Esempio n. 4
0
 def progress(self, percent, tag, message):
     print(util.pretty_progress(percent), message)
Esempio n. 5
0
 def update(pct, tag, description):
     if not cfg.json:
         print("  {}: {}".format(util.pretty_progress(pct), description))