[yum-commits] 3 commits - cli.py output.py yum-cron/yum-cron.py yum/igroups.py yum/__init__.py
James Antill
james at osuosl.org
Wed Apr 24 13:26:04 UTC 2013
cli.py | 22 +++++++++++++++++++---
output.py | 45 +++++++++++++++++++++++++--------------------
yum-cron/yum-cron.py | 4 ++++
yum/__init__.py | 2 +-
yum/igroups.py | 3 ++-
5 files changed, 51 insertions(+), 25 deletions(-)
New commits:
commit 913a7f69b3ef5770ee69f8b94ba6f6f80a73fd24
Author: James Antill <james at and.org>
Date: Tue Apr 23 17:16:23 2013 -0400
Turn metadata_expire off for yum-cron.
diff --git a/yum-cron/yum-cron.py b/yum-cron/yum-cron.py
index c62414e..55e337d 100755
--- a/yum-cron/yum-cron.py
+++ b/yum-cron/yum-cron.py
@@ -824,6 +824,10 @@ class YumCronBase(yum.YumBase):
def populateUpdateMetadata(self):
"""Populate the metadata for the packages in the update."""
+
+ for repo in base.repos.findRepos('*'):
+ repo.metadata_expire = 0
+
self.upinfo
def refreshUpdates(self):
commit 445aa76b36defb59135f51db9ce07288f20062ef
Author: James Antill <james at and.org>
Date: Tue Apr 23 14:58:21 2013 -0400
Don't traceback when the group isn't installed. BZ 928859.
diff --git a/yum/igroups.py b/yum/igroups.py
index 6a04f3a..467aa7b 100644
--- a/yum/igroups.py
+++ b/yum/igroups.py
@@ -172,7 +172,8 @@ class InstalledGroups(object):
fo.write("%u\n" % len(evgrp.grp_names))
for grpname in sorted(evgrp.grp_names):
fo.write("%s\n" % grpname)
- if self.groups[grpname].environment == evgrp.evgid:
+ if (grpname in self.groups and
+ self.groups[grpname].environment == evgrp.evgid):
fo.write("%s\n" % "true")
else:
fo.write("%s\n" % "false")
commit c0d0e4930b5a52f4d3c095977cba36fec97fd314
Author: James Antill <james at and.org>
Date: Mon Apr 22 17:33:54 2013 -0400
Add downloadonly option to userconfirm download prompt.
diff --git a/cli.py b/cli.py
index ba2e343..c8a5554 100755
--- a/cli.py
+++ b/cli.py
@@ -529,6 +529,12 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
errors. A negative return code indicates that errors
occurred in the pre-transaction checks
"""
+ def _downloadonly_userconfirm(self):
+ return self.userconfirm(prompt=_('Is this ok [y/d/N]: '),
+ extra={'downloadonly' :
+ (u'd', _('d'), _('download'),
+ _('downloadonly'))})
+
# just make sure there's not, well, nothing to do
if len(self.tsInfo) == 0:
self.verbose_logger.info(_('Trying to run the transaction but nothing to do. Exiting.'))
@@ -586,12 +592,22 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
# confirm with user
if self._promptWanted():
- if self.conf.assumeno or not self.userconfirm():
+ uc = None
+ if not self.conf.assumeno:
+ uc = _downloadonly_userconfirm(self)
+
+ if not uc:
self.verbose_logger.info(_('Exiting on user command'))
return -1
+ elif uc == 'downloadonly':
+ self.conf.downloadonly = True
- self.verbose_logger.log(yum.logginglevels.INFO_2,
- _('Downloading packages:'))
+ if self.conf.downloadonly:
+ self.verbose_logger.log(yum.logginglevels.INFO_2,
+ _('Background downloading packages, then exiting:'))
+ else:
+ self.verbose_logger.log(yum.logginglevels.INFO_2,
+ _('Downloading packages:'))
problems = self.downloadPkgs(downloadpkgs, callback_total=self.download_callback_total_cb)
if len(problems) > 0:
diff --git a/output.py b/output.py
index 020e2b6..e17194c 100755
--- a/output.py
+++ b/output.py
@@ -958,20 +958,23 @@ class YumOutput:
return 1, ['No Packages to list']
return 0, []
-
-
- def userconfirm(self):
- """Get a yes or no from the user, and default to No
+ def userconfirm(self, prompt=_('Is this ok [y/N]: '), extra={}):
+ """Get a yes or no from the user, and default to No, and maybe more.
- :return: True if the user selects yes, and False if the user
- selects no
+ :param extra: a dict of ui responses to a list of their inputs.
+ :return: the UI response or None for no. At it's simplest this is 'yes' or None
"""
- yui = (to_unicode(_('y')), to_unicode(_('yes')))
- nui = (to_unicode(_('n')), to_unicode(_('no')))
- aui = (yui[0], yui[1], nui[0], nui[1])
+
+ # Allow the one letter english versions in all langs.
+ yui = (u'y', to_unicode(_('y')), to_unicode(_('yes')))
+ nui = (u'n', to_unicode(_('n')), to_unicode(_('no')))
+ aui = set(yui + nui)
+ for xui in extra:
+ aui.update(extra[xui])
+
while True:
try:
- choice = raw_input(_('Is this ok [y/N]: '))
+ choice = raw_input(prompt)
except UnicodeEncodeError:
raise
except UnicodeDecodeError:
@@ -982,17 +985,19 @@ class YumOutput:
choice = choice.lower()
if len(choice) == 0 or choice in aui:
break
- # If the enlish one letter names don't mix, allow them too
- if u'y' not in aui and u'y' == choice:
- choice = yui[0]
- break
- if u'n' not in aui and u'n' == choice:
- break
- if len(choice) == 0 or choice not in yui:
- return False
- else:
- return True
+ if not choice:
+ # Default, maybe configure this?
+ # Would need to never allow default=yes as that's really bad.
+ return None
+
+ if choice in yui:
+ return 'yes'
+ for xui in extra:
+ if choice in extra[xui]:
+ return xui
+
+ return None
def _cli_confirm_gpg_key_import(self, keydict):
# FIXME what should we be printing here?
diff --git a/yum/__init__.py b/yum/__init__.py
index 766f960..543ca2d 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2423,7 +2423,7 @@ much more problems).
urlgrabber.grabber.reset_curl_obj()
if downloadonly and not errors: # caller handles errors
- self.verbose_logger.info(_('exiting because --downloadonly specified'))
+ self.verbose_logger.info(_('exiting because "Download Only" specified'))
sys.exit(self.exit_code)
return errors
More information about the Yum-commits
mailing list