[yum-cvs] 2 commits - output.py yum/rpmtrans.py
Tim Lauridsen
timlau at linux.duke.edu
Tue Aug 14 12:33:21 UTC 2007
output.py | 29 +++--------------------------
yum/rpmtrans.py | 43 +++++++++++++++++++++++++++++++------------
2 files changed, 34 insertions(+), 38 deletions(-)
New commits:
commit cb3c2c1b6e064f2ec876f9d0c0adc6e3f079d243
Merge: ed0a318... 33a7deb...
Author: Tim Lauridsen <tla at rasmil.dk>
Date: Tue Aug 14 14:27:36 2007 +0200
Merge branch 'fix-rpmtrans'
* fix-rpmtrans:
Added RPMBaseCallback class to reduce duplicate code and make it easier to make a callback class for a yum api user
commit 33a7deb1084a33b8cfcbbe70fcc91509260a4b48
Author: Tim Lauridsen <tla at rasmil.dk>
Date: Tue Aug 14 12:15:35 2007 +0200
Added RPMBaseCallback class to reduce duplicate code and make it easier to make a callback class for a yum api user
diff --git a/output.py b/output.py
index 073cb0c..095dd07 100644
--- a/output.py
+++ b/output.py
@@ -30,6 +30,7 @@ from rpmUtils.miscutils import checkSignals
from yum.constants import *
from yum import logginglevels
+from yum.rpmtrans import RPMBaseCallback
class YumTextMeter(TextMeter):
def update(self, amount_read, now=None):
@@ -454,26 +455,10 @@ class CacheProgressCallback:
def progressbar(self, current, total, name=None):
progressbar(current, total, name)
-class YumCliRPMCallBack:
+class YumCliRPMCallBack(RPMBaseCallback):
def __init__(self):
- self.action = { TS_UPDATE : 'Updating',
- TS_ERASE: 'Erasing',
- TS_INSTALL: 'Installing',
- TS_TRUEINSTALL : 'Installing',
- TS_OBSOLETED: 'Obsoleted',
- TS_OBSOLETING: 'Installing',
- TS_UPDATED: 'Cleanup',
- 'repackaging': 'Repackaging'}
-
- self.fileaction = { TS_UPDATE: 'Updated',
- TS_ERASE: 'Erased',
- TS_INSTALL: 'Installed',
- TS_TRUEINSTALL: 'Installed',
- TS_OBSOLETED: 'Obsoleted',
- TS_OBSOLETING: 'Installed',
- TS_UPDATED: 'Cleanup'}
+ RPMBaseCallback.__init__(self)
self.lastmsg = None
- self.logger = logging.getLogger('yum.filelogging.RPMInstallCallback')
self.lastpackage = None # name of last package we looked at
self.output = True
@@ -507,14 +492,6 @@ class YumCliRPMCallBack:
if te_current == te_total:
print " "
- def errorlog(self, msg):
- print >> sys.stderr, msg
-
- def filelog(self, package, action):
- # check package object type - if it is a string - just output it
- msg = '%s: %s' % (self.fileaction[action], package)
- self.logger.info(msg)
-
def _makefmt(self, percent, ts_current, ts_total, progress = True):
l = len(str(ts_total))
size = "%s.%s" % (l, l)
diff --git a/yum/rpmtrans.py b/yum/rpmtrans.py
index 0a14927..0206262 100644
--- a/yum/rpmtrans.py
+++ b/yum/rpmtrans.py
@@ -52,8 +52,10 @@ class NoOutputCallBack:
action is also the same as in event()"""
pass
-
-class SimpleCliCallBack:
+class RPMBaseCallback:
+ '''
+ Base class for a RPMTransaction display callback class
+ '''
def __init__(self):
self.action = { TS_UPDATE : 'Updating',
TS_ERASE: 'Erasing',
@@ -70,19 +72,20 @@ class SimpleCliCallBack:
TS_OBSOLETED: 'Obsoleted',
TS_OBSOLETING: 'Installed',
TS_UPDATED: 'Cleanup'}
- self.lastmsg = None
self.logger = logging.getLogger('yum.filelogging.RPMInstallCallback')
- self.lastpackage = None # name of last package we looked at
def event(self, package, action, te_current, te_total, ts_current, ts_total):
- # this is where a progress bar would be called
- msg = '%s: %s %s/%s [%s/%s]' % (self.action[action], package,
- te_current, te_total, ts_current, ts_total)
- if msg != self.lastmsg:
- print msg
- self.lastmsg = msg
- self.lastpackage = package
-
+ """package is a yum package object or simple string of a package name
+ action is a yum.constant transaction set state or in the obscure
+ rpm repackage case it could be the string 'repackaging'
+ te_current: current number of bytes processed in the transaction
+ element being processed
+ te_total: total number of bytes in the transaction element being processed
+ ts_current: number of processes completed in whole transaction
+ ts_total: total number of processes in the transaction.
+ """
+ raise NotImplementedError()
+
def errorlog(self, msg):
print >> sys.stderr, msg
@@ -91,6 +94,22 @@ class SimpleCliCallBack:
# check package object type - if it is a string - just output it
msg = '%s: %s' % (self.fileaction[action], package)
self.logger.info(msg)
+
+
+class SimpleCliCallBack(RPMBaseCallback):
+ def __init__(self):
+ RPMBaseCallback.__init__(self)
+ self.lastmsg = None
+ self.lastpackage = None # name of last package we looked at
+
+ def event(self, package, action, te_current, te_total, ts_current, ts_total):
+ # this is where a progress bar would be called
+ msg = '%s: %s %s/%s [%s/%s]' % (self.action[action], package,
+ te_current, te_total, ts_current, ts_total)
+ if msg != self.lastmsg:
+ print msg
+ self.lastmsg = msg
+ self.lastpackage = package
class RPMTransaction:
def __init__(self, tsInfo, display=NoOutputCallBack):
More information about the Yum-cvs-commits
mailing list