1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
import rpm
from constants import *
from snack import *
from constants_text import *
from translate import _
class InstallProgressWindow:
def completePackage(self, header, timer):
def formatTime(amt):
hours = amt / 60 / 60
amt = amt % (60 * 60)
min = amt / 60
amt = amt % 60
secs = amt
return "%01d:%02d:%02d" % (int(hours) ,int(min), int(secs))
self.numComplete = self.numComplete + 1
self.sizeComplete = self.sizeComplete + (header[rpm.RPMTAG_SIZE] / 1024)
self.numCompleteW.setText("%12d" % self.numComplete)
self.sizeCompleteW.setText("%10dM" % (self.sizeComplete/1024))
self.numRemainingW.setText("%12d" % (self.numTotal - self.numComplete))
self.sizeRemainingW.setText("%10dM" % (self.sizeTotal/1024 - self.sizeComplete/1024))
self.total.set(self.sizeComplete)
elapsedTime = timer.elapsed()
if not elapsedTime:
elapsedTime = 1
self.timeCompleteW.setText("%12s" % formatTime(elapsedTime))
if self.sizeComplete != 0:
finishTime = (float (self.sizeTotal) / (self.sizeComplete)) * elapsedTime;
else:
finishTime = (float (self.sizeTotal) / (self.sizeComplete+1)) * elapsedTime;
self.timeTotalW.setText("%12s" % formatTime(finishTime))
remainingTime = finishTime - elapsedTime;
self.timeRemainingW.setText("%12s" % formatTime(remainingTime))
self.g.draw()
self.screen.refresh()
def setPackageScale(self, amount, total):
self.s.set(int(((amount * 1.0)/ total) * 100))
self.g.draw()
self.screen.refresh()
def setPackage(self, header):
self.name.setText("%s-%s-%s" % (header[rpm.RPMTAG_NAME],
header[rpm.RPMTAG_VERSION],
header[rpm.RPMTAG_RELEASE]))
self.size.setText("%dk" % (header[rpm.RPMTAG_SIZE] / 1024))
summary = header[rpm.RPMTAG_SUMMARY]
if (summary != None):
self.summ.setText(summary)
else:
self.summ.setText("(none)")
self.g.draw()
self.screen.refresh()
def processEvents(self):
pass
def setSizes(self, total, totalSize):
screen = self.screen
toplevel = GridForm(self.screen, _("Package Installation"), 1, 5)
name = _("Name : ")
size = _("Size : ")
sum = _("Summary: ")
width = 40 + max (len (name), len (size), len (sum))
self.name = Label(" " * 40)
self.size = Label(" ")
detail = Grid(2, 2)
detail.setField(Label(name), 0, 0, anchorLeft = 1)
detail.setField(Label(size), 0, 1, anchorLeft = 1)
detail.setField(self.name, 1, 0, anchorLeft = 1)
detail.setField(self.size, 1, 1, anchorLeft = 1)
toplevel.add(detail, 0, 0)
summary = Grid(2, 1)
summlabel = Label(sum)
self.summ = Textbox(40, 2, "", wrap = 1)
summary.setField(summlabel, 0, 0)
summary.setField(self.summ, 1, 0)
toplevel.add(summary, 0, 1)
self.s = Scale (width, 100)
toplevel.add (self.s, 0, 2, (0, 1, 0, 1))
overall = Grid(4, 4)
# don't ask me why, but if this spacer isn"t here then the
# grid code gets unhappy
overall.setField (Label (" "), 0, 0, anchorLeft = 1)
overall.setField (Label (_(" Packages")), 1, 0, anchorLeft = 1)
overall.setField (Label (_(" Bytes")), 2, 0, anchorLeft = 1)
overall.setField (Label (_(" Time")), 3, 0, anchorLeft = 1)
overall.setField (Label (_("Total :")), 0, 1, anchorLeft = 1)
overall.setField (Label ("%12d" % total), 1, 1, anchorLeft = 1)
overall.setField (Label ("%10dM" % (totalSize/1024)),
2, 1, anchorLeft = 1)
self.timeTotalW = Label("")
overall.setField(self.timeTotalW, 3, 1, anchorLeft = 1)
overall.setField (Label (_("Completed: ")), 0, 2, anchorLeft = 1)
self.numComplete = 0
self.numCompleteW = Label("%12d" % self.numComplete)
overall.setField(self.numCompleteW, 1, 2, anchorLeft = 1)
self.sizeComplete = 0
self.sizeCompleteW = Label("%10dM" % (self.sizeComplete))
overall.setField(self.sizeCompleteW, 2, 2, anchorLeft = 1)
self.timeCompleteW = Label("")
overall.setField(self.timeCompleteW, 3, 2, anchorLeft = 1)
overall.setField (Label (_("Remaining: ")), 0, 3, anchorLeft = 1)
self.numRemainingW = Label("%12d" % total)
self.sizeRemainingW = Label("%10dM" % (totalSize/1024))
overall.setField(self.numRemainingW, 1, 3, anchorLeft = 1)
overall.setField(self.sizeRemainingW, 2, 3, anchorLeft = 1)
self.timeRemainingW = Label("")
overall.setField(self.timeRemainingW, 3, 3, anchorLeft = 1)
toplevel.add(overall, 0, 3)
self.numTotal = total
self.sizeTotal = totalSize
self.total = Scale (width, totalSize)
toplevel.add(self.total, 0, 4, (0, 1, 0, 0))
self.timeStarted = -1
toplevel.draw()
self.g = toplevel
screen.refresh()
self.drawn = 1
def __init__(self, screen):
self.screen = screen
self.drawn = 0
def __del__ (self):
if self.drawn: self.screen.popWindow ()
class setupForInstall:
def __call__(self, screen, dir, intf, id):
if dir == DISPATCH_BACK:
id.setInstallProgressClass(None)
return INSTALL_BACK
else:
id.setInstallProgressClass(InstallProgressWindow(screen))
return INSTALL_OK
|