yum.callbacks
Classes for handling various callbacks.
ProcessTransBaseCallback
-
class yum.callbacks.ProcessTransBaseCallback
A class to handle callbacks from
YumBase.processTransaction().
-
event(state, data=None)
Handle an event by logging it.
Parameters: |
- state – a number indicating the type of callback
- data – data associated with the callback
|
ProcessTransNoOutputCallback
-
class yum.callbacks.ProcessTransNoOutputCallback
A class to handle callbacks from
YumBase.processTransaction(), without logging them.
-
event(state, data=None)
Handle an event.
Parameters: |
- state – a number indicating the type of callback
- data – data associated with the callback
|
DownloadBaseCallback
-
class yum.callbacks.DownloadBaseCallback
Bases: urlgrabber.progress.BaseMeter
This is a base class that can be extended to implement a custom
download progress handler to be used with
YumBase.repos.setProgressBar().
Example:
from yum.callbacks import DownloadBaseCallback
class MyDownloadCallback( DownloadBaseCallback ):
def updateProgress(self,name,frac,fread,ftime):
'''
Update the progressbar
@param name: filename
@param frac: Progress fracment (0 -> 1)
@param fread: formated string containing BytesRead
@param ftime : formated string containing remaining or elapsed time
'''
pct = int( frac*100 )
print " %s : %s " % (name,pct)
if __name__ == '__main__':
my = YumBase()
my.doConfigSetup()
dnlcb = MyDownloadCallback()
my.repos.setProgressBar( dnlcb )
for pkg in my.pkgSack:
print pkg.name
-
update(amount_read, now=None)
Update the status bar.
Parameters: |
- amount_read – the amount of data, in bytes, that has been read
- now – the current time in seconds since the epoch. If
now is not given, the output of time.time() will
be used.
|
-
updateProgress(name, frac, fread, ftime)
Update the progressbar. This method should be overridden
by subclasses to implement the handler.
Parameters: |
- name – the name of the filed being downloaded
- frac – number between 0 and 1 representing the fraction
fraction of the file that has been downloaded
- fread – formatted string containing the number of bytes read
- ftime – formatted string containing remaining or elapsed time
|