1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 import logging
19 from urlgrabber.progress import BaseMeter,format_time,format_number
20
21
22
23
24 PT_DOWNLOAD = 10
25 PT_DOWNLOAD_PKGS = 11
26 PT_GPGCHECK = 20
27 PT_TEST_TRANS = 30
28 PT_TRANSACTION = 40
29
30 PT_MESSAGES = { PT_DOWNLOAD : "Downloading Packages",
31 PT_GPGCHECK : "Check Package Signatures",
32 PT_TEST_TRANS : "Running Test Transaction",
33 PT_TRANSACTION : "Running Transaction"}
34
35
36
38
40 self.logger = logging.getLogger('yum.verbose.ProcessTrasactionBaseCallback')
41
42 - def event(self,state,data=None):
45
49
50 - def event(self,state,data=None):
52
54 """
55 This is class is a base class to use by implement a download progress
56 handler to be used with YumBase.repos.setProgressBar.
57
58 Example:
59
60 from yum.callbacks import DownloadBaseCallback
61
62 class MyDownloadCallback( DownloadBaseCallback ):
63
64 def updateProgress(self,name,frac,fread,ftime):
65 '''
66 Update the progressbar
67 @param name: filename
68 @param frac: Progress fracment (0 -> 1)
69 @param fread: formated string containing BytesRead
70 @param ftime : formated string containing remaining or elapsed time
71 '''
72 pct = int( frac*100 )
73 print " %s : %s " % (name,pct)
74
75
76 if __name__ == '__main__':
77 my = YumBase()
78 my.doConfigSetup()
79 dnlcb = MyDownloadCallback()
80 my.repos.repos.setProgressBar( dnlcb )
81 for pkg in my.pkgSack:
82 print pkg.name
83
84 """
85
87 BaseMeter.__init__( self )
88 self.totSize = ""
89
90 - def update( self, amount_read, now=None ):
91 BaseMeter.update( self, amount_read, now )
92
98
114
115
116 - def _do_end( self, amount_read, now=None ):
121
123 '''
124 Get the name of the package being downloaded
125 '''
126 if self.text and type( self.text ) == type( "" ):
127 name = self.text
128 else:
129 name = self.basename
130 return name
131
133 '''
134 Update the progressbar (Overload in child class)
135 @param name: filename
136 @param frac: Progress fracment (0 -> 1)
137 @param fread: formated string containing BytesRead
138 @param ftime : formated string containing remaining or elapsed time
139 '''
140 pass
141