211
212
os.write(self.master_fd,chr(3))
214
# read status fd from dpkg
215
# from python-apt/apt/progress.py (but modified a bit)
216
# -------------------------------------------------------------
217
res = select.select([self.statusfd],[],[],0.1)
218
while len(res[0]) > 0:
219
self.last_activity = time.time()
220
while not self.read.endswith("\n"):
221
self.read += os.read(self.statusfd.fileno(),1)
222
if self.read.endswith("\n"):
225
(status, pkg, percent, status_str) = string.split(s, ":")
226
if status == "pmerror":
227
self.error(pkg,status_str)
228
elif status == "pmconffile":
229
# we get a string like this:
230
# 'current-conffile' 'new-conffile' useredited distedited
231
match = re.compile("\s*\'(.*)\'\s*\'(.*)\'.*").match(status_str)
233
self.conffile(match.group(1), match.group(2))
234
elif status == "pmstatus":
235
if (float(percent) != self.percent or
236
status_str != self.status):
237
self.statusChange(pkg, float(percent), status_str.strip())
238
self.percent = float(percent)
239
self.status = string.strip(status_str)
240
sys.stdout.write("[%s] %s: %s\n" % (float(percent), pkg, status_str.strip()))
243
res = select.select([self.statusfd],[],[],0.1)
244
# -------------------------------------------------------------
246
#fcntl.fcntl(self.master_fd, fcntl.F_SETFL, os.O_NDELAY)
247
# read master fd (terminal output)
248
res = select.select([self.master_fd],[],[],0.1)
249
while len(res[0]) > 0:
250
self.last_activity = time.time()
252
s = os.read(self.master_fd, 1)
253
sys.stdout.write("%s" % s)
255
# happens after we are finished because the fd is closed
257
res = select.select([self.master_fd],[],[],0.1)
261
215
logging.debug("doing a pty.fork()")
262
216
# some maintainer scripts fail without
263
217
os.environ["TERM"] = "dumb"
264
218
# unset PAGER so that we can do "diff" in the dpkg prompt
265
219
os.environ["PAGER"] = "true"
266
(self.pid, self.master_fd) = pty.fork()
268
logging.debug("pid is: %s" % self.pid)
220
return InstallProgress.fork(self)
272
223
class DistUpgradeViewNonInteractive(DistUpgradeView):