mirror of
https://github.com/lutris/lutris
synced 2024-09-04 23:13:35 +00:00
Use human_size to display sizes in progress bars
This commit is contained in:
parent
761c8d7b57
commit
fd4ffacb62
|
@ -5,7 +5,7 @@ from gi.repository import GLib, GObject, Gtk, Pango
|
|||
|
||||
from lutris.util.downloader import Downloader
|
||||
from lutris.util.log import logger
|
||||
from lutris.util.strings import gtk_safe
|
||||
from lutris.util.strings import gtk_safe, human_size
|
||||
|
||||
# Same reason as Downloader
|
||||
get_time = time.monotonic
|
||||
|
@ -171,10 +171,10 @@ class DownloadCollectionProgressBox(Gtk.Box):
|
|||
self.update_speed_and_time()
|
||||
megabytes = 1024 * 1024
|
||||
progress_text = _(
|
||||
"{downloaded:0.2f} / {size:0.2f}MB ({speed:0.2f}MB/s), {time} remaining"
|
||||
"{downloaded} / {size} ({speed:0.2f}MB/s), {time} remaining"
|
||||
).format(
|
||||
downloaded=(downloaded_size) / megabytes,
|
||||
size=float(self.full_size) / megabytes,
|
||||
downloaded=human_size(downloaded_size),
|
||||
size=human_size(self.full_size),
|
||||
speed=float(self.avg_speed) / megabytes,
|
||||
time=self.time_left,
|
||||
)
|
||||
|
|
|
@ -5,7 +5,7 @@ from gi.repository import GLib, GObject, Gtk, Pango
|
|||
|
||||
from lutris.util.downloader import Downloader
|
||||
from lutris.util.log import logger
|
||||
from lutris.util.strings import gtk_safe
|
||||
from lutris.util.strings import gtk_safe, human_size
|
||||
|
||||
|
||||
class DownloadProgressBox(Gtk.Box):
|
||||
|
@ -120,10 +120,10 @@ class DownloadProgressBox(Gtk.Box):
|
|||
self.progressbar.set_fraction(progress)
|
||||
megabytes = 1024 * 1024
|
||||
progress_text = _(
|
||||
"{downloaded:0.2f} / {size:0.2f}MB ({speed:0.2f}MB/s), {time} remaining"
|
||||
"{downloaded} / {size} ({speed:0.2f}MB/s), {time} remaining"
|
||||
).format(
|
||||
downloaded=float(self.downloader.downloaded_size) / megabytes,
|
||||
size=float(self.downloader.full_size) / megabytes,
|
||||
downloaded=human_size(self.downloader.downloaded_size),
|
||||
size=human_size(self.downloader.full_size),
|
||||
speed=float(self.downloader.average_speed) / megabytes,
|
||||
time=self.downloader.time_left,
|
||||
)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
"""Manipulates installer files"""
|
||||
import os
|
||||
from functools import reduce
|
||||
from urllib.parse import urlparse
|
||||
from gettext import gettext as _
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from lutris import cache, settings
|
||||
from lutris.gui.widgets.download_collection_progress_box import DownloadCollectionProgressBox
|
||||
|
@ -29,7 +28,7 @@ class InstallerFileCollection:
|
|||
|
||||
def _get_files_size(self):
|
||||
if self.num_files > 0:
|
||||
self.full_size = reduce(lambda x, y: x + y, map(lambda a: a.size, self.files_list))
|
||||
self.full_size = sum(f.size for f in self.files_list)
|
||||
|
||||
def _get_service(self):
|
||||
"""Try to get the service using the url of an InstallerFile"""
|
||||
|
|
Loading…
Reference in a new issue