def commit(self):
# ui
self.status.setText(_("Installing '%s'...") % os.path.basename(self.debfile))
# the command
cmd = "/usr/bin/dpkg"
argv = [cmd, "--auto-deconfigure", "-i", self.debfile]
(self.child_pid, self.master_fd) = pty.fork()
if self.child_pid == 0:
os.environ["TERM"] = "dumb"
if not "DEBIAN_FRONTEND" in os.environ:
os.environ["DEBIAN_FRONTEND"] = "noninteractive"
os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
exitstatus = subprocess.call(argv)
os._exit(exitstatus)
while True:
#Read from pty and write to DumbTerminal
try:
(rlist, wlist, xlist) = select.select([self.master_fd],[],[], 0.001)
if len(rlist) > 0:
line = os.read(self.master_fd, 255)
self.parent.konsole.insertWithTermCodes(utf8(line))
except Exception as e:
#print e
from errno import EAGAIN
if hasattr(e, "errno") and e.errno == EAGAIN:
continue
break
KApplication.kApplication().processEvents()
# at this point we got a read error from the pty, that most
# likely means that the client is dead
(pid, status) = os.waitpid(self.child_pid, 0)
self.exitstatus = os.WEXITSTATUS(status)
self.progress.setValue(100)
self.parent.closeButton.setEnabled(True)
self.parent.closeButton.setVisible(True)
self.parent.installationProgress.setVisible(False)
QTimer.singleShot(1, self.parent.changeSize)
评论列表
文章目录