[yum-git] 2 commits - yumcommands.py yum/constants.py yum/rpmsack.py yum/sqlitesack.py
James Antill
james at linux.duke.edu
Fri May 16 17:25:51 UTC 2008
yum/constants.py | 3 +++
yum/rpmsack.py | 3 ++-
yum/sqlitesack.py | 3 ++-
yumcommands.py | 22 ++++++++++++++++++----
4 files changed, 25 insertions(+), 6 deletions(-)
New commits:
commit e6b68e82d917c91b334680374b64d6bd5f22ff65
Author: James Antill <james at and.org>
Date: Fri May 16 13:19:09 2008 -0400
Limit excessive pattern usage
diff --git a/yum/constants.py b/yum/constants.py
index 23e7f27..21c0988 100644
--- a/yum/constants.py
+++ b/yum/constants.py
@@ -97,3 +97,6 @@ RPM_TO_SQLITE = { 'packagesize' : 'size_package',
'vendor' : 'rpm_vendor',
'license' : 'rpm_license'
}
+
+# Cut over for when we should just give up and load everything
+PATTERNS_MAX = 128
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index d335e4e..7b08ab0 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -29,6 +29,7 @@ import fnmatch
import re
from misc import to_unicode
+import constants
class RPMInstalledPackage(YumInstalledPackage):
@@ -255,7 +256,7 @@ class RPMDBPackageSack(PackageSackBase):
@staticmethod
def _compile_patterns(patterns):
- if not patterns:
+ if not patterns or len(patterns) > constants.PATTERNS_MAX:
return None
ret = []
for pat in patterns:
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index f127fe4..a4391c3 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -31,6 +31,7 @@ import misc
from sqlutils import executeSQL
import rpmUtils.miscutils
import sqlutils
+import constants
def catchSqliteException(func):
"""This decorator converts sqlite exceptions into RepoError"""
@@ -940,7 +941,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
"""Builds a list of packages, only containing nevra information. No
excludes are done at this stage. """
- if patterns is None:
+ if patterns is None or len(patterns) > constants.PATTERNS_MAX:
patterns = []
returnList = []
commit 7c99bba4dc10ed9ee0942c8d8d8ff3d593f214cc
Author: James Antill <james at and.org>
Date: Fri May 16 13:18:20 2008 -0400
Add repo size to repolist info.
diff --git a/yumcommands.py b/yumcommands.py
index 0ba6689..c9f7280 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -25,6 +25,7 @@ from yum import logginglevels
from yum import _
import yum.Errors
import operator
+import locale
def checkRootUID(base):
"""
@@ -641,7 +642,10 @@ class RepoListCommand(YumCommand):
else:
arg = 'enabled'
- format_string = "%-20.20s %-40.40s %s"
+ # Setup so len(repo.sack) is correct
+ base.repos.populateSack()
+
+ format_string = "%-20.20s %-40.40s %-8s%s"
repos = base.repos.repos.values()
repos.sort()
enabled_repos = base.repos.listEnabled()
@@ -655,13 +659,20 @@ class RepoListCommand(YumCommand):
ehibeg = ''
dhibeg = ''
hiend = ''
+ tot_num = 0
for repo in repos:
if repo in enabled_repos:
enabled = True
ui_enabled = ehibeg + _('enabled') + hiend
+ num = len(repo.sack)
+ tot_num += num
+ ui_num = locale.format("%d", num, True)
+ ui_fmt_num = ": %7s"
else:
enabled = False
ui_enabled = dhibeg + _('disabled') + hiend
+ ui_num = ""
+ ui_fmt_num = "%s"
if (arg == 'all' or
(arg == 'enabled' and enabled) or
@@ -675,13 +686,16 @@ class RepoListCommand(YumCommand):
line1 = base.fmtKeyValFill(_("Repo-id : "), repo)
line2 = base.fmtKeyValFill(_("Repo-name : "), repo.name)
line3 = base.fmtKeyValFill(_("Repo-enabled: "), ui_enabled)
+ line4 = base.fmtKeyValFill(_("Repo-size : "), ui_num)
base.verbose_logger.log(logginglevels.DEBUG_3,
- "%s\n%s\n%s\n", line1, line2, line3)
+ "%s\n%s\n%s\n%s\n",
+ line1, line2, line3, line4)
else:
base.verbose_logger.log(logginglevels.INFO_2, format_string,
- repo, repo.name, ui_enabled)
+ repo, repo.name, ui_enabled,
+ ui_fmt_num % ui_num)
- return 0, []
+ return 0, ['repolist: ' + locale.format("%d", tot_num, True)]
def needTs(self, base, basecmd, extcmds):
return False
More information about the Yum-cvs-commits
mailing list