Merge lp:~mvo/ubuntu-release-upgrader/use-str.format into lp:ubuntu-release-upgrader

Proposed by Michael Vogt
Status: Rejected
Rejected by: Michael Vogt
Proposed branch: lp:~mvo/ubuntu-release-upgrader/use-str.format
Merge into: lp:ubuntu-release-upgrader
Diff against target: 888 lines (+175/-142)
14 files modified
DistUpgrade/DistUpgradeAptCdrom.py (+1/-1)
DistUpgrade/DistUpgradeCache.py (+10/-10)
DistUpgrade/DistUpgradeController.py (+39/-38)
DistUpgrade/DistUpgradeFetcherCore.py (+5/-5)
DistUpgrade/DistUpgradeFetcherKDE.py (+4/-3)
DistUpgrade/DistUpgradeGettext.py (+7/-2)
DistUpgrade/DistUpgradeView.py (+27/-24)
DistUpgrade/DistUpgradeViewGtk3.py (+25/-21)
DistUpgrade/DistUpgradeViewKDE.py (+23/-15)
DistUpgrade/DistUpgradeViewText.py (+10/-5)
DistUpgrade/GtkProgress.py (+8/-8)
check-new-release-gtk (+8/-7)
do-partial-upgrade (+3/-3)
pre-build.sh (+5/-0)
To merge this branch: bzr merge lp:~mvo/ubuntu-release-upgrader/use-str.format
Reviewer Review Type Date Requested Status
Ubuntu Core Development Team Pending
Review via email: mp+217004@code.launchpad.net

Description of the change

Use str.format() with gettext (eventually everywhere) to avoid crashes if e.g. incorrect translations are specified. The worst case with str.format() is that the information is not displayed correctly, but it won't crash like e.g. LP: #1311396

To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote :

Maybe str.format is better for other reasons, but you can certainly still get tracebacks from it:

$ python3 -c "'hello {0'.format('world')"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: expected '}' before end of string

Revision history for this message
Michael Vogt (mvo) wrote :

Hi Michael, thanks for your comment. Indeed, I should have been more clear.

The issue that is fixed is:

$ python -c 'print("foo" % "bar")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: not all arguments converted during string formatting

$ python -c 'print("foo".format("bar"))'
foo

But yes, if a translation has a incorrect number of {} it will still crash, so maybe its not worth
doing all the work and instead use the "Foo %(bar)s" % { "bar": "some-str" } approach where its
also ok to leave out a argument. I.e.
$ python -c 'print("foo" % {"bar": "bar"})'
foo

Revision history for this message
Barry Warsaw (barry) wrote :

It might be a lot of work to port, but I will suggest using my flufl.i18n package, which has a lot of nice convenience APIs and safeguards for doing i18n interpolation.

http://pythonhosted.org/flufl.i18n/docs/using.html

And of course, it's packaged up :).

Revision history for this message
Barry Warsaw (barry) wrote :

Also note that with modern Pythons

'{0}'.format('foo')

is equivalent to

'{}'.format('foo')

Unmerged revisions

2779. By Michael Vogt

replace all %s style format with str.format() in gettext to be more robust against crashes from incorrectly formated translations

2778. By Michael Vogt

use str.format() for all ngettext() to avoid crashes on incorrect number of parameters (LP: #1311396

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'DistUpgrade/DistUpgradeAptCdrom.py'
--- DistUpgrade/DistUpgradeAptCdrom.py 2012-06-12 13:52:04 +0000
+++ DistUpgrade/DistUpgradeAptCdrom.py 2014-04-24 08:46:39 +0000
@@ -295,7 +295,7 @@
295 _("There was a error adding the CD, the "295 _("There was a error adding the CD, the "
296 "upgrade will abort. Please report this as "296 "upgrade will abort. Please report this as "
297 "a bug if this is a valid Ubuntu CD.\n\n"297 "a bug if this is a valid Ubuntu CD.\n\n"
298 "The error message was:\n'%s'") % e)298 "The error message was:\n'{0}'").format(e))
299 return False299 return False
300 logging.debug("AptCdrom.add() returned: %s" % res)300 logging.debug("AptCdrom.add() returned: %s" % res)
301 return res301 return res
302302
=== modified file 'DistUpgrade/DistUpgradeCache.py'
--- DistUpgrade/DistUpgradeCache.py 2014-04-15 08:57:53 +0000
+++ DistUpgrade/DistUpgradeCache.py 2014-04-24 08:46:39 +0000
@@ -152,17 +152,17 @@
152 header = ngettext("Remove package in bad state",152 header = ngettext("Remove package in bad state",
153 "Remove packages in bad state",153 "Remove packages in bad state",
154 len(reqreinst))154 len(reqreinst))
155 summary = ngettext("The package '%s' is in an inconsistent "155 summary = ngettext("The package '{0}' is in an inconsistent "
156 "state and needs to be reinstalled, but "156 "state and needs to be reinstalled, but "
157 "no archive can be found for it. "157 "no archive can be found for it. "
158 "Do you want to remove this package "158 "Do you want to remove this package "
159 "now to continue?",159 "now to continue?",
160 "The packages '%s' are in an inconsistent "160 "The packages '{0}' are in an inconsistent "
161 "state and need to be reinstalled, but "161 "state and need to be reinstalled, but "
162 "no archives can be found for them. Do you "162 "no archives can be found for them. Do you "
163 "want to remove these packages now to "163 "want to remove these packages now to "
164 "continue?",164 "continue?",
165 len(reqreinst)) % ", ".join(reqreinst)165 len(reqreinst)).format(", ".join(reqreinst))
166 if view.askYesNoQuestion(header, summary):166 if view.askYesNoQuestion(header, summary):
167 self.release_lock()167 self.release_lock()
168 cmd = ["/usr/bin/dpkg", "--remove", "--force-remove-reinstreq"] + list(reqreinst)168 cmd = ["/usr/bin/dpkg", "--remove", "--force-remove-reinstreq"] + list(reqreinst)
@@ -727,13 +727,13 @@
727 for pkg in self.get_changes():727 for pkg in self.get_changes():
728 if pkg.marked_delete and self._inRemovalBlacklist(pkg.name):728 if pkg.marked_delete and self._inRemovalBlacklist(pkg.name):
729 logging.debug("The package '%s' is marked for removal but it's in the removal blacklist", pkg.name)729 logging.debug("The package '%s' is marked for removal but it's in the removal blacklist", pkg.name)
730 raise SystemError(_("The package '%s' is marked for removal but it is in the removal blacklist.") % pkg.name)730 raise SystemError(_("The package '{0}' is marked for removal but it is in the removal blacklist.").format(pkg.name))
731 if pkg.marked_delete and (731 if pkg.marked_delete and (
732 pkg._pkg.essential == True and732 pkg._pkg.essential == True and
733 pkg.installed.architecture == main_arch and733 pkg.installed.architecture == main_arch and
734 not pkg.name in removeEssentialOk):734 not pkg.name in removeEssentialOk):
735 logging.debug("The package '%s' is marked for removal but it's an ESSENTIAL package", pkg.name)735 logging.debug("The package '%s' is marked for removal but it's an ESSENTIAL package", pkg.name)
736 raise SystemError(_("The essential package '%s' is marked for removal.") % pkg.name)736 raise SystemError(_("The essential package '{0}' is marked for removal.").format(pkg.name))
737 # check bad-versions blacklist737 # check bad-versions blacklist
738 badVersions = self.config.getlist("Distro", "BadVersions")738 badVersions = self.config.getlist("Distro", "BadVersions")
739 for bv in badVersions:739 for bv in badVersions:
@@ -742,7 +742,7 @@
742 self[pkgname].candidate.version == ver and742 self[pkgname].candidate.version == ver and
743 (self[pkgname].marked_install or743 (self[pkgname].marked_install or
744 self[pkgname].marked_upgrade)):744 self[pkgname].marked_upgrade)):
745 raise SystemError(_("Trying to install blacklisted version '%s'") % bv)745 raise SystemError(_("Trying to install blacklisted version '{0}'").format(bv))
746 return True746 return True
747747
748 def _lookupPkgRecord(self, pkg):748 def _lookupPkgRecord(self, pkg):
@@ -861,7 +861,7 @@
861 except (SystemError, KeyError) as e:861 except (SystemError, KeyError) as e:
862 logging.error("failed to mark '%s' for install (%s)" %862 logging.error("failed to mark '%s' for install (%s)" %
863 (key, e))863 (key, e))
864 view.error(_("Can't install '%s'") % key,864 view.error(_("Can't install '{0}'").format(key),
865 _("It was impossible to install a "865 _("It was impossible to install a "
866 "required package. Please report "866 "required package. Please report "
867 "this as a bug using "867 "this as a bug using "
@@ -875,13 +875,13 @@
875 meta_pkgs = ', '.join(metapkgs[0:-1])875 meta_pkgs = ', '.join(metapkgs[0:-1])
876 view.error(_("Can't guess meta-package"),876 view.error(_("Can't guess meta-package"),
877 _("Your system does not contain a "877 _("Your system does not contain a "
878 "%s or %s package and it was not "878 "{0} or {1} package and it was not "
879 "possible to detect which version of "879 "possible to detect which version of "
880 "Ubuntu you are running.\n "880 "Ubuntu you are running.\n "
881 "Please install one of the packages "881 "Please install one of the packages "
882 "above first using synaptic or "882 "above first using synaptic or "
883 "apt-get before proceeding.") %883 "apt-get before proceeding.").format(
884 (meta_pkgs, metapkgs[-1]))884 meta_pkgs, metapkgs[-1]))
885 return False885 return False
886 return True886 return True
887887
888888
=== modified file 'DistUpgrade/DistUpgradeController.py'
--- DistUpgrade/DistUpgradeController.py 2014-04-11 22:30:39 +0000
+++ DistUpgrade/DistUpgradeController.py 2014-04-24 08:46:39 +0000
@@ -307,8 +307,8 @@
307 "over ssh currently because in case of failure "307 "over ssh currently because in case of failure "
308 "it is harder to recover.\n\n"308 "it is harder to recover.\n\n"
309 "If you continue, an additional ssh daemon will be "309 "If you continue, an additional ssh daemon will be "
310 "started at port '%s'.\n"310 "started at port '{0}'.\n"
311 "Do you want to continue?") % port)311 "Do you want to continue?").format(port))
312 # abort312 # abort
313 if res == False:313 if res == False:
314 sys.exit(1)314 sys.exit(1)
@@ -318,10 +318,10 @@
318 if res == 0:318 if res == 0:
319 summary = _("Starting additional sshd")319 summary = _("Starting additional sshd")
320 descr = _("To make recovery in case of failure easier, an "320 descr = _("To make recovery in case of failure easier, an "
321 "additional sshd will be started on port '%s'. "321 "additional sshd will be started on port '{0}'. "
322 "If anything goes wrong with the running ssh "322 "If anything goes wrong with the running ssh "
323 "you can still connect to the additional one.\n"323 "you can still connect to the additional one.\n"
324 ) % port324 ).format(port)
325 if iptables_active():325 if iptables_active():
326 cmd = "iptables -I INPUT -p tcp --dport %s -j ACCEPT" % port326 cmd = "iptables -I INPUT -p tcp --dport %s -j ACCEPT" % port
327 descr += _(327 descr += _(
@@ -398,8 +398,9 @@
398 if not (release == self.fromDist or release == self.toDist):398 if not (release == self.fromDist or release == self.toDist):
399 logging.error("Bad upgrade: '%s' != '%s' " % (release, self.fromDist))399 logging.error("Bad upgrade: '%s' != '%s' " % (release, self.fromDist))
400 self._view.error(_("Can not upgrade"),400 self._view.error(_("Can not upgrade"),
401 _("An upgrade from '%s' to '%s' is not "401 _("An upgrade from '{0}' to '{1}' is not "
402 "supported with this tool." % (release, self.toDist)))402 "supported with this tool.").format(
403 release, self.toDist))
403 sys.exit(1)404 sys.exit(1)
404405
405 # setup aufs406 # setup aufs
@@ -417,11 +418,11 @@
417 self._view.information(_("Sandbox mode"),418 self._view.information(_("Sandbox mode"),
418 _("This upgrade is running in sandbox "419 _("This upgrade is running in sandbox "
419 "(test) mode. All changes are written "420 "(test) mode. All changes are written "
420 "to '%s' and will be lost on the next "421 "to '{0}' and will be lost on the next "
421 "reboot.\n\n"422 "reboot.\n\n"
422 "*No* changes written to a system directory "423 "*No* changes written to a system directory "
423 "from now until the next reboot are "424 "from now until the next reboot are "
424 "permanent.") % aufs_rw_dir)425 "permanent.").format(aufs_rw_dir))
425426
426 # setup backports (if we have them)427 # setup backports (if we have them)
427 if self.options and self.options.havePrerequists:428 if self.options and self.options.havePrerequists:
@@ -482,12 +483,12 @@
482 if os.path.exists(systemdir) and not os.access(systemdir, os.W_OK):483 if os.path.exists(systemdir) and not os.access(systemdir, os.W_OK):
483 logging.error("%s not writable" % systemdir)484 logging.error("%s not writable" % systemdir)
484 self._view.error(485 self._view.error(
485 _("Can not write to '%s'") % systemdir,486 _("Can not write to '{0}'").format(systemdir),
486 _("Its not possible to write to the system directory "487 _("Its not possible to write to the system directory "
487 "'%s' on your system. The upgrade can not "488 "'{0}' on your system. The upgrade can not "
488 "continue.\n"489 "continue.\n"
489 "Please make sure that the system directory is "490 "Please make sure that the system directory is "
490 "writable.") % systemdir)491 "writable.").format(systemdir))
491 self.abort()492 self.abort()
492 493
493494
@@ -640,7 +641,7 @@
640 "%s-proposed" % self.fromDist in entry.dist):641 "%s-proposed" % self.fromDist in entry.dist):
641 logging.debug("upgrade to development release, disabling proposed")642 logging.debug("upgrade to development release, disabling proposed")
642 entry.dist = "%s-proposed" % self.toDist643 entry.dist = "%s-proposed" % self.toDist
643 entry.comment += _("Not for humans during development stage of release %s") % self.toDist644 entry.comment += _("Not for humans during development stage of release {0}").format(self.toDist)
644 entry.disabled = True645 entry.disabled = True
645 continue646 continue
646647
@@ -726,7 +727,7 @@
726 # disable anything that is not from a official mirror or a whitelisted third party727 # disable anything that is not from a official mirror or a whitelisted third party
727 if entry.dist == self.fromDist:728 if entry.dist == self.fromDist:
728 entry.dist = self.toDist729 entry.dist = self.toDist
729 disable_comment = " " + _("disabled on upgrade to %s") % self.toDist730 disable_comment = " " + _("disabled on upgrade to {0}").format(self.toDist)
730 if isinstance(entry.comment, bytes):731 if isinstance(entry.comment, bytes):
731 entry.comment += disable_comment.encode('UTF-8')732 entry.comment += disable_comment.encode('UTF-8')
732 else:733 else:
@@ -770,10 +771,10 @@
770 "out of date.\n\n"771 "out of date.\n\n"
771 "Do you want to rewrite your "772 "Do you want to rewrite your "
772 "'sources.list' file anyway? If you choose "773 "'sources.list' file anyway? If you choose "
773 "'Yes' here it will update all '%s' to '%s' "774 "'Yes' here it will update all '{0}' to '{1}' "
774 "entries.\n"775 "entries.\n"
775 "If you select 'No' the upgrade will cancel."776 "If you select 'No' the upgrade will cancel."
776 ) % (self.fromDist, self.toDist))777 ).format(self.fromDist, self.toDist))
777 if res:778 if res:
778 # re-init the sources and try again779 # re-init the sources and try again
779 self.sources = SourcesList(matcherPath=".")780 self.sources = SourcesList(matcherPath=".")
@@ -784,10 +785,10 @@
784 #hm, still nothing useful ...785 #hm, still nothing useful ...
785 prim = _("Generate default sources?")786 prim = _("Generate default sources?")
786 secon = _("After scanning your 'sources.list' no "787 secon = _("After scanning your 'sources.list' no "
787 "valid entry for '%s' was found.\n\n"788 "valid entry for '{0}' was found.\n\n"
788 "Should default entries for '%s' be "789 "Should default entries for '{1}' be "
789 "added? If you select 'No', the upgrade "790 "added? If you select 'No', the upgrade "
790 "will cancel.") % (self.fromDist, self.toDist)791 "will cancel.").format(self.fromDist, self.toDist)
791 if not self._view.askYesNoQuestion(prim, secon):792 if not self._view.askYesNoQuestion(prim, secon):
792 self.abort()793 self.abort()
793794
@@ -880,17 +881,17 @@
880 header = ngettext("Package in inconsistent state",881 header = ngettext("Package in inconsistent state",
881 "Packages in inconsistent state",882 "Packages in inconsistent state",
882 len(reqreinst))883 len(reqreinst))
883 summary = ngettext("The package '%s' is in an inconsistent "884 summary = ngettext("The package '{0}' is in an inconsistent "
884 "state and needs to be reinstalled, but "885 "state and needs to be reinstalled, but "
885 "no archive can be found for it. "886 "no archive can be found for it. "
886 "Please reinstall the package manually "887 "Please reinstall the package manually "
887 "or remove it from the system.",888 "or remove it from the system.",
888 "The packages '%s' are in an inconsistent "889 "The packages '{0}' are in an inconsistent "
889 "state and need to be reinstalled, but "890 "state and need to be reinstalled, but "
890 "no archive can be found for them. "891 "no archive can be found for them. "
891 "Please reinstall the packages manually "892 "Please reinstall the packages manually "
892 "or remove them from the system.",893 "or remove them from the system.",
893 len(reqreinst)) % ", ".join(reqreinst)894 len(reqreinst)).format(", ".join(reqreinst))
894 self._view.error(header, summary)895 self._view.error(header, summary)
895 return False896 return False
896 # FIXME: check out what packages are downloadable etc to897 # FIXME: check out what packages are downloadable etc to
@@ -899,8 +900,8 @@
899 self.foreign_pkgs = self.cache._getForeignPkgs(self.origin, self.fromDist, self.toDist)900 self.foreign_pkgs = self.cache._getForeignPkgs(self.origin, self.fromDist, self.toDist)
900 if self.serverMode:901 if self.serverMode:
901 self.tasks = self.cache.installedTasks902 self.tasks = self.cache.installedTasks
902 logging.debug("Foreign: %s" % " ".join(self.foreign_pkgs))903 logging.debug("Foreign: {0}".format(" ".join(self.foreign_pkgs)))
903 logging.debug("Obsolete: %s" % " ".join(self.obsolete_pkgs))904 logging.debug("Obsolete: {0}".format(" ".join(self.obsolete_pkgs)))
904 return True905 return True
905906
906 def doUpdate(self, showErrors=True, forceRetries=None):907 def doUpdate(self, showErrors=True, forceRetries=None):
@@ -940,9 +941,10 @@
940 " this checks if we have enough free space on /var and /usr"941 " this checks if we have enough free space on /var and /usr"
941 err_sum = _("Not enough free disk space")942 err_sum = _("Not enough free disk space")
942 err_long= _("The upgrade has aborted. "943 err_long= _("The upgrade has aborted. "
943 "The upgrade needs a total of %s free space on disk '%s'. "944 "The upgrade needs a total of {0} free space on disk "
944 "Please free at least an additional %s of disk "945 "'{1}'. "
945 "space on '%s'. "946 "Please free at least an additional {2} of disk "
947 "space on '{3}'. "
946 "Empty your trash and remove temporary "948 "Empty your trash and remove temporary "
947 "packages of former installations using "949 "packages of former installations using "
948 "'sudo apt-get clean'.")950 "'sudo apt-get clean'.")
@@ -959,10 +961,10 @@
959 # perspective, but it means we do not need to break the961 # perspective, but it means we do not need to break the
960 # string freeze962 # string freeze
961 for required in e.free_space_required_list:963 for required in e.free_space_required_list:
962 self._view.error(err_sum, err_long % (required.size_total,964 self._view.error(err_sum, err_long.format(required.size_total,
963 required.dir,965 required.dir,
964 required.size_needed,966 required.size_needed,
965 required.dir))967 required.dir))
966 return False968 return False
967 return True969 return True
968970
@@ -1172,7 +1174,7 @@
1172 "http://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+filebug "1174 "http://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+filebug "
1173 "and attach the files in /var/log/dist-upgrade/ "1175 "and attach the files in /var/log/dist-upgrade/ "
1174 "to the bug report.\n"1176 "to the bug report.\n"
1175 "%s" % e)1177 "{0}".format(e))
1176 self._view.error(_("Could not install the upgrades"), msg)1178 self._view.error(_("Could not install the upgrades"), msg)
1177 # installing the packages failed, can't be retried1179 # installing the packages failed, can't be retried
1178 cmd = ["/usr/bin/dpkg","--configure","-a"]1180 cmd = ["/usr/bin/dpkg","--configure","-a"]
@@ -1208,7 +1210,7 @@
1208 _("The upgrade has aborted. Please check your "\1210 _("The upgrade has aborted. Please check your "\
1209 "Internet connection or "\1211 "Internet connection or "\
1210 "installation media and try again. "),1212 "installation media and try again. "),
1211 "%s" % e)1213 "{0}".format(e))
1212 # abort here because we want our sources.list back1214 # abort here because we want our sources.list back
1213 self.abort()1215 self.abort()
12141216
@@ -1301,7 +1303,7 @@
1301 _("A problem occurred during the clean-up. "1303 _("A problem occurred during the clean-up. "
1302 "Please see the below message for more "1304 "Please see the below message for more "
1303 "information. "),1305 "information. "),
1304 "%s" % e)1306 "{0}".format(e))
1305 # run stuff after cleanup1307 # run stuff after cleanup
1306 self.quirks.run("PostCleanup")1308 self.quirks.run("PostCleanup")
1307 # run the post upgrade scripts that can do fixup like xorg.conf1309 # run the post upgrade scripts that can do fixup like xorg.conf
@@ -1375,8 +1377,8 @@
1375 # FIXME: instead of error out, fetch and install it1377 # FIXME: instead of error out, fetch and install it
1376 # here1378 # here
1377 self._view.error(_("Required depends is not installed"),1379 self._view.error(_("Required depends is not installed"),
1378 _("The required dependency '%s' is not "1380 _("The required dependency '{0}' is not "
1379 "installed. " % dep))1381 "installed. ".format(dep)))
1380 sys.exit(1)1382 sys.exit(1)
1381 return res 1383 return res
13821384
@@ -1755,7 +1757,7 @@
1755 logging.error("No '%s' available/downloadable after sources.list rewrite+update" % pkg)1757 logging.error("No '%s' available/downloadable after sources.list rewrite+update" % pkg)
1756 self._view.error(_("Invalid package information"),1758 self._view.error(_("Invalid package information"),
1757 _("After updating your package "1759 _("After updating your package "
1758 "information, the essential package '%s' "1760 "information, the essential package '{0}' "
1759 "could not be located. This may be "1761 "could not be located. This may be "
1760 "because you have no official mirrors "1762 "because you have no official mirrors "
1761 "listed in your software sources, or "1763 "listed in your software sources, or "
@@ -1765,8 +1767,7 @@
1765 "software sources."1767 "software sources."
1766 "\n"1768 "\n"
1767 "In the case of an overloaded mirror, you "1769 "In the case of an overloaded mirror, you "
1768 "may want to try the upgrade again later.")1770 "may want to try the upgrade again later.").format(pkg))
1769 % pkg)
1770 if os.path.exists("/usr/bin/apport-bug"):1771 if os.path.exists("/usr/bin/apport-bug"):
1771 subprocess.Popen(["apport-bug", "ubuntu-release-upgrader-core"])1772 subprocess.Popen(["apport-bug", "ubuntu-release-upgrader-core"])
1772 else:1773 else:
17731774
=== modified file 'DistUpgrade/DistUpgradeFetcherCore.py'
--- DistUpgrade/DistUpgradeFetcherCore.py 2014-02-25 00:14:50 +0000
+++ DistUpgrade/DistUpgradeFetcherCore.py 2014-04-24 08:46:39 +0000
@@ -72,9 +72,9 @@
72 f = self.tmpdir + "/" + os.path.basename(self.new_dist.upgradeTool)72 f = self.tmpdir + "/" + os.path.basename(self.new_dist.upgradeTool)
73 sig = self.tmpdir + "/" + os.path.basename(73 sig = self.tmpdir + "/" + os.path.basename(
74 self.new_dist.upgradeToolSig)74 self.new_dist.upgradeToolSig)
75 print(_("authenticate '%(file)s' against '%(signature)s' ") % {75 print(_("authenticate '{file}' against '{signature}' ").format(
76 'file': os.path.basename(f),76 file=os.path.basename(f),
77 'signature': os.path.basename(sig)})77 signature=os.path.basename(sig)))
78 if self.gpgauthenticate(f, sig):78 if self.gpgauthenticate(f, sig):
79 return True79 return True
80 return False80 return False
@@ -136,7 +136,7 @@
136 def extractDistUpgrader(self):136 def extractDistUpgrader(self):
137 # extract the tarball137 # extract the tarball
138 fname = os.path.join(self.tmpdir, os.path.basename(self.uri))138 fname = os.path.join(self.tmpdir, os.path.basename(self.uri))
139 print(_("extracting '%s'") % os.path.basename(fname))139 print(_("extracting '{0}'").format(os.path.basename(fname)))
140 if not os.path.exists(fname):140 if not os.path.exists(fname):
141 return False141 return False
142 try:142 try:
@@ -316,7 +316,7 @@
316 return False316 return False
317 else:317 else:
318 self.error(_("Can not run the upgrade"),318 self.error(_("Can not run the upgrade"),
319 _("The error message is '%s'.") % e.strerror)319 _("The error message is '{0}'.").format(e.strerror))
320 return True320 return True
321321
322if __name__ == "__main__":322if __name__ == "__main__":
323323
=== modified file 'DistUpgrade/DistUpgradeFetcherKDE.py'
--- DistUpgrade/DistUpgradeFetcherKDE.py 2014-02-25 00:28:19 +0000
+++ DistUpgrade/DistUpgradeFetcherKDE.py 2014-04-24 08:46:39 +0000
@@ -157,18 +157,19 @@
157 current_item = self.total_items157 current_item = self.total_items
158 label_text = _("Downloading additional package files...")158 label_text = _("Downloading additional package files...")
159 if self.current_cps > 0:159 if self.current_cps > 0:
160 label_text += _("File %s of %s at %sB/s") % (160 label_text += _("File {0} of {1} at {2}B/s").format(
161 self.current_items, self.total_items,161 self.current_items, self.total_items,
162 apt_pkg.size_to_str(self.current_cps))162 apt_pkg.size_to_str(self.current_cps))
163 else:163 else:
164 label_text += _("File %s of %s") % (164 label_text += _("File {0} of {1}").format(
165 self.current_items, self.total_items)165 self.current_items, self.total_items)
166 self.label.setText(label_text)166 self.label.setText(label_text)
167 KApplication.kApplication().processEvents()167 KApplication.kApplication().processEvents()
168 return True168 return True
169169
170 def mediaChange(self, medium, drive):170 def mediaChange(self, medium, drive):
171 msg = _("Please insert '%s' into the drive '%s'") % (medium, drive)171 msg = _("Please insert '{0}' into the drive '{1}'").format(
172 medium, drive)
172 #change = QMessageBox.question(None, _("Media Change"), msg,173 #change = QMessageBox.question(None, _("Media Change"), msg,
173 # QMessageBox.Ok, QMessageBox.Cancel)174 # QMessageBox.Ok, QMessageBox.Cancel)
174 change = KMessageBox.questionYesNo(None, _("Media Change"),175 change = KMessageBox.questionYesNo(None, _("Media Change"),
175176
=== modified file 'DistUpgrade/DistUpgradeGettext.py'
--- DistUpgrade/DistUpgradeGettext.py 2012-06-13 11:40:17 +0000
+++ DistUpgrade/DistUpgradeGettext.py 2014-04-24 08:46:39 +0000
@@ -64,7 +64,9 @@
64 return ""64 return ""
65 translated_msg = unicode_gettext(_translation(), message)65 translated_msg = unicode_gettext(_translation(), message)
66 if not _verify(message, translated_msg):66 if not _verify(message, translated_msg):
67 logging.error("incorrect translation for message '%s' to '%s' (wrong number of arguments)" % (message, translated_msg))67 logging.error(
68 "incorrect translation for message '{0}' to '{1}' "
69 "(wrong number of arguments)".format(message, translated_msg))
68 return message70 return message
69 return translated_msg71 return translated_msg
7072
@@ -75,7 +77,10 @@
75 """77 """
76 translated_msg = unicode_ngettext(_translation(), msgid1, msgid2, n)78 translated_msg = unicode_ngettext(_translation(), msgid1, msgid2, n)
77 if not _verify(msgid1, translated_msg):79 if not _verify(msgid1, translated_msg):
78 logging.error("incorrect translation for ngettext message '%s' plural: '%s' to '%s' (wrong number of arguments)" % (msgid1, msgid2, translated_msg))80 logging.error(
81 "incorrect translation for ngettext message '{0}' "
82 "plural: '{1}' to '{2}' (wrong number of arguments)".format(
83 msgid1, msgid2, translated_msg))
79 # dumb fallback to not crash84 # dumb fallback to not crash
80 if n == 1:85 if n == 1:
81 return msgid186 return msgid1
8287
=== modified file 'DistUpgrade/DistUpgradeView.py'
--- DistUpgrade/DistUpgradeView.py 2014-04-14 16:16:56 +0000
+++ DistUpgrade/DistUpgradeView.py 2014-04-24 08:46:39 +0000
@@ -76,12 +76,12 @@
76 # get the fragments, this is not ideal i18n wise, but its76 # get the fragments, this is not ideal i18n wise, but its
77 # difficult to do it differently77 # difficult to do it differently
78 if days > 0:78 if days > 0:
79 map["str_days"] = ngettext("%li day","%li days", days) % days79 map["str_days"] = ngettext("{0} day","{0} days", days).format(days)
80 if hours > 0:80 if hours > 0:
81 map["str_hours"] = ngettext("%li hour","%li hours", hours) % hours81 map["str_hours"] = ngettext("{0} hour","{0} hours", hours).format(hours)
82 if minutes > 0:82 if minutes > 0:
83 map["str_minutes"] = ngettext("%li minute","%li minutes", minutes) % minutes83 map["str_minutes"] = ngettext("{0} minute","{0} minutes", minutes).format(minutes)
84 map["str_seconds"] = ngettext("%li second","%li seconds", seconds) % seconds84 map["str_seconds"] = ngettext("{0} second","{0} seconds", seconds).format(seconds)
8585
86 # now assemble the string86 # now assemble the string
87 if days > 0:87 if days > 0:
@@ -97,7 +97,8 @@
97 # plural form97 # plural form
98 # 98 #
99 # Note: most western languages will not need to change this99 # Note: most western languages will not need to change this
100 return _("%(str_days)s %(str_hours)s") % map100 return _("{str_days} {str_hours}").format(str_days=map["str_days"],
101 str_hours=map["str_hours"])
101 # display no minutes for time > 3h, see LP: #144455102 # display no minutes for time > 3h, see LP: #144455
102 elif hours > 3:103 elif hours > 3:
103 return map["str_hours"]104 return map["str_hours"]
@@ -115,7 +116,9 @@
115 # plural form116 # plural form
116 # 117 #
117 # Note: most western languages will not need to change this118 # Note: most western languages will not need to change this
118 return _("%(str_hours)s %(str_minutes)s") % map119 return _("{str_hours} {str_minutes}").format(
120 str_hours=map["str_hours"],
121 str_minutes=map["str_minutes"])
119 elif minutes > 0:122 elif minutes > 0:
120 return map["str_minutes"]123 return map["str_minutes"]
121 return map["str_seconds"]124 return map["str_seconds"]
@@ -166,11 +169,11 @@
166 if self.est_speed == 0:169 if self.est_speed == 0:
167 timeModem = required_download/(56*1024/8) # 56 kbit 170 timeModem = required_download/(56*1024/8) # 56 kbit
168 timeDSL = required_download/(1024*1024/8) # 1Mbit = 1024 kbit171 timeDSL = required_download/(1024*1024/8) # 1Mbit = 1024 kbit
169 s= _("This download will take about %s with a 1Mbit DSL connection "172 s= _("This download will take about {0} with a 1Mbit DSL connection "
170 "and about %s with a 56k modem.") % (FuzzyTimeToStr(timeDSL), FuzzyTimeToStr(timeModem))173 "and about {1} with a 56k modem.").format(FuzzyTimeToStr(timeDSL), FuzzyTimeToStr(timeModem))
171 return s174 return s
172 # if we have a estimated speed, use it175 # if we have a estimated speed, use it
173 s = _("This download will take about %s with your connection. ") % FuzzyTimeToStr(required_download/self.est_speed)176 s = _("This download will take about {0} with your connection. ").format(FuzzyTimeToStr(required_download/self.est_speed))
174 return s177 return s
175 178
176179
@@ -366,35 +369,35 @@
366 # FIXME: show detailed packages369 # FIXME: show detailed packages
367 if len(self.demotions) > 0:370 if len(self.demotions) > 0:
368 msg += ngettext(371 msg += ngettext(
369 "%(amount)d installed package is no longer supported by Canonical. "372 "{amount} installed package is no longer supported by Canonical. "
370 "You can still get support from the community.",373 "You can still get support from the community.",
371 "%(amount)d installed packages are no longer supported by "374 "{amount} installed packages are no longer supported by "
372 "Canonical. You can still get support from the community.",375 "Canonical. You can still get support from the community.",
373 len(self.demotions)) % { 'amount' : len(self.demotions) }376 len(self.demotions)).format(amount=len(self.demotions))
374 msg += "\n\n"377 msg += "\n\n"
375 if pkgs_remove > 0:378 if pkgs_remove > 0:
376 # FIXME: make those two separate lines to make it clear379 # FIXME: make those two separate lines to make it clear
377 # that the "%" applies to the result of ngettext380 # that the "%" applies to the result of ngettext
378 msg += ngettext("%d package is going to be removed.",381 msg += ngettext("{0} package is going to be removed.",
379 "%d packages are going to be removed.",382 "{0} packages are going to be removed.",
380 pkgs_remove) % pkgs_remove383 pkgs_remove).format(pkgs_remove)
381 msg += " "384 msg += " "
382 if pkgs_inst > 0:385 if pkgs_inst > 0:
383 msg += ngettext("%d new package is going to be "386 msg += ngettext("{0} new package is going to be "
384 "installed.",387 "installed.",
385 "%d new packages are going to be "388 "{0} new packages are going to be "
386 "installed.",pkgs_inst) % pkgs_inst389 "installed.",pkgs_inst).format(pkgs_inst)
387 msg += " "390 msg += " "
388 if pkgs_upgrade > 0:391 if pkgs_upgrade > 0:
389 msg += ngettext("%d package is going to be upgraded.",392 msg += ngettext("{0} package is going to be upgraded.",
390 "%d packages are going to be upgraded.",393 "{0} packages are going to be upgraded.",
391 pkgs_upgrade) % pkgs_upgrade394 pkgs_upgrade).format(pkgs_upgrade)
392 msg +=" "395 msg +=" "
393 if downloadSize > 0:396 if downloadSize > 0:
394 downloadSizeStr = apt_pkg.size_to_str(downloadSize)397 downloadSizeStr = apt_pkg.size_to_str(downloadSize)
395 if isinstance(downloadSizeStr, bytes):398 if isinstance(downloadSizeStr, bytes):
396 downloadSizeStr = downloadSizeStr.decode(ENCODING)399 downloadSizeStr = downloadSizeStr.decode(ENCODING)
397 msg += _("\n\nYou have to download a total of %s. ") % (400 msg += _("\n\nYou have to download a total of {0}. ").format(
398 downloadSizeStr)401 downloadSizeStr)
399 msg += self.getAcquireProgress().estimatedDownloadTime(downloadSize)402 msg += self.getAcquireProgress().estimatedDownloadTime(downloadSize)
400 if ((pkgs_upgrade + pkgs_inst) > 0) and ((pkgs_upgrade + pkgs_inst + pkgs_remove) > 100):403 if ((pkgs_upgrade + pkgs_inst) > 0) and ((pkgs_upgrade + pkgs_inst + pkgs_remove) > 100):
401404
=== modified file 'DistUpgrade/DistUpgradeViewGtk3.py'
--- DistUpgrade/DistUpgradeViewGtk3.py 2014-04-24 08:42:34 +0000
+++ DistUpgrade/DistUpgradeViewGtk3.py 2014-04-24 08:46:39 +0000
@@ -112,7 +112,7 @@
112 self.canceled = True112 self.canceled = True
113 def media_change(self, medium, drive):113 def media_change(self, medium, drive):
114 #print("mediaChange %s %s" % (medium, drive))114 #print("mediaChange %s %s" % (medium, drive))
115 msg = _("Please insert '%s' into the drive '%s'") % (medium,drive)115 msg = _("Please insert '{0}' into the drive '{0}'").format(medium,drive)
116 dialog = Gtk.MessageDialog(parent=self.parent.window_main,116 dialog = Gtk.MessageDialog(parent=self.parent.window_main,
117 flags=Gtk.DialogFlags.MODAL,117 flags=Gtk.DialogFlags.MODAL,
118 type=Gtk.MessageType.QUESTION,118 type=Gtk.MessageType.QUESTION,
@@ -148,12 +148,13 @@
148 if isinstance(current_cps, bytes):148 if isinstance(current_cps, bytes):
149 current_cps = current_cps.decode(149 current_cps = current_cps.decode(
150 locale.getpreferredencoding())150 locale.getpreferredencoding())
151 self.status.set_text(_("Fetching file %li of %li at %sB/s") % (151 self.status.set_text(
152 currentItem, self.total_items, current_cps))152 _("Fetching file {0} of {1} at {2}B/s").format(
153 self.progress.set_text(_("About %s remaining") % FuzzyTimeToStr(153 currentItem, self.total_items, current_cps))
154 self.eta))154 self.progress.set_text(_("About {0} remaining").format(
155 FuzzyTimeToStr(self.eta)))
155 else:156 else:
156 self.status.set_text(_("Fetching file %li of %li") % (157 self.status.set_text(_("Fetching file {0} of {1}").format(
157 currentItem, self.total_items))158 currentItem, self.total_items))
158 self.progress.set_text(" ")159 self.progress.set_text(" ")
159 while Gtk.events_pending():160 while Gtk.events_pending():
@@ -215,11 +216,11 @@
215216
216 #self.expander_terminal.set_expanded(True)217 #self.expander_terminal.set_expanded(True)
217 self.parent.dialog_error.set_transient_for(self.parent.window_main)218 self.parent.dialog_error.set_transient_for(self.parent.window_main)
218 summary = _("Could not install '%s'") % pkg219 summary = _("Could not install '{0}'").format(pkg)
219 msg = _("The upgrade will continue but the '%s' package may not "220 msg = _("The upgrade will continue but the '{0}' package may not "
220 "be in a working state. Please consider submitting a "221 "be in a working state. Please consider submitting a "
221 "bug report about it.") % pkg222 "bug report about it.").format(pkg)
222 markup="<big><b>%s</b></big>\n\n%s" % (summary, msg)223 markup="<big><b>{0}</b></big>\n\n{1}".format(summary, msg)
223 self.parent.dialog_error.realize()224 self.parent.dialog_error.realize()
224 self.parent.dialog_error.set_title("")225 self.parent.dialog_error.set_title("")
225 self.parent.dialog_error.get_window().set_functions(Gdk.WMFunction.MOVE)226 self.parent.dialog_error.get_window().set_functions(Gdk.WMFunction.MOVE)
@@ -233,11 +234,12 @@
233 logging.debug("got a conffile-prompt from dpkg for file: '%s'" % current)234 logging.debug("got a conffile-prompt from dpkg for file: '%s'" % current)
234 start = time.time()235 start = time.time()
235 #self.expander.set_expanded(True)236 #self.expander.set_expanded(True)
236 prim = _("Replace the customized configuration file\n'%s'?") % current237 prim = _("Replace the customized configuration file\n'{0}'?").format(
238 current)
237 sec = _("You will lose any changes you have made to this "239 sec = _("You will lose any changes you have made to this "
238 "configuration file if you choose to replace it with "240 "configuration file if you choose to replace it with "
239 "a newer version.")241 "a newer version.")
240 markup = "<span weight=\"bold\" size=\"larger\">%s </span> \n\n%s" % (prim, sec)242 markup = "<span weight=\"bold\" size=\"larger\">{0} </span> \n\n{1}".format(prim, sec)
241 self.parent.label_conffile.set_markup(markup)243 self.parent.label_conffile.set_markup(markup)
242 self.parent.dialog_conffile.set_title("")244 self.parent.dialog_conffile.set_title("")
243 self.parent.dialog_conffile.set_transient_for(self.parent.window_main)245 self.parent.dialog_conffile.set_transient_for(self.parent.window_main)
@@ -254,7 +256,8 @@
254 diff = diff.decode("UTF-8", "replace")256 diff = diff.decode("UTF-8", "replace")
255 self.parent.textview_conffile.get_buffer().set_text(diff)257 self.parent.textview_conffile.get_buffer().set_text(diff)
256 else:258 else:
257 self.parent.textview_conffile.get_buffer().set_text(_("The 'diff' command was not found"))259 self.parent.textview_conffile.get_buffer().set_text(
260 _("The 'diff' command was not found"))
258 res = self.parent.dialog_conffile.run()261 res = self.parent.dialog_conffile.run()
259 self.parent.dialog_conffile.hide()262 self.parent.dialog_conffile.hide()
260 self.time_ui += time.time() - start263 self.time_ui += time.time() - start
@@ -307,7 +310,8 @@
307 eta = (100.0 - percent) * time_per_percent310 eta = (100.0 - percent) * time_per_percent
308 # only show if we have some sensible data (60sec < eta < 2days)311 # only show if we have some sensible data (60sec < eta < 2days)
309 if eta > 61.0 and eta < (60*60*24*2):312 if eta > 61.0 and eta < (60*60*24*2):
310 self.progress.set_text(_("About %s remaining") % FuzzyTimeToStr(eta))313 self.progress.set_text(
314 _("About {0} remaining").format(FuzzyTimeToStr(eta)))
311 else:315 else:
312 self.progress.set_text(" ")316 self.progress.set_text(" ")
313 # 2 == WEBKIT_LOAD_FINISHED - the enums is not exposed via python317 # 2 == WEBKIT_LOAD_FINISHED - the enums is not exposed via python
@@ -652,16 +656,16 @@
652 # fill in the details656 # fill in the details
653 self.details_list.clear()657 self.details_list.clear()
654 for (parent_text, details_list) in (658 for (parent_text, details_list) in (
655 ( _("No longer supported by Canonical (%s)"), self.demotions),659 ( _("No longer supported by Canonical ({0})"), self.demotions),
656 ( _("<b>Downgrade (%s)</b>"), self.toDowngrade),660 ( _("<b>Downgrade ({0})</b>"), self.toDowngrade),
657 ( _("Remove (%s)"), self.toRemove),661 ( _("Remove ({0})"), self.toRemove),
658 ( _("No longer needed (%s)"), self.toRemoveAuto),662 ( _("No longer needed ({0})"), self.toRemoveAuto),
659 ( _("Install (%s)"), self.toInstall),663 ( _("Install ({0})"), self.toInstall),
660 ( _("Upgrade (%s)"), self.toUpgrade),664 ( _("Upgrade ({0})"), self.toUpgrade),
661 ):665 ):
662 if details_list:666 if details_list:
663 node = self.details_list.append(None,667 node = self.details_list.append(None,
664 [parent_text % len(details_list)])668 [parent_text.format(len(details_list))])
665 for pkg in details_list:669 for pkg in details_list:
666 self.details_list.append(node, ["<b>%s</b> - %s" % (670 self.details_list.append(node, ["<b>%s</b> - %s" % (
667 pkg.name, GLib.markup_escape_text(getattr(pkg.candidate, "summary", None)))])671 pkg.name, GLib.markup_escape_text(getattr(pkg.candidate, "summary", None)))])
668672
=== modified file 'DistUpgrade/DistUpgradeViewKDE.py'
--- DistUpgrade/DistUpgradeViewKDE.py 2012-10-09 16:35:12 +0000
+++ DistUpgrade/DistUpgradeViewKDE.py 2014-04-24 08:46:39 +0000
@@ -193,7 +193,7 @@
193 self.parent = parent193 self.parent = parent
194194
195 def media_change(self, medium, drive):195 def media_change(self, medium, drive):
196 msg = _("Please insert '%s' into the drive '%s'") % (medium,drive)196 msg = _("Please insert '{0}' into the drive '{1}'").format(medium,drive)
197 change = QMessageBox.question(self.parent.window_main, _("Media Change"), msg, QMessageBox.Ok, QMessageBox.Cancel)197 change = QMessageBox.question(self.parent.window_main, _("Media Change"), msg, QMessageBox.Ok, QMessageBox.Cancel)
198 if change == QMessageBox.Ok:198 if change == QMessageBox.Ok:
199 return True199 return True
@@ -223,10 +223,15 @@
223 current_cps = apt_pkg.size_to_str(self.current_cps)223 current_cps = apt_pkg.size_to_str(self.current_cps)
224 if isinstance(current_cps, bytes):224 if isinstance(current_cps, bytes):
225 current_cps = current_cps.decode(locale.getpreferredencoding())225 current_cps = current_cps.decode(locale.getpreferredencoding())
226 self.status.setText(_("Fetching file %li of %li at %sB/s") % (current_item, self.total_items, current_cps))226 self.status.setText(_("Fetching file {0} of {1} at {2}B/s").format(
227 self.parent.window_main.progress_text.setText("<i>" + _("About %s remaining") % FuzzyTimeToStr(self.eta) + "</i>")227 current_item, self.total_items, current_cps))
228 self.parent.window_main.progress_text.setText(
229 "<i>" + _("About {0} remaining").format(
230 FuzzyTimeToStr(self.eta)) +
231 "</i>")
228 else:232 else:
229 self.status.setText(_("Fetching file %li of %li") % (current_item, self.total_items))233 self.status.setText(_("Fetching file {0} of {1}").format(
234 current_item, self.total_items))
230 self.parent.window_main.progress_text.setText(" ")235 self.parent.window_main.progress_text.setText(" ")
231236
232 QApplication.processEvents()237 QApplication.processEvents()
@@ -278,10 +283,10 @@
278 # we do not report followup errors from earlier failures283 # we do not report followup errors from earlier failures
279 if gettext.dgettext('dpkg', "dependency problems - leaving unconfigured") in errormsg:284 if gettext.dgettext('dpkg', "dependency problems - leaving unconfigured") in errormsg:
280 return False285 return False
281 summary = _("Could not install '%s'") % pkg286 summary = _("Could not install '{0}'").format(pkg)
282 msg = _("The upgrade will continue but the '%s' package may not "287 msg = _("The upgrade will continue but the '{0}' package may not "
283 "be in a working state. Please consider submitting a "288 "be in a working state. Please consider submitting a "
284 "bug report about it.") % pkg289 "bug report about it.").format(pkg)
285 msg = "<big><b>%s</b></big><br />%s" % (summary, msg)290 msg = "<big><b>%s</b></big><br />%s" % (summary, msg)
286291
287 dialogue = QDialog(self.parent.window_main)292 dialogue = QDialog(self.parent.window_main)
@@ -300,11 +305,13 @@
300 """ask question in case conffile has been changed by user"""305 """ask question in case conffile has been changed by user"""
301 logging.debug("got a conffile-prompt from dpkg for file: '%s'" % current)306 logging.debug("got a conffile-prompt from dpkg for file: '%s'" % current)
302 start = time.time()307 start = time.time()
303 prim = _("Replace the customized configuration file\n'%s'?") % current308 prim = _("Replace the customized configuration file\n'{0}'?").format(
309 current)
304 sec = _("You will lose any changes you have made to this "310 sec = _("You will lose any changes you have made to this "
305 "configuration file if you choose to replace it with "311 "configuration file if you choose to replace it with "
306 "a newer version.")312 "a newer version.")
307 markup = "<span weight=\"bold\" size=\"larger\">%s </span> \n\n%s" % (prim, sec)313 markup = "<span weight=\"bold\" size=\"larger\">{0} </span> "\
314 "\n\n{1}".format(prim, sec)
308 self.confDialogue = QDialog(self.parent.window_main)315 self.confDialogue = QDialog(self.parent.window_main)
309 loadUi("dialog_conffile.ui", self.confDialogue)316 loadUi("dialog_conffile.ui", self.confDialogue)
310 self.confDialogue.label_conffile.setText(markup)317 self.confDialogue.label_conffile.setText(markup)
@@ -372,7 +379,8 @@
372 eta = (100.0 - self.percent) * time_per_percent379 eta = (100.0 - self.percent) * time_per_percent
373 # only show if we have some sensible data (60sec < eta < 2days)380 # only show if we have some sensible data (60sec < eta < 2days)
374 if eta > 61.0 and eta < (60*60*24*2):381 if eta > 61.0 and eta < (60*60*24*2):
375 self.progress_text.setText(_("About %s remaining") % FuzzyTimeToStr(eta))382 self.progress_text.setText(_("About {0} remaining").format(
383 FuzzyTimeToStr(eta)))
376 else:384 else:
377 self.progress_text.setText(" ")385 self.progress_text.setText(" ")
378386
@@ -778,15 +786,15 @@
778 self.changesDialogue.treeview_details.setHeaderLabels(["Packages"])786 self.changesDialogue.treeview_details.setHeaderLabels(["Packages"])
779 self.changesDialogue.treeview_details.header().hide()787 self.changesDialogue.treeview_details.header().hide()
780 for demoted in self.demotions:788 for demoted in self.demotions:
781 self.changesDialogue.treeview_details.insertTopLevelItem(0, QTreeWidgetItem(self.changesDialogue.treeview_details, [_("No longer supported %s") % demoted.name]) )789 self.changesDialogue.treeview_details.insertTopLevelItem(0, QTreeWidgetItem(self.changesDialogue.treeview_details, [_("No longer supported {0}").format(demoted.name)]) )
782 for rm in self.toRemove:790 for rm in self.toRemove:
783 self.changesDialogue.treeview_details.insertTopLevelItem(0, QTreeWidgetItem(self.changesDialogue.treeview_details, [_("Remove %s") % rm.name]) )791 self.changesDialogue.treeview_details.insertTopLevelItem(0, QTreeWidgetItem(self.changesDialogue.treeview_details, [_("Remove {0}").format(rm.name)]) )
784 for rm in self.toRemoveAuto:792 for rm in self.toRemoveAuto:
785 self.changesDialogue.treeview_details.insertTopLevelItem(0, QTreeWidgetItem(self.changesDialogue.treeview_details, [_("Remove (was auto installed) %s") % rm.name]) )793 self.changesDialogue.treeview_details.insertTopLevelItem(0, QTreeWidgetItem(self.changesDialogue.treeview_details, [_("Remove (was auto installed) {0}").format(rm.name)]) )
786 for inst in self.toInstall:794 for inst in self.toInstall:
787 self.changesDialogue.treeview_details.insertTopLevelItem(0, QTreeWidgetItem(self.changesDialogue.treeview_details, [_("Install %s") % inst.name]) )795 self.changesDialogue.treeview_details.insertTopLevelItem(0, QTreeWidgetItem(self.changesDialogue.treeview_details, [_("Install {0}").format(inst.name)]) )
788 for up in self.toUpgrade:796 for up in self.toUpgrade:
789 self.changesDialogue.treeview_details.insertTopLevelItem(0, QTreeWidgetItem(self.changesDialogue.treeview_details, [_("Upgrade %s") % up.name]) )797 self.changesDialogue.treeview_details.insertTopLevelItem(0, QTreeWidgetItem(self.changesDialogue.treeview_details, [_("Upgrade {0}").format(up.name)]) )
790798
791 #FIXME resize label, stop it being shrinkable799 #FIXME resize label, stop it being shrinkable
792 res = self.changesDialogue.exec_()800 res = self.changesDialogue.exec_()
793801
=== modified file 'DistUpgrade/DistUpgradeViewText.py'
--- DistUpgrade/DistUpgradeViewText.py 2014-04-14 12:14:57 +0000
+++ DistUpgrade/DistUpgradeViewText.py 2014-04-24 08:46:39 +0000
@@ -196,27 +196,32 @@
196 if len(self.demotions) > 0:196 if len(self.demotions) > 0:
197 output += "\n" 197 output += "\n"
198 output += twrap(198 output += twrap(
199 _("No longer supported: %s\n") % " ".join([p.name for p in self.demotions]),199 _("No longer supported: {0}\n").format(
200 " ".join([p.name for p in self.demotions])),
200 subsequent_indent=' ')201 subsequent_indent=' ')
201 if len(self.toRemove) > 0:202 if len(self.toRemove) > 0:
202 output += "\n" 203 output += "\n"
203 output += twrap(204 output += twrap(
204 _("Remove: %s\n") % " ".join([p.name for p in self.toRemove]),205 _("Remove: {0}\n").format(
206 " ".join([p.name for p in self.toRemove])),
205 subsequent_indent=' ')207 subsequent_indent=' ')
206 if len(self.toRemoveAuto) > 0:208 if len(self.toRemoveAuto) > 0:
207 output += twrap(209 output += twrap(
208 _("Remove (was auto installed) %s") % " ".join([p.name for p in self.toRemoveAuto]), 210 _("Remove (was auto installed) {0}").format(
211 " ".join([p.name for p in self.toRemoveAuto])),
209 subsequent_indent=' ')212 subsequent_indent=' ')
210 output += "\n"213 output += "\n"
211 if len(self.toInstall) > 0:214 if len(self.toInstall) > 0:
212 output += "\n"215 output += "\n"
213 output += twrap(216 output += twrap(
214 _("Install: %s\n") % " ".join([p.name for p in self.toInstall]),217 _("Install: {0}\n").format(
218 " ".join([p.name for p in self.toInstall])),
215 subsequent_indent=' ')219 subsequent_indent=' ')
216 if len(self.toUpgrade) > 0:220 if len(self.toUpgrade) > 0:
217 output += "\n" 221 output += "\n"
218 output += twrap(222 output += twrap(
219 _("Upgrade: %s\n") % " ".join([p.name for p in self.toUpgrade]),223 _("Upgrade: {0}\n").format(
224 " ".join([p.name for p in self.toUpgrade])),
220 subsequent_indent=' ')225 subsequent_indent=' ')
221 self.showInPager(output)226 self.showInPager(output)
222 print("%s %s" % (_("Continue [yN] "), _("Details [d]")), end="")227 print("%s %s" % (_("Continue [yN] "), _("Details [d]")), end="")
223228
=== modified file 'DistUpgrade/GtkProgress.py'
--- DistUpgrade/GtkProgress.py 2013-01-15 15:51:10 +0000
+++ DistUpgrade/GtkProgress.py 2014-04-24 08:46:39 +0000
@@ -70,15 +70,15 @@
70 if current_item > self.total_items:70 if current_item > self.total_items:
71 current_item = self.total_items71 current_item = self.total_items
72 if self.current_cps > 0:72 if self.current_cps > 0:
73 status_text = (_("Downloading file %(current)li of %(total)li "73 status_text = (_("Downloading file {current} of {total} "
74 "with %(speed)s/s") % {74 "with {speed}/s").format(
75 "current": current_item,75 current=current_item,
76 "total": self.total_items,76 total=self.total_items,
77 "speed": humanize_size(self.current_cps)})77 speed=humanize_size(self.current_cps)))
78 else:78 else:
79 status_text = (_("Downloading file %(current)li of %(total)li") %79 status_text = (_("Downloading file {current} of {total}").format(
80 {"current": current_item,80 current=current_item,
81 "total": self.total_items})81 total=self.total_items))
82 self.progress.set_fraction(82 self.progress.set_fraction(
83 (self.current_bytes + self.current_items) /83 (self.current_bytes + self.current_items) /
84 float(self.total_bytes + self.total_items))84 float(self.total_bytes + self.total_items))
8585
=== modified file 'check-new-release-gtk'
--- check-new-release-gtk 2013-10-05 02:17:39 +0000
+++ check-new-release-gtk 2014-04-24 08:46:39 +0000
@@ -73,7 +73,7 @@
73 self.options = options73 self.options = options
74 self.datadir = options.datadir74 self.datadir = options.datadir
75 self.new_dist = None75 self.new_dist = None
76 logging.debug("running with devel=%s proposed=%s" % (76 logging.debug("running with devel={0} proposed={0}".format(
77 options.devel_release, options.proposed_release))77 options.devel_release, options.proposed_release))
78 m = MetaRelease(useDevelopmentRelease=options.devel_release,78 m = MetaRelease(useDevelopmentRelease=options.devel_release,
79 useProposed=options.proposed_release)79 useProposed=options.proposed_release)
@@ -93,7 +93,7 @@
93 Gtk.main()93 Gtk.main()
9494
95 def new_dist_available(self, meta_release, new_dist):95 def new_dist_available(self, meta_release, new_dist):
96 logging.debug("new_dist_available: %s" % new_dist)96 logging.debug("new_dist_available: {0}".format(new_dist))
97 self.new_dist = new_dist97 self.new_dist = new_dist
98 client = Gio.Settings("com.ubuntu.update-manager")98 client = Gio.Settings("com.ubuntu.update-manager")
99 ignore_dist = client.get_string("check-new-release-ignore")99 ignore_dist = client.get_string("check-new-release-ignore")
@@ -101,7 +101,7 @@
101 # go into nag mode101 # go into nag mode
102 if (ignore_dist == new_dist.name and102 if (ignore_dist == new_dist.name and
103 meta_release.no_longer_supported is None):103 meta_release.no_longer_supported is None):
104 logging.warn("found new dist '%s' but it is on the ignore list" % new_dist.name)104 logging.warn("found new dist '{0}' but it is on the ignore list".format(new_dist.name))
105 sys.exit()105 sys.exit()
106106
107 # show alert on unsupported distros107 # show alert on unsupported distros
@@ -110,7 +110,7 @@
110 Gtk.main_quit()110 Gtk.main_quit()
111 else:111 else:
112 self.build_ui()112 self.build_ui()
113 self.window_main.set_title(_("Ubuntu %(version)s Upgrade Available") % {'version': new_dist.version})113 self.window_main.set_title(_("Ubuntu {version} Upgrade Available").format(version=new_dist.version))
114 self.window_main.show()114 self.window_main.show()
115115
116 def close(self):116 def close(self):
@@ -129,7 +129,7 @@
129 extra_args = extra_args + " --proposed"129 extra_args = extra_args + " --proposed"
130 os.execl("/bin/sh", "/bin/sh", "-c",130 os.execl("/bin/sh", "/bin/sh", "-c",
131 "/usr/bin/pkexec /usr/bin/do-release-upgrade "131 "/usr/bin/pkexec /usr/bin/do-release-upgrade "
132 "--frontend=DistUpgradeViewGtk3%s" % extra_args)132 "--frontend=DistUpgradeViewGtk3{0}".format(extra_args))
133133
134 def on_button_ask_me_later_clicked(self, button):134 def on_button_ask_me_later_clicked(self, button):
135 logging.debug("ask me later")135 logging.debug("ask me later")
@@ -141,8 +141,9 @@
141141
142 def on_button_dont_upgrade_clicked(self, button):142 def on_button_dont_upgrade_clicked(self, button):
143 #print("don't upgrade")143 #print("don't upgrade")
144 s = _("You have declined the upgrade to Ubuntu %s") % self.new_dist.version144 s = _("You have declined the upgrade to Ubuntu {0}").format(
145 self.dialog_really_do_not_upgrade.set_markup("<b>%s</b>" % s)145 self.new_dist.version)
146 self.dialog_really_do_not_upgrade.set_markup("<b>{0}</b>".format(s))
146 if self.dialog_really_do_not_upgrade.run() == Gtk.ResponseType.OK:147 if self.dialog_really_do_not_upgrade.run() == Gtk.ResponseType.OK:
147 client = Gio.Settings("com.ubuntu.update-manager")148 client = Gio.Settings("com.ubuntu.update-manager")
148 client.set_string("check-new-release-ignore", self.new_dist.name)149 client.set_string("check-new-release-ignore", self.new_dist.name)
149150
=== modified file 'do-partial-upgrade'
--- do-partial-upgrade 2012-06-28 19:22:04 +0000
+++ do-partial-upgrade 2014-04-24 08:46:39 +0000
@@ -77,7 +77,7 @@
77 data_dir = os.path.normpath(options.data_dir)+"/"77 data_dir = os.path.normpath(options.data_dir)+"/"
7878
79 if options.show_version:79 if options.show_version:
80 print("%s: version %s" % (os.path.basename(sys.argv[0]), VERSION))80 print("{0}: version {1}".format(os.path.basename(sys.argv[0]), VERSION))
81 sys.exit(0)81 sys.exit(0)
8282
83 module_name = "DistUpgrade." + options.frontend83 module_name = "DistUpgrade." + options.frontend
@@ -86,7 +86,7 @@
86 view_class = getattr(submodule, options.frontend)86 view_class = getattr(submodule, options.frontend)
87 view = view_class(data_dir)87 view = view_class(data_dir)
88 if options.frontend == "DistUpgradeViewGtk3":88 if options.frontend == "DistUpgradeViewGtk3":
89 view.label_title.set_markup("<b><big>%s</big></b>" %89 view.label_title.set_markup("<b><big>{0}</big></b>".format(
90 _("Running partial upgrade"))90 _("Running partial upgrade")))
91 controller = DistUpgradeController(view, datadir=data_dir)91 controller = DistUpgradeController(view, datadir=data_dir)
92 controller.doPartialUpgrade()92 controller.doPartialUpgrade()
9393
=== modified file 'pre-build.sh'
--- pre-build.sh 2014-04-07 12:30:43 +0000
+++ pre-build.sh 2014-04-24 08:46:39 +0000
@@ -8,6 +8,11 @@
8dpkg-checkbuilddeps -d 'python3-apt, apt-btrfs-snapshot, parsewiki, python-feedparser,8dpkg-checkbuilddeps -d 'python3-apt, apt-btrfs-snapshot, parsewiki, python-feedparser,
9 python3-mock, xvfb, gir1.2-gtk-3.0, python3-gi, python3-nose'9 python3-mock, xvfb, gir1.2-gtk-3.0, python3-gi, python3-nose'
1010
11# check the po files (LP: #1311396)
12for po in po/*.po; do
13 msgfmt -c $po
14done
15
11# update demotions16# update demotions
12(cd utils && ./demotions.py saucy trusty > demoted.cfg)17(cd utils && ./demotions.py saucy trusty > demoted.cfg)
13# when this gets enabled, make sure to add symlink in DistUpgrade18# when this gets enabled, make sure to add symlink in DistUpgrade

Subscribers

People subscribed via source and target branches