diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2008-12-15 14:35:29 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2008-12-15 14:35:29 +0100 |
| commit | dc5fde8efcbe2054db5afb61ac0a33849a72c4d1 (patch) | |
| tree | 48437e7f0214012838d8d0197b34502adb672572 /doc/examples | |
| parent | 676d6f2735b23fc0ca7360cef0ca325ce53d8c49 (diff) | |
| parent | 481a90a820564dc12567348c16773e15cc129560 (diff) | |
| download | python-apt-dc5fde8efcbe2054db5afb61ac0a33849a72c4d1.tar.gz | |
Merged python-apt consolidation branch by Sebastian
Heinlein (many thanks):
* apt/cache.py:
- new method "isVirtualPackage()"
- new method "getProvidingPackages()"
- new method "getRequiredDownload()"
- new method "additionalRequiredSpace()"
* apt/debfile.py:
- move a lot of the gdebi code into this file, this
provides interfaces for querrying and installing
.deb files and .dsc files
* apt/package.py:
- better description parsing
- new method "installedFiles()"
- new method "getChangelog()"
* apt/gtk/widgets.py:
- new gobject GOpProgress
- new gobject GFetchProgress
- new gobject GInstallProgress
- new gobject GDpkgInstallProgress
- new widget GtkAptProgress
* doc/examples/gui-inst.py:
- updated to use the new widgets
* debian/control:
- add suggests for python-gtk2 and python-vte
* setup.py:
- build html/ help of the apt and aptsources modules
into /usr/share/doc/python-apt/html
* data/templates/Ubuntu.info.in:
- updated to fix ports.ubuntu.com for powerpc and lpia
(LP: #220890)
* aptsources/distro.py:
- add parameter to get_distro() to make unit testing easier
* tests/test_aptsources_ports.py:
- add test for arch specific handling (when sub arch is on
a different mirror than "main" arches)
* python/acquire.cc (GetPkgAcqFile): Support DestDir and DestFilename.
Diffstat (limited to 'doc/examples')
| -rwxr-xr-x | doc/examples/gui-inst.py | 130 |
1 files changed, 21 insertions, 109 deletions
diff --git a/doc/examples/gui-inst.py b/doc/examples/gui-inst.py index c2555134..feefd6ed 100755 --- a/doc/examples/gui-inst.py +++ b/doc/examples/gui-inst.py @@ -12,113 +12,25 @@ import fcntl import pygtk pygtk.require('2.0') import gtk -import vte -import time -import posix - -from apt.progress import OpProgress, FetchProgress, InstallProgress - -class GuiFetchProgress(gtk.Window, FetchProgress): - def __init__(self): - gtk.Window.__init__(self) - self.vbox = gtk.VBox() - self.vbox.show() - self.add(self.vbox) - self.progress = gtk.ProgressBar() - self.progress.show() - self.label = gtk.Label() - self.label.show() - self.vbox.pack_start(self.progress) - self.vbox.pack_start(self.label) - self.resize(300,100) - def start(self): - print "start" - self.progress.set_fraction(0.0) - self.show() - def stop(self): - self.hide() - def pulse(self): - FetchProgress.pulse(self) - self.label.set_text("Speed: %s/s" % apt_pkg.SizeToStr(self.currentCPS)) - #self.progressbar.set_fraction(self.currentBytes/self.totalBytes) - while gtk.events_pending(): - gtk.main_iteration() - return True - -class TermInstallProgress(InstallProgress, gtk.Window): - def __init__(self): - gtk.Window.__init__(self) - InstallProgress.__init__(self) - self.show() - box = gtk.VBox() - box.show() - 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) - 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() - def waitChild(self): - while not self.finished: - self.updateInterface() - while gtk.events_pending(): - gtk.main_iteration() - time.sleep(0.001) - sys.stdin.readline() - return self.apt_status - def statusChange(self, pkg, percent, status): - print "statusChange", pkg, percent - self.progressbar.set_fraction(float(percent)/100.0) - self.progressbar.set_text(string.strip(status)) - def fork(self): - env = ["VTE_PTY_KEEP_FD=%s"%self.writefd] - return self.term.forkpty(envv=env) - -cache = apt.Cache() -print "Available packages: %s " % cache._cache.PackageCount - - -# update the cache -fprogress = GuiFetchProgress() -iprogress = TermInstallProgress() - -# update the cache -#cache.Update(fprogress) -#cache = apt_pkg.GetCache(progress) -#depcache = apt_pkg.GetDepCache(cache) -#depcache.ReadPinFile() -#depcache.Init(progress) - - -# show the interface -while gtk.events_pending(): - gtk.main_iteration() - - -pkg = cache["3dchess"] -print "\n%s"%pkg.name - -# install or remove, the importend thing is to keep us busy :) -if pkg.isInstalled: - pkg.markDelete() -else: - pkg.markInstall() -cache.commit(fprogress, iprogress) - -print "Exiting" -sys.exit(0) - - +import apt.gtk.widgets + +if __name__ == "__main__": + + win = gtk.Window() + progress = apt.gtk.widgets.GtkAptProgress() + win.set_title("GtkAptProgress Demo") + win.add(progress) + progress.show() + win.show() + + cache = apt.cache.Cache(progress.open) + if cache["2vcard"].isInstalled: + cache["2vcard"].markDelete() + else: + cache["2vcard"].markInstall() + progress.show_terminal(expanded=True) + cache.commit(progress.fetch, + progress.install) + + gtk.main() |
