summaryrefslogtreecommitdiff
path: root/DistUpgrade
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-08-29 23:11:17 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2006-08-29 23:11:17 +0200
commitab901030dbec4180254a680dd1c49016cfc36d4a (patch)
treee4534baa3153a2b66ce9d69d7b1ba00ceb0908cc /DistUpgrade
parent9a8c25937bfac8242b7eef9f3f815a273392606a (diff)
downloadpython-apt-ab901030dbec4180254a680dd1c49016cfc36d4a.tar.gz
* DistUpgrade/*:
- added download time estimation (based on modem and 1Mbit DSL)
Diffstat (limited to 'DistUpgrade')
-rw-r--r--DistUpgrade/DistUpgradeCache.py10
-rw-r--r--DistUpgrade/DistUpgradeControler.py2
-rw-r--r--DistUpgrade/DistUpgradeView.py11
-rw-r--r--DistUpgrade/DistUpgradeViewGtk.py19
4 files changed, 25 insertions, 17 deletions
diff --git a/DistUpgrade/DistUpgradeCache.py b/DistUpgrade/DistUpgradeCache.py
index 455ef34f..e1f892ac 100644
--- a/DistUpgrade/DistUpgradeCache.py
+++ b/DistUpgrade/DistUpgradeCache.py
@@ -8,6 +8,7 @@ import re
import logging
from gettext import gettext as _
from DistUpgradeConfigParser import DistUpgradeConfig
+from DistUpgradeView import FuzzyTimeToStr
class MyCache(apt.Cache):
# init
@@ -35,6 +36,15 @@ class MyCache(apt.Cache):
pm.GetArchives(fetcher, self._list, self._records)
return fetcher.FetchNeeded
@property
+ def estimatedDownloadTime(self):
+ """ get the estimated download time """
+ requiredDownload = self.requiredDownload
+ timeModem = requiredDownload/(56*1024/8) # 56 kbit
+ timeDSL = requiredDownload/(1024*1024/8) # 1Mbit = 1024 kbit
+ s= _("The download will approximately take %s with a 56k modem and %s with "
+ "a 1Mbit DSL connection" % FuzzyTimeToStr(timeModem), FuzzyTimeToStr(timeDSL))
+ return s
+ @property
def additionalRequiredSpace(self):
""" get the size of the additonal required space on the fs """
return self._depcache.UsrSize
diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py
index 689882ac..cb0835fb 100644
--- a/DistUpgrade/DistUpgradeControler.py
+++ b/DistUpgrade/DistUpgradeControler.py
@@ -132,7 +132,7 @@ class DistUpgradeControler(object):
_("The upgrade can use the network to check "
"the latest updates and to fetch packages that are not on the "
"current CD.\n"
- "If you have inexpensive network access you should answer "
+ "If you have fast or inexpensive network access you should answer "
"'Yes' here. If networking is expensive for you choose 'No'.")
)
self.useNetwork = res
diff --git a/DistUpgrade/DistUpgradeView.py b/DistUpgrade/DistUpgradeView.py
index 4b24ee7f..6d6d5516 100644
--- a/DistUpgrade/DistUpgradeView.py
+++ b/DistUpgrade/DistUpgradeView.py
@@ -19,6 +19,17 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
+def FuzzyTimeToStr(sec):
+ " return the time a bit fuzzy (no seconds if time > 60 secs "
+ if sec > 60*60*24:
+ return _("%li days %li hours %li minutes") % (sec/60/60/24, (sec/60/60) % 24, (sec/60) % 60)
+ if sec > 60*60:
+ return _("%li hours %li minutes") % (sec/60/60, (sec/60) % 60)
+ if sec > 60:
+ return _("%li minutes") % (sec/60)
+ return _("%li seconds") % sec
+
+
class DumbTerminal(object):
def call(self, cmd):
" expects a command in the subprocess style (as a list) "
diff --git a/DistUpgrade/DistUpgradeViewGtk.py b/DistUpgrade/DistUpgradeViewGtk.py
index fb774c5a..bb2e63e2 100644
--- a/DistUpgrade/DistUpgradeViewGtk.py
+++ b/DistUpgrade/DistUpgradeViewGtk.py
@@ -37,7 +37,7 @@ import apt_pkg
import os
from apt.progress import InstallProgress
-from DistUpgradeView import DistUpgradeView
+from DistUpgradeView import DistUpgradeView, FuzzyTimeToStr
from UpdateManager.Common.SimpleGladeApp import SimpleGladeApp, bindtextdomain
import gettext
@@ -46,19 +46,6 @@ from gettext import gettext as _
def utf8(str):
return unicode(str, 'latin1').encode('utf-8')
-def FuzzyTimeToStr(sec):
- " return the time a bit fuzzy (no seconds if time > 60 secs "
- if sec > 60*60*24:
- return _("About %li days %li hours %li minutes remaining") % (sec/60/60/24,
- (sec/60/60) % 24,
- (sec/60) % 60)
- if sec > 60*60:
- return _("About %li hours %li minutes remaining") % (sec/60/60,
- (sec/60) % 60)
- if sec > 60:
- return _("About %li minutes remaining") % (sec/60)
- return _("About %li seconds remaining") % sec
-
class GtkCdromProgressAdapter(apt.progress.CdromProgress):
""" Report the cdrom add progress
@@ -140,7 +127,7 @@ class GtkFetchProgressAdapter(apt.progress.FetchProgress):
if self.currentCPS > 0:
self.status.set_text(_("Fetching file %li of %li at %s/s" % (currentItem, self.totalItems, apt_pkg.SizeToStr(self.currentCPS))))
- self.progress.set_text(FuzzyTimeToStr(self.eta))
+ self.progress.set_text(_("About %s remaining") % FuzzyTimeToStr(self.eta))
else:
self.status.set_text(_("Fetching file %li of %li" % (currentItem, self.totalItems)))
self.progress.set_text(" ")
@@ -262,7 +249,7 @@ class GtkInstallProgressAdapter(InstallProgress):
eta = (100.0 - self.percent) * time_per_percent
# only show if we have some sensible data
if eta > 61.0 and eta < (60*60*24*2):
- self.progress.set_text(FuzzyTimeToStr(eta))
+ self.progress.set_text(_("About %s remaining") % FuzzyTimeToStr(eta))
else:
self.progress.set_text(" ")