]> git.lizzy.rs Git - torbrowser-launcher.git/commitdiff
Nicer message for the progress-bar
authormeejah <meejah@meejah.ca>
Fri, 22 Feb 2013 01:40:23 +0000 (18:40 -0700)
committermeejah <meejah@meejah.ca>
Fri, 22 Feb 2013 01:40:23 +0000 (18:40 -0700)
torbrowser-launcher

index 2050f902f520ea0b9a1eaf30910dffa4d371e565..5c7aa07289a995f97dc7a34dac5b8d1b31c4e721 100755 (executable)
@@ -291,7 +291,15 @@ class TorBrowserLauncher:
         self.so_far += len(bytes)
         percent = float(self.so_far) / float(self.total)
         self.progress.set_fraction(percent)
-        self.progress.set_text('Downloaded %2.1f%%' % (percent * 100.0))
+        amount = float(self.so_far)
+        units = "bytes"
+        for (size, unit) in [(1000000, "MB"), (1000, "KB")]:
+          if amount > size:
+            units = unit
+            amount = amount / float(size)
+            break
+
+        self.progress.set_text('Downloaded %2.1f%% (%2.1f %s)' % ((percent * 100.0), amount, units))
 
       def connectionLost(self, reason):
         print 'Finished receiving body:', reason.getErrorMessage()