[yum-commits] Branch 'yum-3_2_X' - 5 commits - cli.py output.py shell.py yumcommands.py yum/__init__.py yum/yumRepo.py
James Antill
james at osuosl.org
Thu Sep 9 20:39:36 UTC 2010
cli.py | 20 ++++++++++
output.py | 109 ++++++++++++++++++++++++++++++++++++++++++++++++--------
shell.py | 12 ++++++
yum/__init__.py | 2 +
yum/yumRepo.py | 10 +++++
yumcommands.py | 12 ++++--
6 files changed, 147 insertions(+), 18 deletions(-)
New commits:
commit a98056413cb52dee8f9bb41bb14b9b708866a349
Author: James Antill <james at and.org>
Date: Thu Sep 9 16:04:13 2010 -0400
Handle generated .sqlite files, for .xml MD which has unique filenames. BZ 628963
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 37b4b3d..b501d61 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -1314,6 +1314,16 @@ class YumRepository(Repository, config.RepoConf):
os.rename(local, local + '.old.tmp')
reverts.append(local)
+ # This is the super easy way. We just to see if a generated
+ # file is there for all files, but it should always work.
+ # And anyone who is giving us MD with blah and blah.sqlite
+ # which are different types, can play a game I like to call
+ # "come here, ouch".
+ gen_local = local + '.sqlite'
+ if os.path.exists(gen_local):
+ os.rename(gen_local, gen_local + '.old.tmp')
+ reverts.append(gen_local)
+
if ndata is None: # Doesn't exist in this repo
continue
commit 726792369cf3b0998fd122b394b2eb2f5d2ddee6
Author: James Antill <james at and.org>
Date: Thu Sep 9 15:18:16 2010 -0400
Add some minor aliases for history sub-commands.
diff --git a/yumcommands.py b/yumcommands.py
index 351e6b4..517e6b9 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -1359,7 +1359,9 @@ class HistoryCommand(YumCommand):
def doCheck(self, base, basecmd, extcmds):
cmds = ('list', 'info', 'summary', 'repeat', 'redo', 'undo', 'new',
- 'addon-info', 'package-list')
+ 'addon', 'addon-info',
+ 'pkg', 'pkgs', 'pkg-list', 'pkgs-list',
+ 'package', 'package-list', 'packages', 'packages-list')
if extcmds and extcmds[0] not in cmds:
base.logger.critical(_('Invalid history sub-command, use: %s.'),
", ".join(cmds))
@@ -1383,9 +1385,10 @@ class HistoryCommand(YumCommand):
ret = base.historyInfoCmd(extcmds)
elif vcmd == 'summary':
ret = base.historySummaryCmd(extcmds)
- elif vcmd == 'addon-info':
+ elif vcmd in ('addon', 'addon-info'):
ret = base.historyAddonInfoCmd(extcmds)
- elif vcmd == 'package-list':
+ elif vcmd in ('pkg', 'pkgs', 'pkg-list', 'pkgs-list',
+ 'package', 'package-list', 'packages', 'packages-list'):
ret = base.historyPackageListCmd(extcmds)
elif vcmd == 'undo':
ret = self._hcmd_undo(base, extcmds)
commit 4fbf9f25458ff85ff7a33c9c1dce502a4e96c93c
Author: James Antill <james at and.org>
Date: Thu Sep 9 15:16:48 2010 -0400
Add history package-list command, to show history view from the pkg POV.
diff --git a/output.py b/output.py
index 1b6bc70..2287b90 100755
--- a/output.py
+++ b/output.py
@@ -1378,7 +1378,7 @@ to exit.
fmt = "%s | %s | %s | %s | %s"
print fmt % (utf8_width_fill(_("ID"), 6, 6),
- utf8_width_fill(_("Login user"), 22, 22),
+ utf8_width_fill(_("Login user"), 24, 24),
utf8_width_fill(_("Date and time"), 16, 16),
utf8_width_fill(_("Action(s)"), 14, 14),
utf8_width_fill(_("Altered"), 7, 7))
@@ -1393,11 +1393,11 @@ to exit.
break
done += 1
- name = self._pwd_ui_username(old.loginuid, 22)
+ name = self._pwd_ui_username(old.loginuid, 24)
tm = time.strftime("%Y-%m-%d %H:%M",
time.localtime(old.beg_timestamp))
num, uiacts = self._history_uiactions(old.trans_data)
- name = utf8_width_fill(name, 22, 22)
+ name = utf8_width_fill(name, 24, 24)
uiacts = utf8_width_fill(uiacts, 14, 14)
rmark = lmark = ' '
if old.return_code is None:
@@ -1629,23 +1629,24 @@ to exit.
num += 1
print "%4d" % num, line
+ _history_state2uistate = {'True-Install' : _('Install'),
+ 'Install' : _('Install'),
+ 'Dep-Install' : _('Dep-Install'),
+ 'Obsoleted' : _('Obsoleted'),
+ 'Obsoleting' : _('Obsoleting'),
+ 'Erase' : _('Erase'),
+ 'Reinstall' : _('Reinstall'),
+ 'Downgrade' : _('Downgrade'),
+ 'Downgraded' : _('Downgraded'),
+ 'Update' : _('Update'),
+ 'Updated' : _('Updated'),
+ }
def historyInfoCmdPkgsAltered(self, old, pats=[]):
last = None
# Note that these don't use _simple_pkg() because we are showing what
# happened to them in the transaction ... not the difference between the
# version in the transaction and now.
- all_uistates = {'True-Install' : _('Install'),
- 'Install' : _('Install'),
- 'Dep-Install' : _('Dep-Install'),
- 'Obsoleted' : _('Obsoleted'),
- 'Obsoleting' : _('Obsoleting'),
- 'Erase' : _('Erase'),
- 'Reinstall' : _('Reinstall'),
- 'Downgrade' : _('Downgrade'),
- 'Downgraded' : _('Downgraded'),
- 'Update' : _('Update'),
- 'Updated' : _('Updated'),
- }
+ all_uistates = self._history_state2uistate
maxlen = 0
for hpkg in old.trans_data:
uistate = all_uistates.get(hpkg.state, hpkg.state)
@@ -1795,6 +1796,84 @@ to exit.
print ''
+ def historyPackageListCmd(self, extcmds):
+ """ Shows the user a list of data about the history, from the point
+ of a package(s) instead of via. transactions. """
+ tids = self.history.search(extcmds)
+ if not tids:
+ self.logger.critical(_('Bad package(s), given (nothing found)'))
+ return 1, ['Failed history package-list']
+
+ all_uistates = self._history_state2uistate
+
+ fmt = "%s | %s | %s"
+ # REALLY Needs to use columns!
+ print fmt % (utf8_width_fill(_("ID"), 6, 6),
+ utf8_width_fill(_("Action(s)"), 14, 14),
+ utf8_width_fill(_("Package"), 53, 53))
+ print "-" * 79
+ fmt = "%6u | %s | %-50s"
+ last = None
+ for old in self.history.old(tids):
+ # Copy and paste from list ... uh.
+ rmark = lmark = ' '
+ if old.return_code is None:
+ rmark = lmark = '*'
+ elif old.return_code:
+ rmark = lmark = '#'
+ # We don't check .errors, because return_code will be non-0
+ elif old.output:
+ rmark = lmark = 'E'
+ elif old.rpmdb_problems:
+ rmark = lmark = 'P'
+ elif old.trans_skip:
+ rmark = lmark = 's'
+ if old.altered_lt_rpmdb:
+ rmark = '<'
+ if old.altered_gt_rpmdb:
+ lmark = '>'
+
+ for hpkg in old.trans_data: # Find a pkg to go with each cmd...
+ x,m,u = yum.packages.parsePackages([hpkg], extcmds)
+ if not x and not m:
+ continue
+
+ uistate = all_uistates.get(hpkg.state, hpkg.state)
+ uistate = utf8_width_fill(uistate, 14)
+
+ # To chop the name off we need nevra strings, str(pkg) gives
+ # envra so we have to do it by hand ... *sigh*.
+ cn = hpkg.ui_nevra
+
+ # Should probably use columns here...
+ if False: pass
+ elif (last is not None and
+ last.state == 'Updated' and last.name == hpkg.name and
+ hpkg.state == 'Update'):
+ ln = len(hpkg.name) + 1
+ cn = (" " * ln) + cn[ln:]
+ elif (last is not None and
+ last.state == 'Downgrade' and last.name == hpkg.name and
+ hpkg.state == 'Downgraded'):
+ ln = len(hpkg.name) + 1
+ cn = (" " * ln) + cn[ln:]
+ else:
+ last = None
+ if hpkg.state in ('Updated', 'Downgrade'):
+ last = hpkg
+
+ print fmt % (old.tid, uistate, cn), "%s%s" % (lmark,rmark)
+
+ # And, again, copy and paste...
+ lastdbv = self.history.last()
+ if lastdbv is None:
+ self._rpmdb_warn_checks(warn=False)
+ else:
+ # If this is the last transaction, is good and it doesn't
+ # match the current rpmdb ... then mark it as bad.
+ rpmdbv = self.rpmdb.simpleVersion(main_only=True)[0]
+ if lastdbv.end_rpmdbversion != rpmdbv:
+ self._rpmdb_warn_checks()
class DepSolveProgressCallBack:
diff --git a/yumcommands.py b/yumcommands.py
index b3935f6..351e6b4 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -1329,7 +1329,7 @@ class HistoryCommand(YumCommand):
return ['history']
def getUsage(self):
- return "[info|list|summary|addon-info|redo|undo|new]"
+ return "[info|list|summary|addon-info|package-list|redo|undo|new]"
def getSummary(self):
return _("Display, or use, the transaction history")
@@ -1358,7 +1358,8 @@ class HistoryCommand(YumCommand):
base.history._create_db_file()
def doCheck(self, base, basecmd, extcmds):
- cmds = ('list', 'info', 'summary', 'repeat', 'redo', 'undo', 'new', 'addon-info')
+ cmds = ('list', 'info', 'summary', 'repeat', 'redo', 'undo', 'new',
+ 'addon-info', 'package-list')
if extcmds and extcmds[0] not in cmds:
base.logger.critical(_('Invalid history sub-command, use: %s.'),
", ".join(cmds))
@@ -1384,6 +1385,8 @@ class HistoryCommand(YumCommand):
ret = base.historySummaryCmd(extcmds)
elif vcmd == 'addon-info':
ret = base.historyAddonInfoCmd(extcmds)
+ elif vcmd == 'package-list':
+ ret = base.historyPackageListCmd(extcmds)
elif vcmd == 'undo':
ret = self._hcmd_undo(base, extcmds)
elif vcmd in ('redo', 'repeat'):
commit c62673ca2452a74b1c67e64cedb7f5caf0f60b02
Author: James Antill <james at and.org>
Date: Thu Sep 9 14:43:23 2010 -0400
Show addon-info in the history summary text.
diff --git a/yumcommands.py b/yumcommands.py
index 5498322..b3935f6 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -1329,7 +1329,7 @@ class HistoryCommand(YumCommand):
return ['history']
def getUsage(self):
- return "[info|list|summary|redo|undo|new]"
+ return "[info|list|summary|addon-info|redo|undo|new]"
def getSummary(self):
return _("Display, or use, the transaction history")
commit 528ce00f67967abb5810e33780bcd57a3ca97044
Author: James Antill <james at and.org>
Date: Thu Sep 9 14:41:55 2010 -0400
Add "addon" history information for "yum shell", currently triggers non-def.
diff --git a/cli.py b/cli.py
index 3e837ae..0accd35 100644
--- a/cli.py
+++ b/cli.py
@@ -327,14 +327,34 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
self.yum_cli_commands[self.basecmd].doCheck(self, self.basecmd, self.extcmds)
+ def _shell_history_write(self):
+ if not hasattr(self, '_shell_history_cmds'):
+ return
+ if not self._shell_history_cmds:
+ return
+
+ data = self._shell_history_cmds
+ # Turn: [["a", "b"], ["c", "d"]] => "a b\nc d\n"
+ data = [" ".join(cmds) for cmds in data]
+ data.append('')
+ data = "\n".join(data)
+ self.history.write_addon_data('shell-cmds', data)
+
def doShell(self):
"""do a shell-like interface for yum commands"""
yumshell = shell.YumShell(base=self)
+
+ # We share this array...
+ self._shell_history_cmds = yumshell._shell_history_cmds
+
if len(self.extcmds) == 0:
yumshell.cmdloop()
else:
yumshell.script()
+
+ del self._shell_history_cmds
+
return yumshell.result, yumshell.resultmsgs
def errorSummary(self, errstring):
diff --git a/shell.py b/shell.py
index f1c82a3..a32e880 100644
--- a/shell.py
+++ b/shell.py
@@ -50,6 +50,14 @@ class YumShell(cmd.Cmd):
self.logger = logging.getLogger("yum.cli")
self.verbose_logger = logging.getLogger("yum.verbose.cli")
+ # NOTE: This is shared with self.base ... so don't reassign.
+ self._shell_history_cmds = []
+
+ def _shell_history_add_cmds(self, cmds):
+ if not self.base.conf.history_record:
+ return
+
+ self._shell_history_cmds.append(cmds)
def _shlex_split(self, input_string):
"""split the input using shlex rules, and error or exit accordingly"""
@@ -98,6 +106,8 @@ class YumShell(cmd.Cmd):
self.base.cmds = self._shlex_split(self.base.cmdstring)
self.base.plugins.run('args', args=self.base.cmds)
+ self._shell_history_add_cmds(self.base.cmds)
+
try:
self.base.parseCommands()
except Errors.YumBaseError:
@@ -266,6 +276,8 @@ class YumShell(cmd.Cmd):
cmds.insert(0, 'repolist')
self.base.cmds = cmds
+ self._shell_history_add_cmds(self.base.cmds)
+
try:
self.base.parseCommands()
except Errors.YumBaseError:
diff --git a/yum/__init__.py b/yum/__init__.py
index 2973846..b5e9213 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1343,6 +1343,8 @@ class YumBase(depsolve.Depsolve):
self.skipped_packages, rpmdb_problems, cmdline)
# write out our config and repo data to additional history info
self._store_config_in_history()
+ if hasattr(self, '_shell_history_write'): # Only in cli...
+ self._shell_history_write()
self.plugins.run('historybegin')
# Just before we update the transaction, update what we think the
More information about the Yum-commits
mailing list