diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-11-28 13:01:29 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-11-28 13:01:29 +0000 |
| commit | 311111a187216e25957c08e7c2e114b0118a48e2 (patch) | |
| tree | 8fc864ae10bf3c90fb7ab45ff6b1418ea94c4c72 /doc/examples | |
| parent | 0a8598b3b728e0445f84186b3f302734d1347371 (diff) | |
| download | python-apt-311111a187216e25957c08e7c2e114b0118a48e2.tar.gz | |
* cache.commit() uses the packagemanager python code now (+fix the gui-inst example)
Diffstat (limited to 'doc/examples')
| -rwxr-xr-x | doc/examples/gui-inst.py | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/doc/examples/gui-inst.py b/doc/examples/gui-inst.py index 38417e10..1cb551ef 100755 --- a/doc/examples/gui-inst.py +++ b/doc/examples/gui-inst.py @@ -2,6 +2,7 @@ # example how to install in a custom terminal widget # see also gnome bug: #169201 +import apt import apt_pkg import sys, os, fcntl import copy @@ -13,6 +14,7 @@ pygtk.require('2.0') import gtk import vte import time +import posix from apt.progress import OpProgress, FetchProgress, InstallProgress @@ -50,11 +52,16 @@ class TermInstallProgress(InstallProgress, gtk.Window): self.add(box) self.term = vte.Terminal() self.term.show() + # check for the child + self.reaper = vte.reaper_get() + self.reaper.connect("child-exited",self.child_exited) + self.finished = False + box.pack_start(self.term) self.progressbar = gtk.ProgressBar() self.progressbar.show() box.pack_start(self.progressbar) - + (read, write) = os.pipe() self.writefd=write self.status = os.fdopen(read, "r") @@ -62,7 +69,12 @@ class TermInstallProgress(InstallProgress, gtk.Window): print "read-fd: %s" % self.status.fileno() print "write-fd: %s" % self.writefd self.read = "" - + + def child_exited(self,term, pid, status): + print "child_exited: %s %s %s %s" % (self,term,pid,status) + self.apt_status = posix.WEXITSTATUS(status) + self.finished = True + def startUpdate(self): print "start" self.show() @@ -84,29 +96,26 @@ class TermInstallProgress(InstallProgress, gtk.Window): self.read = "" while gtk.events_pending(): gtk.main_iteration() + def finishUpdate(self): sys.stdin.readline() - def fork(self): + def run(self, pm): print "fork" env = ["VTE_PTY_KEEP_FD=%s"%self.writefd] print env pid = self.term.forkpty(envv=env) + if pid == 0: + res = pm.DoInstall(self.writefd) + print res + sys.exit(res) print "After fork: %s " % pid - return pid - - -# init -apt_pkg.init() - -progress = OpProgress() -cache = apt_pkg.GetCache(progress) -print "Available packages: %s " % cache.PackageCount + while not self.finished: + self.updateInterface() + return self.apt_status +cache = apt.Cache() +print "Available packages: %s " % cache._cache.PackageCount -# get depcache -depcache = apt_pkg.GetDepCache(cache) -depcache.ReadPinFile() -depcache.Init(progress) # update the cache fprogress = GuiFetchProgress() @@ -125,15 +134,15 @@ while gtk.events_pending(): gtk.main_iteration() -iter = cache["3dchess"] -print "\n%s"%iter +pkg = cache["3dchess"] +print "\n%s"%pkg.name # install or remove, the importend thing is to keep us busy :) -if iter.CurrentVer == None: - depcache.MarkInstall(iter) +if pkg.isInstalled: + pkg.markDelete() else: - depcache.MarkDelete(iter) -depcache.Commit(fprogress, iprogress) + pkg.markInstall() +cache.commit(fprogress, iprogress) print "Exiting" sys.exit(0) |
