69
69
def changeCdrom(self):
72
class GtkOpProgress(apt.progress.OpProgress):
72
class GtkOpProgress(apt.progress.base.OpProgress):
73
73
def __init__(self, progressbar):
74
74
self.progressbar = progressbar
75
75
#self.progressbar.set_pulse_step(0.01)
76
76
#self.progressbar.pulse()
78
79
def update(self, percent):
80
81
# self.progressbar.set_fraction(1)
82
83
# self.progressbar.pulse()
83
self.progressbar.set_fraction(percent/100.0)
84
new_fraction = percent/100.0
85
if abs(self.fraction-new_fraction) > 0.1:
86
self.fraction = new_fraction
87
self.progressbar.set_fraction(self.fraction)
84
88
while gtk.events_pending():
85
89
gtk.main_iteration()
94
98
# FIXME2: we need to thing about mediaCheck here too
95
99
def __init__(self, parent):
96
FetchProgress.__init__(self)
100
super(GtkFetchProgressAdapter, self).__init__()
97
101
# if this is set to false the download will cancel
98
102
self.status = parent.label_status
99
103
self.progress = parent.progressbar_cache
104
108
def cancelClicked(self, widget):
105
109
logging.debug("cancelClicked")
106
110
self.canceled = True
107
def mediaChange(self, medium, drive):
111
def media_change(self, medium, drive):
108
112
#print "mediaChange %s %s" % (medium, drive)
109
113
msg = _("Please insert '%s' into the drive '%s'") % (medium,drive)
110
114
dialog = gtk.MessageDialog(parent=self.parent.window_main,
122
126
#logging.debug("start")
123
FetchProgress.start(self)
127
super(GtkFetchProgressAdapter, self).start()
124
128
self.progress.set_fraction(0)
125
129
self.status.show()
126
130
self.button_cancel.show()
129
133
self.progress.set_text(" ")
130
134
self.status.set_text(_("Fetching is complete"))
131
135
self.button_cancel.hide()
133
# FIXME: move the status_str and progress_str into python-apt
134
# (python-apt need i18n first for this)
135
FetchProgress.pulse(self)
136
self.progress.set_fraction(self.percent/100.0)
137
currentItem = self.currentItems + 1
138
if currentItem > self.totalItems:
139
currentItem = self.totalItems
141
if self.currentCPS > 0:
142
self.status.set_text(_("Fetching file %li of %li at %sB/s") % (currentItem, self.totalItems, apt_pkg.SizeToStr(self.currentCPS)))
143
self.progress.set_text(_("About %s remaining") % FuzzyTimeToStr(self.eta))
145
self.status.set_text(_("Fetching file %li of %li") % (currentItem, self.totalItems))
146
self.progress.set_text(" ")
136
def pulse(self, owner):
137
super(GtkFetchProgressAdapter, self).pulse(owner)
138
# only update if there is a noticable change
139
if abs(self.percent-self.progress.get_fraction()*100.0) > 0.1:
140
self.progress.set_fraction(self.percent/100.0)
141
currentItem = self.current_items + 1
142
if currentItem > self.total_items:
143
currentItem = self.total_items
144
if self.current_cps > 0:
145
self.status.set_text(_("Fetching file %li of %li at %sB/s") % (
146
currentItem, self.total_items,
147
apt_pkg.size_to_str(self.current_cps)))
148
self.progress.set_text(_("About %s remaining") % FuzzyTimeToStr(
151
self.status.set_text(_("Fetching file %li of %li") % (
152
currentItem, self.total_items))
153
self.progress.set_text(" ")
148
154
while gtk.events_pending():
149
155
gtk.main_iteration()
150
156
return (not self.canceled)
168
174
# some options for dpkg to make it die less easily
169
175
apt_pkg.Config.set("DPkg::StopOnError","False")
171
def startUpdate(self):
172
InstallProgress.startUpdate(self)
177
def start_update(self):
178
InstallProgress.start_update(self)
173
179
self.finished = False
174
180
# FIXME: add support for the timeout
175
181
# of the terminal (to display something useful then)
259
265
sys.exitfunc = lambda: True
262
def statusChange(self, pkg, percent, status):
268
def status_change(self, pkg, percent, status):
263
269
# start the timer when the first package changes its status
264
270
if self.start_time == 0.0:
265
271
#print "setting start time to %s" % self.start_time
266
272
self.start_time = time.time()
267
self.progress.set_fraction(float(percent)/100.0)
268
self.label_status.set_text(status.strip())
273
# only update if there is a noticable change
274
if abs(percent-self.progress.get_fraction()*100.0) > 0.1:
275
self.progress.set_fraction(float(percent)/100.0)
276
self.label_status.set_text(status.strip())
269
277
# start showing when we gathered some data
270
278
if percent > 1.0:
271
279
self.last_activity = time.time()
290
298
self.apt_status = status
291
299
self.finished = True
301
def wait_child(self):
294
302
while not self.finished:
295
self.updateInterface()
303
self.update_interface()
296
304
return self.apt_status
298
def finishUpdate(self):
306
def finish_update(self):
299
307
self.label_status.set_text("")
301
def updateInterface(self):
302
InstallProgress.updateInterface(self)
309
def update_interface(self):
310
InstallProgress.update_interface(self)
303
311
# check if we haven't started yet with packages, pulse then
304
312
if self.start_time == 0.0:
305
313
self.progress.pulse()
311
319
logging.warning("no activity on terminal for %s seconds (%s)" % (self.TIMEOUT_TERMINAL_ACTIVITY, self.label_status.get_text()))
312
320
self.activity_timeout_reported = True
313
321
self.parent.expander_terminal.set_expanded(True)
314
323
while gtk.events_pending():
315
324
gtk.main_iteration()
318
327
class DistUpgradeVteTerminal(object):
319
328
def __init__(self, parent, term):