diff options
| author | Ben Finney <ben@benfinney.id.au> | 2008-05-16 16:11:06 +1000 |
|---|---|---|
| committer | Ben Finney <ben@benfinney.id.au> | 2008-05-16 16:11:06 +1000 |
| commit | a953d82143f0ec979e18f17e8d9bbacbac954868 (patch) | |
| tree | 42e76c37d72847d4fe3ca2487e227ae1649ad3c0 /doc/examples | |
| parent | 21ef2ab57d68de87a2b44a23d9a3bfb87d24d46d (diff) | |
| download | python-apt-a953d82143f0ec979e18f17e8d9bbacbac954868.tar.gz | |
Fixes to blank lines, to conform with PEP 8.
Diffstat (limited to 'doc/examples')
| -rw-r--r-- | doc/examples/acquire.py | 4 | ||||
| -rw-r--r-- | doc/examples/action.py | 12 | ||||
| -rwxr-xr-x | doc/examples/build-deps.py | 2 | ||||
| -rw-r--r-- | doc/examples/cdrom.py | 6 | ||||
| -rwxr-xr-x | doc/examples/deb_inspect.py | 3 | ||||
| -rw-r--r-- | doc/examples/desc.py | 1 | ||||
| -rwxr-xr-x | doc/examples/gui-inst.py | 19 | ||||
| -rw-r--r-- | doc/examples/inst.py | 10 | ||||
| -rw-r--r-- | doc/examples/progress.py | 14 | ||||
| -rwxr-xr-x | doc/examples/recommends.py | 6 |
10 files changed, 41 insertions, 36 deletions
diff --git a/doc/examples/acquire.py b/doc/examples/acquire.py index cce3fb0d..07f8da0e 100644 --- a/doc/examples/acquire.py +++ b/doc/examples/acquire.py @@ -4,6 +4,7 @@ import os import sys import tempfile + def get_file(fetcher, uri, destFile): cwd = os.getcwd() # create a temp dir @@ -86,6 +87,3 @@ print "fetcher.Run() returned: %s" % res print "now runing pm.DoInstall()" res = pm.DoInstall(1) print "pm.DoInstall() returned: %s"% res - - - diff --git a/doc/examples/action.py b/doc/examples/action.py index adf26539..9277129e 100644 --- a/doc/examples/action.py +++ b/doc/examples/action.py @@ -21,15 +21,6 @@ cache.Update(progress) print "Exiting" sys.exit(0) - - - - - - - - - iter = cache["base-config"] print "example package iter: %s" % iter @@ -45,7 +36,6 @@ depcache.Init(progress) #sys.exit() - # get a canidate version ver= depcache.GetCandidateVer(iter) print "Candidate version: %s " % ver @@ -66,7 +56,6 @@ depcache.MarkDelete(iter) print "DelCount: %s " % depcache.DelCount print "%s.MarkedDelete(): %s" % (iter.Name, depcache.MarkedDelete(iter)) - iter = cache["3dchess"] print "\nMarking '%s' for install" % iter.Name depcache.MarkInstall(iter) @@ -100,7 +89,6 @@ for pkg in cache.Packages: if pkg.CurrentVer != None and not depcache.MarkedInstall(pkg) and depcache.IsUpgradable(pkg): print "Upgrade didn't upgrade (kept): %s" % pkg.Name - print "\nPerforming DistUpgrade" depcache.Upgrade(True) print "Keep: %s " % depcache.KeepCount diff --git a/doc/examples/build-deps.py b/doc/examples/build-deps.py index fae7b55b..2d83a54f 100755 --- a/doc/examples/build-deps.py +++ b/doc/examples/build-deps.py @@ -5,6 +5,7 @@ import apt_pkg import sys import sets # only needed for python2.3, python2.4 supports this naively + def get_source_pkg(pkg, records, depcache): """ get the source package name of a given package """ version = depcache.GetCandidateVer(pkg) @@ -18,6 +19,7 @@ def get_source_pkg(pkg, records, depcache): srcpkg = pkg.Name return srcpkg + # main apt_pkg.init() cache = apt_pkg.GetCache() diff --git a/doc/examples/cdrom.py b/doc/examples/cdrom.py index bf044d7c..e54eb763 100644 --- a/doc/examples/cdrom.py +++ b/doc/examples/cdrom.py @@ -22,11 +22,5 @@ print "ident result is: %s (%s) " % (res, ident) apt_pkg.Config.Set("APT::CDROM::Rename", "True") cdrom.Add(progress) - - print "Exiting" sys.exit(0) - - - - diff --git a/doc/examples/deb_inspect.py b/doc/examples/deb_inspect.py index b57526c6..68219d6d 100755 --- a/doc/examples/deb_inspect.py +++ b/doc/examples/deb_inspect.py @@ -6,6 +6,7 @@ import apt_inst import sys import os.path + def Callback(What,Name,Link,Mode,UID,GID,Size,MTime,Major,Minor): """ callback for debExtract """ @@ -40,8 +41,10 @@ if __name__ == "__main__": dir = "/tmp/deb" os.mkdir(dir) apt_inst.debExtractArchive(open(file),dir) + def visit(arg, dirname, names): print "%s/" % dirname for file in names: print "\t%s" % file + os.path.walk(dir, visit, None) diff --git a/doc/examples/desc.py b/doc/examples/desc.py index 87b9473b..1d43f2f9 100644 --- a/doc/examples/desc.py +++ b/doc/examples/desc.py @@ -22,4 +22,3 @@ records.Lookup((f,index)) desc = records.LongDesc print len(desc) print desc - diff --git a/doc/examples/gui-inst.py b/doc/examples/gui-inst.py index 5e5d2c99..28887d34 100755 --- a/doc/examples/gui-inst.py +++ b/doc/examples/gui-inst.py @@ -18,7 +18,9 @@ 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() @@ -31,12 +33,15 @@ class GuiFetchProgress(gtk.Window, FetchProgress): 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)) @@ -45,7 +50,9 @@ class GuiFetchProgress(gtk.Window, FetchProgress): gtk.main_iteration() return True + class TermInstallProgress(InstallProgress, gtk.Window): + def __init__(self): gtk.Window.__init__(self) InstallProgress.__init__(self) @@ -63,13 +70,16 @@ class TermInstallProgress(InstallProgress, gtk.Window): 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() @@ -78,18 +88,20 @@ class TermInstallProgress(InstallProgress, gtk.Window): 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() @@ -101,12 +113,10 @@ iprogress = TermInstallProgress() #depcache.ReadPinFile() #depcache.Init(progress) - # show the interface while gtk.events_pending(): gtk.main_iteration() - pkg = cache["3dchess"] print "\n%s"%pkg.name @@ -119,6 +129,3 @@ cache.commit(fprogress, iprogress) print "Exiting" sys.exit(0) - - - diff --git a/doc/examples/inst.py b/doc/examples/inst.py index ff9d452c..d1e2ff99 100644 --- a/doc/examples/inst.py +++ b/doc/examples/inst.py @@ -8,10 +8,13 @@ import time from apt.progress import InstallProgress + class TextInstallProgress(InstallProgress): + def __init__(self): apt.progress.InstallProgress.__init__(self) self.last = 0.0 + def updateInterface(self): InstallProgress.updateInterface(self) if self.last >= self.percent: @@ -19,11 +22,14 @@ class TextInstallProgress(InstallProgress): sys.stdout.write("\r[%s] %s\n" %(self.percent, self.status)) sys.stdout.flush() self.last = self.percent + def conffile(self,current,new): print "conffile prompt: %s %s" % (current,new) + def error(self, errorstr): print "got dpkg error: '%s'" % errorstr + cache = apt.Cache(apt.progress.OpTextProgress()) fprogress = apt.progress.TextFetchProgress() @@ -42,7 +48,3 @@ res = cache.commit(fprogress, iprogress) print res sys.exit(0) - - - - diff --git a/doc/examples/progress.py b/doc/examples/progress.py index b90253cb..39e73e70 100644 --- a/doc/examples/progress.py +++ b/doc/examples/progress.py @@ -4,7 +4,9 @@ import sys import time import string + class TextProgress(apt.OpProgress): + def __init__(self): self.last=0.0 @@ -21,6 +23,7 @@ class TextProgress(apt.OpProgress): class TextFetchProgress(apt.FetchProgress): + def __init__(self): pass @@ -32,6 +35,7 @@ class TextFetchProgress(apt.FetchProgress): def updateStatus(self, uri, descr, shortDescr, status): print "UpdateStatus: '%s' '%s' '%s' '%i'" % (uri,descr,shortDescr, status) + def pulse(self): print "Pulse: CPS: %s/s; Bytes: %s/%s; Item: %s/%s" % (SizeToStr(self.currentCPS), SizeToStr(self.currentBytes), SizeToStr(self.totalBytes), self.currentItems, self.totalItems) return True @@ -43,15 +47,20 @@ class TextFetchProgress(apt.FetchProgress): class TextInstallProgress(apt.InstallProgress): + def __init__(self): apt.InstallProgress.__init__(self) pass + def startUpdate(self): print "StartUpdate" + def finishUpdate(self): print "FinishUpdate" + def statusChange(self, pkg, percent, status): print "[%s] %s: %s" % (percent, pkg, status) + def updateInterface(self): apt.InstallProgress.updateInterface(self) # usefull to e.g. redraw a GUI @@ -59,17 +68,22 @@ class TextInstallProgress(apt.InstallProgress): class TextCdromProgress(apt.CdromProgress): + def __init__(self): pass + # update is called regularly so that the gui can be redrawn + def update(self, text, step): # check if we actually have some text to display if text != "": print "Update: %s %s" % (string.strip(text), step) + def askCdromName(self): print "Please enter cd-name: ", cd_name = sys.stdin.readline() return (True, string.strip(cd_name)) + def changeCdrom(self): print "Please insert cdrom and press <ENTER>" answer = sys.stdin.readline() diff --git a/doc/examples/recommends.py b/doc/examples/recommends.py index c1a7eb2e..03d46068 100755 --- a/doc/examples/recommends.py +++ b/doc/examples/recommends.py @@ -5,6 +5,7 @@ apt_pkg.init() cache = apt_pkg.GetCache() + class Wanted: def __init__(self, name): @@ -12,6 +13,7 @@ class Wanted: self.recommended = [] self.suggested = [] + wanted = {} for package in cache.Packages: @@ -35,7 +37,3 @@ ks.sort() for want in ks: print want, wanted[want].recommended, wanted[want].suggested - - - - |
